# HG changeset patch # User Matt Mackall # Date 2008-03-20 18:53:59 # Node ID 6d952dc2abc95595d841c66479b08a3227086b52 # Parent af3f26b6bba45c0a88500214f91fbdcec7abf3c3 dirstate: refactor granularity code, add a test - rename option dirstate.granularity - move option reading into .write() - add a simple test diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -66,12 +66,6 @@ class dirstate(object): elif name == '_checkexec': self._checkexec = util.checkexec(self._root) return self._checkexec - elif name == '_limit': - try: - self._limit = int(self._ui.config('ui', 'limit', 1)) - except ValueError: - self._limit = 1 - return self._limit else: raise AttributeError, name @@ -342,10 +336,15 @@ class dirstate(object): if not self._dirty: return st = self._opener("dirstate", "w", atomictemp=True) - if self._limit > 0: - limit = util.fstat(st).st_mtime - self._limit - else: - limit = sys.maxint + + 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 + cs = cStringIO.StringIO() copymap = self._copymap pack = struct.pack diff --git a/tests/test-race b/tests/test-race new file mode 100755 --- /dev/null +++ b/tests/test-race @@ -0,0 +1,15 @@ +#!/bin/sh + +mkdir t +cd t +hg init +echo a > a +hg add a +hg commit -m test + +# do we ever miss a sub-second change? +for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do + hg co -qC 0 + echo b > a + hg st +done diff --git a/tests/test-race.out b/tests/test-race.out new file mode 100644 --- /dev/null +++ b/tests/test-race.out @@ -0,0 +1,20 @@ +M a +M a +M a +M a +M a +M a +M a +M a +M a +M a +M a +M a +M a +M a +M a +M a +M a +M a +M a +M a