[PATCH 3 of 4] match: avoid accessing match._pathrestricted from subdirmatcher

Martin von Zweigbergk martinvonz at google.com
Thu May 18 14:03:45 EDT 2017


# HG changeset patch
# User Martin von Zweigbergk <martinvonz at google.com>
# Date 1494631881 25200
#      Fri May 12 16:31:21 2017 -0700
# Node ID 786822a7d1d8c5c90f393ea2d0fc06cdb0a96a00
# Parent  c387c5e78c2cbd703c791fc8b9515526d1ce6155
match: avoid accessing match._pathrestricted from subdirmatcher

Accessing only the public API wherever possible helps us refactor
matchers later.

diff --git a/mercurial/match.py b/mercurial/match.py
--- a/mercurial/match.py
+++ b/mercurial/match.py
@@ -381,7 +381,6 @@
         self._path = path
         self._matcher = matcher
         self._always = matcher._always
-        self._pathrestricted = matcher._pathrestricted
 
         self._files = [f[len(path) + 1:] for f in matcher._files
                        if f.startswith(path + "/")]
@@ -398,15 +397,18 @@
         # call the original matcher with the subdirectory path prepended.
         self.matchfn = lambda fn: matcher.matchfn(self._path + "/" + fn)
 
+    def bad(self, f, msg):
+        self._matcher.bad(self._path + "/" + f, msg)
+
     def abs(self, f):
         return self._matcher.abs(self._path + "/" + f)
 
-    def bad(self, f, msg):
-        self._matcher.bad(self._path + "/" + f, msg)
-
     def rel(self, f):
         return self._matcher.rel(self._path + "/" + f)
 
+    def uipath(self, f):
+        return self._matcher.uipath(self._path + "/" + f)
+
     def visitdir(self, dir):
         if dir == '.':
             dir = self._path


More information about the Mercurial-devel mailing list