diff mercurial/dirstate.py @ 4146:e287d61dd268

Yield directories in dirstate.statwalk()
author Emanuele Aina <faina.mail@tiscali.it>
date Tue, 06 Mar 2007 17:45:39 -0300
parents e6d26e71f049
children ba51a8225a60
line wrap: on
line diff
--- a/mercurial/dirstate.py	Tue Mar 06 17:45:38 2007 -0300
+++ b/mercurial/dirstate.py	Tue Mar 06 17:45:39 2007 -0300
@@ -357,7 +357,7 @@
             yield src, f
 
     def statwalk(self, files=None, match=util.always, ignored=False,
-                 badmatch=None):
+                 badmatch=None, directories=False):
         '''
         walk recursively through the directory tree, finding all files
         matched by the match function
@@ -365,6 +365,7 @@
         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
         'b' file was not found and matched badmatch
 
@@ -394,6 +395,8 @@
         # recursion free walker, faster than os.walk.
         def findfiles(s):
             work = [s]
+            if directories:
+                yield 'd', util.normpath(s[common_prefix_len:]), os.lstat(s)
             while work:
                 top = work.pop()
                 names = os.listdir(top)
@@ -421,6 +424,8 @@
                         ds = util.pconvert(os.path.join(nd, f +'/'))
                         if imatch(ds):
                             work.append(p)
+                            if directories:
+                                yield 'd', np, st
                         if imatch(np) and np in dc:
                             yield 'm', np, st
                     elif imatch(np):