Patchwork [1,of,2,V4] dirstate.walk: add a flag to let extensions avoid full walks

login
register
mail settings
Submitter Siddharth Agarwal
Date May 14, 2013, 5:34 p.m.
Message ID <c7b2b674c7b820dda44a.1368552881@dev1091.prn1.facebook.com>
Download mbox | patch
Permalink /patch/1632/
State Accepted
Commit b03952ee634de701b54a936830d6cac7ccac7e50
Headers show

Comments

Siddharth Agarwal - May 14, 2013, 5:34 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1366675878 25200
#      Mon Apr 22 17:11:18 2013 -0700
# Node ID c7b2b674c7b820dda44a09f270c4b67ac514f636
# Parent  0a031b2198905fed27a2c5adbda215c7907d3cea
dirstate.walk: add a flag to let extensions 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.
Bryan O'Sullivan - May 14, 2013, 5:40 p.m.
On Tue, May 14, 2013 at 10:34 AM, Siddharth Agarwal <sid0@fb.com> wrote:

> dirstate.walk: add a flag to let extensions avoid full walks
>

Both applied, thanks.

Patch

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -623,14 +623,20 @@ 
 
         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 a flag that extensions that hook into walk can use -- 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))