[PATCH 1 of 3] pathauditor: add isvalidpath() method

Durham Goode durham at fb.com
Tue Feb 5 17:38:38 CST 2013


# HG changeset patch
# User Durham Goode <durham at fb.com>
# Date 1360103054 28800
# Node ID f2a1cf2cbb4ac88f922c5bcb5792c2c7c4c236d5
# Parent  c6377e34cb1ed79cb142f01652b0acfa09ef8c1f
pathauditor: add isvalidpath() 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

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -175,6 +175,13 @@
         # want to add "foo/bar/baz" before checking if there's a "foo/.hg"
         self.auditeddir.update(prefixes)
 
+    def isvalidpath(self, path):
+        try:
+            self(path)
+            return True
+        except (OSError, util.Abort):
+            return False
+
 class abstractvfs(object):
     """Abstract base class; cannot be instantiated"""
 
@@ -736,11 +743,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.isvalidpath(abs)
 
         st = walkresults[abs]
         dstate = repo.dirstate[abs]


More information about the Mercurial-devel mailing list