[PATCH 2 of 3] dirstate: introduce new config option 'wait'
Adrian Buehlmann
adrian at cadifra.com
Wed May 20 13:07:28 CDT 2009
# HG changeset patch
# User Adrian Buehlmann <adrian at cadifra.com>
# Date 1242664550 -7200
# Node ID ecb607c5062dafd7d37457cace84b3ce1a0594e4
# Parent 664d4f643816dbe4b0563f1e0e59271cfb972375
dirstate: introduce new config option 'wait'
diff --git a/doc/hgrc.5.txt b/doc/hgrc.5.txt
--- a/doc/hgrc.5.txt
+++ b/doc/hgrc.5.txt
@@ -237,6 +237,11 @@ dirstate::
granularity;;
Granularity of the modification time of files (in seconds). Defaults to 1.
If set to 0, Mercurial ignores file time granularity issues.
+ wait;;
+ If True, Mercurial waits n seconds before updating .hg/dirstate. n is
+ defined by option 'granularity' (see above, defaults to 1). Setting wait
+ to True ensures that there are no 'unset' entries in .hg/dirstate (see
+ 'hg debugstate'). Default is False.
[[email]]
email::
diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -10,6 +10,7 @@ from i18n import _
import util, ignore, osutil, parsers
import struct, os, stat, errno
import cStringIO, sys
+import time
_unknown = ('?', 0, 0, 0)
_format = ">cllll"
@@ -374,16 +375,18 @@ class dirstate(object):
def write(self):
if not self._dirty:
return
- st = self._opener("dirstate", "w", atomictemp=True)
-
try:
gran = int(self._ui.config('dirstate', 'granularity', 1))
except ValueError:
gran = 1
- limit = sys.maxint
- if gran > 0:
- limit = util.fstat(st).st_mtime - gran
-
+ wait = self._ui.configbool('dirstate', 'wait')
+ if wait:
+ time.sleep(gran)
+ st = self._opener("dirstate", "w", atomictemp=True)
+ if not wait:
+ limit = sys.maxint
+ if gran > 0:
+ limit = util.fstat(st).st_mtime - gran
cs = cStringIO.StringIO()
copymap = self._copymap
pack = struct.pack
@@ -392,7 +395,7 @@ class dirstate(object):
for f, e in self._map.iteritems():
if f in copymap:
f = "%s\0%s" % (f, copymap[f])
- if e[3] > limit and e[0] == 'n':
+ if not wait and e[0] == 'n' and e[3] > limit:
e = (e[0], 0, -1, -1)
e = pack(_format, e[0], e[1], e[2], e[3], len(f))
write(e)
More information about the Mercurial-devel
mailing list