# HG changeset patch # User Matt Mackall # Date 1206039239 18000 # 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 -r af3f26b6bba4 -r 6d952dc2abc9 mercurial/dirstate.py --- a/mercurial/dirstate.py Wed Mar 19 17:55:21 2008 -0300 +++ b/mercurial/dirstate.py Thu Mar 20 13:53:59 2008 -0500 @@ -66,12 +66,6 @@ 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 @@ 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 -r af3f26b6bba4 -r 6d952dc2abc9 tests/test-race --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-race Thu Mar 20 13:53:59 2008 -0500 @@ -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 -r af3f26b6bba4 -r 6d952dc2abc9 tests/test-race.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-race.out Thu Mar 20 13:53:59 2008 -0500 @@ -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