[PATCH 1 of 2] localrepo: filter out subrepos from status checks

durin42 at gmail.com durin42 at gmail.com
Tue Dec 8 15:15:06 CST 2009


# HG changeset patch
# User Augie Fackler <durin42 at gmail.com>
# Date 1260291595 21600
# Node ID 7bb991c4c3da3996272858798959de9de48e4f99
# Parent  4e3a8f3e9dc26dcc08bd7d134906a6e3043b1118
localrepo: filter out subrepos from status checks

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -989,6 +989,10 @@
         match = match or match_.always(self.root, self.getcwd())
         listignored, listclean, listunknown = ignored, clean, unknown
 
+        subrepos = self[None].substate.keys()
+        if subrepos:
+            match = match_.filteringmatcher(self.root, self.getcwd(), match, subrepos)
+
         # load earliest manifest first for caching reasons
         if not working and ctx2.rev() < ctx1.rev():
             ctx2.manifest()
diff --git a/mercurial/match.py b/mercurial/match.py
--- a/mercurial/match.py
+++ b/mercurial/match.py
@@ -107,6 +107,36 @@
     def __init__(self, root, cwd):
         match.__init__(self, root, cwd, [])
 
+class filteringmatcher(match):
+    def __init__(self, root, cwd, parent, exclude):
+        self.excludepaths = exclude
+        self.parent = parent
+
+    def _isfiltered(self, fn):
+        return sum(map(fn.startswith, self.excludepaths))
+
+    def matchfn(self, fn):
+        if self._isfiltered(fn):
+            return False
+        return self.parent(fn)
+
+    def __iter__(self):
+        for f in self.parent:
+            if self._isfiltered(f):
+                continue
+            yield f
+
+    def exact(self, f):
+        if self._isfiltered(f):
+            return False
+        return self.parent.exact(f)
+
+    def files(self):
+        return filter(self._isfiltered, self.parent._files)
+
+    def anypats(self):
+        return self.parent.anypats()
+
 def patkind(pat):
     return _patsplit(pat, None)[0]
 


More information about the Mercurial-devel mailing list