match: override visitdir() the usual way in subdirmatcher
authorMartin von Zweigbergk <martinvonz@google.com>
Thu, 18 May 2017 10:17:57 -0700
changeset 32323 0aa4032a97e1
parent 32322 23c9a2a71c6e
child 32324 77dac8fd30ee
match: override visitdir() the usual way in subdirmatcher Just override the function instead of replacing it on each instance.
mercurial/match.py
--- a/mercurial/match.py	Thu May 18 09:04:37 2017 -0700
+++ b/mercurial/match.py	Thu May 18 10:17:57 2017 -0700
@@ -397,11 +397,6 @@
         # from the inputs. Instead, we override matchfn() and visitdir() to
         # call the original matcher with the subdirectory path prepended.
         self.matchfn = lambda fn: matcher.matchfn(self._path + "/" + fn)
-        def visitdir(dir):
-            if dir == '.':
-                return matcher.visitdir(self._path)
-            return matcher.visitdir(self._path + "/" + dir)
-        self.visitdir = visitdir
 
     def abs(self, f):
         return self._matcher.abs(self._path + "/" + f)
@@ -412,6 +407,13 @@
     def rel(self, f):
         return self._matcher.rel(self._path + "/" + f)
 
+    def visitdir(self, dir):
+        if dir == '.':
+            dir = self._path
+        else:
+            dir = self._path + "/" + dir
+        return self._matcher.visitdir(dir)
+
 class icasefsmatcher(match):
     """A matcher for wdir on case insensitive filesystems, which normalizes the
     given patterns to the case in the filesystem.