[PATCH 2 of 3] dirstate: add getfstime() to get current time to filesystem resolution
Matt Mackall
mpm at selenic.com
Wed Mar 16 03:33:39 UTC 2011
On Tue, 2011-03-15 at 21:39 -0400, Greg Ward wrote:
> # HG changeset patch
> # User Greg Ward <greg at gerg.ca>
> # Date 1300238571 14400
> # Node ID a32697a387d0ff0b7327cb993b700c1eb0310326
> # Parent c5fa123f60a63af19057e873106c532ee2c553fa
> dirstate: add getfstime() to get current time to filesystem resolution.
>
> Based on code already in write(). Will be needed by
> localrepository.commit() to call dirstate.maybelookup().
And this tempfile is needed because we don't have a handy file around
that we're already writing to?
> diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
> --- a/mercurial/dirstate.py
> +++ b/mercurial/dirstate.py
> @@ -10,6 +10,7 @@
> import util, ignore, osutil, parsers, encoding
> import struct, os, stat, errno
> import cStringIO
> +import tempfile
>
> _format = ">cllll"
> propertycache = util.propertycache
> @@ -391,6 +392,15 @@
> self._pl = (parent, nullid)
> self._dirty = True
>
> + def getfstime(self, dir):
> + '''Return the current time to filesystem resolution.'''
> + (fd, fn) = tempfile.mkstemp(dir=dir)
> + try:
> + return int(os.fstat(fd).st_mtime)
> + finally:
> + os.close(fd)
> + os.unlink(fn)
> +
> def maybelookup(self, f, now):
> '''Examine f to determine if it needs more work to determine its
> true status, or whether it can be considered normal. If more
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
--
Mathematics is the supreme nostalgia of our time.
More information about the Mercurial-devel
mailing list