one byte change to file not detected ?

Steve Borho steve at borho.org
Wed Feb 27 14:11:35 CST 2008


On Wed, 2008-02-20 at 17:27 -0300, Alexis S. L. Carvalho wrote:
> Thus spake Patrick Mézard:
> > BuraphaLinux Server a écrit :
> > > Clearly mercurial cares more about speed than safety.
> > > 
> > > Yeah, I can patch it but then I have to rehack it every time they
> > > release since clearly this is some dumb policy decision to make their
> > > stuff benchmark better at the cost of safety.
> > 
> > Just by curiosity, what VCS implementing the smart policy are you using ?
> 
> I don't remember what git does, but IIRC bzr and monotone avoid caching
> the stat(2) data when the mtime is too recent.  E.g. if we're writing
> the dirstate at time X, don't save data for files with mtime >= X-3.
> 
> And of course, if there's no stat data, do a full compare.
> 
> Something like the patch below (but it would need a better name for
> ui.limit and I should probably use the mtime of the new dirstate instead
> of time.time).
> 
> Alexis
> 
> 
> diff -r b023915aa1bc mercurial/dirstate.py
> --- a/mercurial/dirstate.py
> +++ b/mercurial/dirstate.py
> @@ -10,7 +10,7 @@ from node import *
>  from node import *
>  from i18n import _
>  import struct, os, time, bisect, stat, strutil, util, re, errno, ignore
> -import cStringIO, osutil
> +import cStringIO, osutil, sys, time
>  
>  _unknown = ('?', 0, 0, 0)
>  _format = ">cllll"
> @@ -63,6 +63,12 @@ class dirstate(object):
>          elif name == '_slash':
>              self._slash = self._ui.configbool('ui', 'slash') and os.sep != '/'
>              return self._slash
> +        elif name == '_limit':
> +            try:
> +                self._limit = int(self._ui.config('ui', 'limit', 0))
> +            except ValueError:
> +                self._limit = 0
> +            return self._limit
>          else:
>              raise AttributeError, name
>  
> @@ -310,6 +316,10 @@ class dirstate(object):
>      def write(self):
>          if not self._dirty:
>              return
> +        if self._limit > 0:
> +            limit = int(time.time() - self._limit)
> +        else:
> +            limit = sys.maxint
>          cs = cStringIO.StringIO()
>          copymap = self._copymap
>          pack = struct.pack
> @@ -318,6 +328,10 @@ 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:
> +                self._ui.debug("ignoring stat data for %s. %d > %d\n"
> +                               % (f, e[3], limit))
> +                e = (e[0], 0, -1, -1, 0)
>              e = pack(_format, e[0], e[1], e[2], e[3], len(f))
>              write(e)
>              write(f)

Any reason why this (or something like it) hasn't made it into crew yet?

-- 
Steve Borho (steve at borho.org)
http://www.borho.org/~steve/steve.asc
Key fingerprint = 2D08 E7CF B624 624C DE1F  E2E4 B0C2 5292 F2C6 2C8C



More information about the Mercurial mailing list