[PATCH 1 of 2 V3] dirstate: add an extension hook to avoid full walks

Siddharth Agarwal sid0 at fb.com
Mon May 13 18:08:03 CDT 2013


# HG changeset patch
# User Siddharth Agarwal <sid0 at fb.com>
# Date 1366675878 25200
#      Mon Apr 22 17:11:18 2013 -0700
# Node ID 3fdad8e0543ab0e4f0891f53b0055f409d9ef999
# Parent  0a031b2198905fed27a2c5adbda215c7907d3cea
dirstate: add an extension hook to avoid full walks

Consider a hypothetical extension that implements walk in a more efficient
manner and skips some known-clean files. However, that can only be done under
some situations, such as when clean files are not being asked for and a
match.traversedir callback is not set. The full flag lets walk tell these two
cases apart.

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -623,14 +623,19 @@
 
         return results, dirsfound, dirsnotfound
 
-    def walk(self, match, subrepos, unknown, ignored):
+    def walk(self, match, subrepos, unknown, ignored, full=True):
         '''
         Walk recursively through the directory tree, finding all files
         matched by match.
 
+        If full is False, maybe skip some known-clean files.
+
         Return a dict mapping filename to stat-like object (either
         mercurial.osutil.stat instance or return value of os.stat()).
+
         '''
+        # full is an extension hook -- this implementation doesn't use it at
+        # all. This satisfies the contract because we only guarantee a "maybe".
 
         def fwarn(f, msg):
             self._ui.warn('%s: %s\n' % (self.pathto(f), msg))


More information about the Mercurial-devel mailing list