Patchwork [1,of,2,V2] dirstate: add an extension hook for interesting files

login
register
mail settings
Submitter Siddharth Agarwal
Date May 13, 2013, 7:47 p.m.
Message ID <ed4040d92e56cd7a963f.1368474451@dev1091.prn1.facebook.com>
Download mbox | patch
Permalink /patch/1619/
State Superseded, archived
Headers show

Comments

Siddharth Agarwal - May 13, 2013, 7:47 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1366675878 25200
#      Mon Apr 22 17:11:18 2013 -0700
# Node ID ed4040d92e56cd7a963f896f72bcf55922449171
# Parent  0a031b2198905fed27a2c5adbda215c7907d3cea
dirstate: add an extension hook for interesting files

Consider a hypothetical extension that implements walk in a more efficient
manner and return only files that status would consider interesting. 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
interesting flag lets walk tell these two cases apart.
Matt Mackall - May 13, 2013, 8:11 p.m.
On Mon, 2013-05-13 at 12:47 -0700, Siddharth Agarwal wrote:
> # HG changeset patch
> # User Siddharth Agarwal <sid0@fb.com>
> # Date 1366675878 25200
> #      Mon Apr 22 17:11:18 2013 -0700
> # Node ID ed4040d92e56cd7a963f896f72bcf55922449171
> # Parent  0a031b2198905fed27a2c5adbda215c7907d3cea
> dirstate: add an extension hook for interesting files
> 
> Consider a hypothetical extension that implements walk in a more efficient
> manner and return only files that status would consider interesting. 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
> interesting flag lets walk tell these two cases apart.

The semantics of this flag are extremely confusing. I think it'd be
better to have a flag like this:

 full: if true, do a full walk (default)
       if false, allow skipping known-clean files

Patch

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -623,14 +623,23 @@ 
 
         return results, dirsfound, dirsnotfound
 
-    def walk(self, match, subrepos, unknown, ignored):
+    def walk(self, match, subrepos, unknown, ignored, interesting=False):
         '''
         Walk recursively through the directory tree, finding all files
         matched by match.
 
+        If interesting is True, only return a conservative estimate of files
+        that are somehow interesting. This should include every file that is
+        modified, added, removed, deleted, unknown or ignored (the last two if
+        requested), plus maybe some clean files.
+
         Return a dict mapping filename to stat-like object (either
         mercurial.osutil.stat instance or return value of os.stat()).
+
         '''
+        # interesting is an extension hook -- this implementation doesn't use it
+        # at all. This satisfies the contract because interesting is
+        # conservative.
 
         def fwarn(f, msg):
             self._ui.warn('%s: %s\n' % (self.pathto(f), msg))