diff mercurial/dirstate.py @ 2042:a514c7509fa9

small changes to revert command. fix bug 93: work with files that are in target manifest but not dirstate.
author Vadim Gelfer <vadim.gelfer@gmail.com>
date Mon, 03 Apr 2006 10:02:09 -0700
parents a59da8cc35e4
children 5460f0196f77
line wrap: on
line diff
--- a/mercurial/dirstate.py	Mon Apr 03 14:56:00 2006 +0200
+++ b/mercurial/dirstate.py	Mon Apr 03 10:02:09 2006 -0700
@@ -294,7 +294,8 @@
                 kind))
         return False
 
-    def statwalk(self, files=None, match=util.always, dc=None, ignored=False):
+    def statwalk(self, files=None, match=util.always, dc=None, ignored=False,
+                 badmatch=None):
         self.lazyread()
 
         # walk all files by default
@@ -311,11 +312,12 @@
                 return False
             return match(file_)
 
-        return self.walkhelper(files=files, statmatch=statmatch, dc=dc)
+        return self.walkhelper(files=files, statmatch=statmatch, dc=dc,
+                               badmatch=badmatch)
 
-    def walk(self, files=None, match=util.always, dc=None):
+    def walk(self, files=None, match=util.always, dc=None, badmatch=None):
         # filter out the stat
-        for src, f, st in self.statwalk(files, match, dc):
+        for src, f, st in self.statwalk(files, match, dc, badmatch=badmatch):
             yield src, f
 
     # walk recursively through the directory tree, finding all files
@@ -330,7 +332,7 @@
     # dc is an optional arg for the current dirstate.  dc is not modified
     # directly by this function, but might be modified by your statmatch call.
     #
-    def walkhelper(self, files, statmatch, dc):
+    def walkhelper(self, files, statmatch, dc, badmatch=None):
         # recursion free walker, faster than os.walk.
         def findfiles(s):
             work = [s]
@@ -379,9 +381,12 @@
                         found = True
                         break
                 if not found:
-                    self.ui.warn('%s: %s\n' % (
-                                 util.pathto(self.getcwd(), ff),
-                                 inst.strerror))
+                    if inst.errno != errno.ENOENT or not badmatch:
+                        self.ui.warn('%s: %s\n' % (
+                            util.pathto(self.getcwd(), ff),
+                            inst.strerror))
+                    elif badmatch and badmatch(ff) and statmatch(ff, None):
+                        yield 'b', ff, None
                 continue
             if stat.S_ISDIR(st.st_mode):
                 cmp1 = (lambda x, y: cmp(x[1], y[1]))