walk: use match.dir in statwalk
authorMatt Mackall <mpm@selenic.com>
Mon, 12 May 2008 11:37:08 -0500
changeset 6588 10c23c1d5f33
parent 6587 a259e217bc0c
child 6589 0f98cae7c77f
walk: use match.dir in statwalk
hgext/purge.py
mercurial/dirstate.py
--- a/hgext/purge.py	Mon May 12 11:37:08 2008 -0500
+++ b/hgext/purge.py	Mon May 12 11:37:08 2008 -0500
@@ -86,11 +86,10 @@
     files = []
     missing = []
     match = cmdutil.match(repo, dirs, opts)
+    match.dir = directories.append
     for src, f, st in repo.dirstate.statwalk(match.files(), match,
-                                             ignored=ignored, directories=True):
-        if src == 'd':
-            directories.append(f)
-        elif src == 'm':
+                                             ignored=ignored):
+        if src == 'm':
             missing.append(f)
         elif src == 'f' and f not in repo.dirstate:
             files.append(f)
--- a/mercurial/dirstate.py	Mon May 12 11:37:08 2008 -0500
+++ b/mercurial/dirstate.py	Mon May 12 11:37:08 2008 -0500
@@ -422,7 +422,7 @@
             yield f
 
     def statwalk(self, files, match, unknown=True,
-                 ignored=False, badfn=None, directories=False):
+                 ignored=False, badfn=None):
         '''
         walk recursively through the directory tree, finding all files
         matched by the match function
@@ -430,7 +430,6 @@
         results are yielded in a tuple (src, filename, st), where src
         is one of:
         'f' the file was found in the directory tree
-        'd' the file is a directory of the tree
         'm' the file was only in the dirstate and not in the tree
 
         and st is the stat result if the file was found in the directory.
@@ -485,8 +484,8 @@
             wadd = work.append
             found = []
             add = found.append
-            if directories:
-                add((normpath(s[common_prefix_len:]), 'd', lstat(s)))
+            if hasattr(match, 'dir'):
+                match.dir(normpath(s[common_prefix_len:]))
             while work:
                 top = work.pop()
                 entries = listdir(top, stat=True)
@@ -513,8 +512,8 @@
                     if kind == stat.S_IFDIR:
                         if not ignore(np):
                             wadd(p)
-                            if directories:
-                                add((np, 'd', st))
+                            if hasattr(match, 'dir'):
+                                match.dir(np)
                         if np in dc and match(np):
                             add((np, 'm', st))
                     elif imatch(np):