Preserving timestamps

Steve Borho steve at ageia.com
Tue Aug 7 21:00:21 UTC 2007


On Tuesday 07 August 2007 10:29:54 am Henryk Gerlach wrote:
> > From: "Miguel Freitas" (miguel cpti cetuc puc-rio br)
> > Subject: Preserving timestamps
> >
> > Before you fry me in boiling oil... :-)
> > I did read the FAQ ("Why is the modification time of files not
> > restored on checkout?") and recent messages on ml ("Maintaining
> > modified dates of files"). but...
> >
> > I'm currently using hg to manage a FPGA project with Xilinx tools.
> > Their IDE stores about all files, schematics and stuff in plain
> > text, which is a very good thing to allow using hg.
> >
> > My question is, i know preserving mtimes is bad in general, but is
> > it possible to implement this feature for a specific set of files
> > in a repository?
>
> Okay, I gave it a shot, just for the fun of it.
>
> Try the follwing two scripts (and share your improvements)

I don't have any code to volunteer, but I can suggest an alternate 
approach.

Instead of making .timestamps a file, you could make it a directory 
which mirrors the structure of your repository.  To signify a file you 
wish to preserve timestamps, you add an empty placeholder:
mkdir -p $(hg root)/.timestamps/foo/bar
touch $(hg root)/.timestamps/foo/bar/baz.py

So now your hooks do the equivelent of:
touch -r $(hg root)/foo/bar/baz.py $(hg root)/.timestamps/foo/bar/baz.py
<modify baz.py>
touch -r $(hg root)/.timestamps/foo/bar/baz.py $(hg root)/foo/bar/baz.py

Obviously this only works on systems with 'touch', but the equivelent 
could be done with python code as well.  The main idea is to use a 
directory tree instead of a flat file.

-- 
Steve Borho (steve at ageia.com)
http://www.borho.org/~steve/steveAgeia.asc
Key fingerprint = 3D9C 67D5 F426 4322 075B  0795 C9B2 C3A0 97D0 C090



More information about the Mercurial mailing list