A (D)VCS feature that I'd really like

July 6, 2008

Here's something that I want: I want a version control system (ideally a distributed one) that can preserve file timestamps. I'm looking for such a weird feature because I happen to have created something that I want to put under version control where (some of the) file timestamps are significant and need to be preserved.

(This is yet another hazard of using files as entries, albeit in a slightly different form.)

This is an uncommon feature in version control systems at the best of times, partly because actually doing this can muck up source builds when you revert to older versions of files (with older timestamps). I know that neither Mercurial nor Git have this, and while I haven't looked into the 'secondary' DVCSes (such as bzr) very much, my impression is that none of them do it either.

(File timestamps don't have to be first class version controlled data; I'd be happy if the file timestamp was only recorded when some other change to the file was committed, as opposed to causing commits every time it was the only thing that changed.)

I suspect that most practical workaround is a program to save and restore the file timestamps for a directory hierarchy, and then making the file of timestamp data (and possibly the program) part of what's under version control. This requires an extra step on checkouts and especially commits, and if I ever do much branching I'll probably get merge conflicts all the time on the file of timestamp data, but at least it preserves the data.

Comments on this page:

From at 2008-07-07 00:24:30:

I'm not sure whether merge conflicts will be a major issue, but Darcs and many of the others have hooks that let you specify external (or internal to the source tree) programs to be run pre- and post-commit. Among other things this is sometimes used to do things like run autoconf before automatically creating a distribution tarball. From the manual:

darcs setpref predist "autoconf && automake"
darcs dist --dist-name darcs-`./darcs --version`

More pertinently you could easily create a predist script to specify modification times and permissions (the latter and symbolic links being the only things I really miss with Darcs).

- Kate

From at 2008-07-07 12:01:03:

Almost all DVCS allow to specify action after commit or after/before checkout using hooks. You can use hooks to save timestamps to a flat file when committing changes, and restore it from the file after checkout.

If you are using Git you can take a look at Metastore (http://david.hardeman.nu/software.php#metastore): I guess that similar examples exists for other DVCS like Marcurial, Bazaar or Darcs.

Jakub Narebski

From at 2008-07-07 14:51:49:

I would think it would be a lot easier to just hack the source of an existing VCS to do it, rather than try to maintain a secondary database, since I imagine it's a pretty localized change--hopefully there's only one place in the source code that's actually creating the client copy. The only tricky part would be digging out the timestamp from the existing data.

By cks at 2008-07-08 00:14:45:

Unfortunately, I suspect that DVCSes simply don't save the original file timestamp in their data about the file.

By nothings at 2008-07-08 03:06:38:

Hmm, good point. I guess they just store the check-in time, you're right. (Yeah, that was me before.)

Written on 06 July 2008.
« A small drawback to Wietse Venema's TCP Wrappers
How to force Solaris to renumber network devices »

Page tools: View Source, View Normal, Add Comment.
Login: Password:
Atom Syndication: Recent Comments.

Last modified: Sun Jul 6 23:51:38 2008
This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.