Mercurial > hg
changeset 6327:6d952dc2abc9
dirstate: refactor granularity code, add a test
- rename option dirstate.granularity
- move option reading into .write()
- add a simple test
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Thu, 20 Mar 2008 13:53:59 -0500 |
parents | af3f26b6bba4 |
children | 991f7518c3f3 |
files | mercurial/dirstate.py tests/test-race tests/test-race.out |
diffstat | 3 files changed, 44 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- /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