哪个 VCS 能够保留文件时间戳?
我有一组代表“项目”的文件(txt、cfg、手工编辑的二进制文件、脚本等),我希望在存储库中管理这些文件。我想将存储库和服务器(如果需要)放置在我的家用 Windows 计算机上,并且能够远程和本地访问它。
我已经设置了 VisualSVN 服务器和 TortiseSVN 客户端,除了一个主要挂断之外,一切都运行良好;文件时间戳。当我将文件添加到存储库时,SVN 会清除上次修改日期并将其更改为提交时的日期。
我的文件的日期跨越过去 4 年,保留这些时间戳对我来说很重要。我已经搜索过,但还没有找到这个问题的解决方案(尽管似乎很多其他人都要求同样的行为)。
所以我的问题是,是否有一个免费的 VCS 可以捕获原始文件时间戳并满足我的其他一般使用标准?我看了一眼GIT,好像没有,对CVS也不太确定。
感谢您提供的所有帮助,
罗布
I have a collection of files that represent a "project" (txt, cfg, hand edited binary, scripts, etc) that I would like managed in a repository. I would like to house the repository and server (if necessary) on my home Windows machine and be able to access it remotely and locally.
I have setup VisualSVN server and TortiseSVN client and it all works perfectly except for one major hangup; file timestamps. When I add a file to the repository, SVN wipes out the last modified date and changes it to the date when it was committed.
I have files that have dates that span the last 4 years and keeping these timestamps is important to me. I have searched, but have not found a solution to this problem (even though it seems plenty of other people have asked for the same behavior).
So my question is, is there a FREE VCS that allows for original file timestamps to be captured and meets my other general use criteria? I glanced at GIT, but it didn't seem like it did, and I wasn't sure about CVS.
Thanks for any and all help,
Rob
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
Mercurial 有一个扩展,可以自动保存文件时间戳。我已经尝试过了,似乎效果很好。为了使其正常工作,您必须执行以下操作:
下载并安装扩展。
初始化要保留时间戳的存储库,添加文件,但尚未提交。
生成时间戳文件。我认为您必须在提交文件之前执行此操作,但我还没有尝试过这两种方法来确定。
执行初始提交以将文件及其正确的时间戳存储在存储库中。
There is an extension to Mercurial that automatically saves file timestamps. I have tried it out and it seems to work well. In order to get it to work properly, you must do the following:
Download and install the extension.
Initialize the repository where you want to preserve timestamps, add the files, but don't commit yet.
Generate the timestamps file. I think you have to do this before you commit the file, but I haven't tried it both ways to be sure.
Do the initial commit to store the files in the repository with their proper timestamps.
真正保留每个文件的时间戳并不是一种可以很好扩展的方法。
我应该知道,执行此操作的一个 CVCS(集中式 VCS)是... ClearCase ! (请参阅
签入 -ptime
选项)而且太慢了:)
另外,如 manojlds 提到,有这个反对 Git 的这个想法的线程。
尽管如此,还是有一项针对 SVN 的研究,用于保留时间戳:
使用版本控制审计跟踪进行构建来自 Alec Clews,示例位于 github/svnbuilding。
github/gitbuilding 也进行了类似的研究。
在这两种情况下,都是将信息记录在单独的文件中,甚至这也不是恢复日期和时间...
因此,如果您需要此信息:
a/最好适用于全部您放入 VCS 中的文件(尤其是免费版本或任何 DVCS)
b/ 您可以使用 Git:
Truly preserving the timestamp of each and every file is not an approach that scales well.
I should know, the one CVCS (Centralized VCS) which does this is... ClearCase! (see the
checkin -ptime
option)And it is sloooooow :)
Plus, as manojlds mentions, there is this thread against this idea for Git.
Still, there was a study, for SVN, for preserving timestamps:
Building with a Version Control Audit Trail from Alec Clews, with an example in github/svnbuilding.
And there was a similar study with github/gitbuilding.
In both case, it is about recording the information in a separate file, and even that wasn't about restoring dates and time...
So if you need this information:
a/ it better be for all the files you are putting in a VCS (especially a free one, or any DVCS)
b/ you could, with Git:
这可能没有帮助,但 RCS 可以做到这一点。
签入文件时,
ci -d
将签入日期和时间设置为工作文件的上次修改时间。签出文件时,
co -M
将新工作文件的修改时间设置为检索到的修订版本的日期。注意:co(1)
手册页显示当然,RCS 可能缺少您需要的许多其他功能,例如远程访问。
This probably won't help, but RCS does this.
When checking in a file,
ci -d
sets the check-in date and time to the working file's time of last modification.When checking out a file,
co -M
sets the modification time on the new working file to be the date of the retrieved revision. NOTE: Theco(1)
man page saysOf course RCS probably lacks a lot of other features you're going to need, like remote access.
这对于 VCS 来说是一个坏主意,对于某些人来说可能有一些有效的用例 - 但它们会非常晦涩并且与软件无关。所有 VCS 系统都会跟踪此元数据,您的构建脚本可以查询它,然后回溯您的文件。
出于好奇,你为什么要做这样的事情?我认为阐述您遇到的问题并寻求解决方案会比询问如何实施您所采用的解决方案产生更好的结果。
This would be a bad idea for a VCS, there may be some valid use cases for some - but they'll be really obscure and not software related. All VCS systems keep track of this metadata, and your build script could query it and then backdate your files.
Out of curiosity, why would you want to do such a thing? I think expounding on the problem you have and asking for a solution will yield you better results than asking how to implement the one solution you've seized on.
我不确定这是否是您想要的,但以下使用提交时间。如果您希望在第一次提交时保留时间戳,我没有找到办法,除非将其添加到 svn 属性中。
您可以将其添加到您的 svn 配置中,并且它应该使用提交时间:
当时间戳更改为旧日期时,它可能会导致一些问题/混乱,因此使用它时要知道后果是什么。
这与 Git 之类的 DVCS 相同或更糟。 Linus 在一个关于时间戳的线程中回复:
http://kerneltrap.org/mailarchive/git/2007/3/1/240167
I am not sure if this what you want, but the following uses the commit time. If you want the timestamp to be preserved when first committing, I don't see a way, except maybe adding it in a svn property.
You can add this to your svn config and it should use commit time:
It can cause some problems / confusion when timestamp changes to older date so use it knowing what the consequences are.
This is the same or worse in DVCSs like Git. Linus reply in a thread on timestamp:
http://kerneltrap.org/mailarchive/git/2007/3/1/240167
CVS 可以做到。您必须首先使用 cvs import -d ... 添加文件,之后初始签出将创建具有原始时间戳的文件。任何类型的后续更新都会将工作副本中的时间戳更改为当前时间,以免混淆 make 或类似工具。只有初次结帐才能为您提供原始时间。我很喜欢这种行为,因为它可以让你准确地记录历史。
我目前正在寻找自己如何使用 git 执行此操作,但似乎没有。
CVS can do it. You have to add files initially with cvs import -d ... After that the initial checkout will create files with the original timestamp. Subsequent updates of any kind will change the timestamp in the working copy to the current time such as to not confuse make or similar tools. Only the initial checkout will get you the original time. I like that behavior a lot as it allows you to record history accurately.
I am currently looking myself how to do this with git but it seems it doesn't.
我想出了一个解决方法
感谢大家的意见。我已经找到了一个解决方法,可以让我继续使用当前的 SVN 设置。我只是将希望保留原始日期的预先存在的文件和文件夹存档。存档本身的日期在第一次提交时更改为当前日期,但存档中的文件在展开时保留其原始日期。然后,当/如果它们被更新时,我将它们从存档中删除并将它们直接添加到存储库中。
这有点做作,但对我有用。我认为如果 SVN 能够自动捕获属性中的时间戳并在客户端中提供一个选项来获取它并在结账时修改时间戳,那就太好了。显然这不会是默认行为,但我认为拥有该选项没有任何坏处。
I FIGURED OUT A WORKAROUND
Thank you all for your input. I have figured out a workaround that allows me to continue using my current SVN setup. I simply archive the pre-existing files and folders that I wish to retain original dates. The archive itself has the date changed to current on the first commit, but the files in the archive when expanded keep their original dates. Then when/if they are updated, I delete them from archive and add them directly to the repository.
It's kind of hokey, but it works for me. I think it would be nice if SVN could auto capture the timestamp in a property and have an option in the client to grab it and modify the timestamp on checkout. Obviously it wouldn't be default behavior, but I don't see any harm in having that option.
这在 TortoiseSVN 中可以保留原始时间戳。
创建新项目后和首次结帐后
a) 使用 TotalCommander 等工具手动或更好地设置/更正时间戳
b)只需用原始时间戳复制/替换原始位置的所有文件
到您的 TortoiseSVN 结帐的工作副本。替换所有文件。现在他们拥有了
再次原始时间戳。 TortoiseSVN 检测到文件没有更改并保留它们。
注意力:
仅适用于个人/单用户用例。
如果您签出文件,TortoiseSVN 将再次使用提交或当前时间戳。
但只要你只使用 SVN 在单用户用例中签入,那就没问题了。
This works in TortoiseSVN to preserve the original timestamps.
After creating a new project and after first checkout
a) Use a tool like TotalCommander to set/correct the timestamps manually or better
b) Just copy / replace all files from the originally location with original timestamps
to the working copy of your TortoiseSVN checkout. Replace all files. Now they have the
original timestamp again. TortoiseSVN detects that the files haven't changed and leave them alone.
Attention:
Only works for personal / single user use-case.
If you check out the files, TortoiseSVN will use commit or current timestamp again.
But as long you only use SVN to checkin in single user usecase, it will be fine.