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

login
register
mail settings
Submitter via Mercurial-devel
Date May 18, 2017, 6:03 p.m.
Message ID <786822a7d1d8c5c90f39.1495130625@martinvonz.svl.corp.google.com>
Download mbox | patch
Permalink /patch/20685/
State Accepted
Headers show

Comments

via Mercurial-devel - May 18, 2017, 6:03 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@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.

Patch

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