[PATCH 1 of 3] pathauditor: add check() method
Durham Goode
durham at fb.com
Sun Feb 10 14:42:31 UTC 2013
# HG changeset patch
# User Durham Goode <durham at fb.com>
# Date 1360103054 28800
# Node ID 814455d55e1f3505442ef96a96f7188f42698d3f
# Parent 57b7531a5705a099637f6d6bedd4de509fb2a441
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
diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -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]
More information about the Mercurial-devel
mailing list