diff mercurial/scmutil.py @ 18624:4db216b1c154

pathauditor: add check() method The pathauditor currently throws exceptions when it encounters an invalid path. This change adds a method to allow people to treat it as a boolean. This is currently used by scmutil.addremove and in a subsequent patch it will be used by dirstate.walk
author Durham Goode <durham@fb.com>
date Tue, 05 Feb 2013 14:24:14 -0800
parents 43ffd0279876
children b114e41c4df3
line wrap: on
line diff
--- a/mercurial/scmutil.py	Sat Feb 09 22:54:34 2013 +0000
+++ b/mercurial/scmutil.py	Tue Feb 05 14:24:14 2013 -0800
@@ -184,6 +184,13 @@
         # want to add "foo/bar/baz" before checking if there's a "foo/.hg"
         self.auditeddir.update(prefixes)
 
+    def check(self, path):
+        try:
+            self(path)
+            return True
+        except (OSError, util.Abort):
+            return False
+
 class abstractvfs(object):
     """Abstract base class; cannot be instantiated"""
 
@@ -745,11 +752,7 @@
     ctx = repo[None]
     walkresults = repo.dirstate.walk(m, sorted(ctx.substate), True, False)
     for abs in sorted(walkresults):
-        good = True
-        try:
-            audit_path(abs)
-        except (OSError, util.Abort):
-            good = False
+        good = audit_path.check(abs)
 
         st = walkresults[abs]
         dstate = repo.dirstate[abs]