Patchwork match: minor cleanups to patternmatcher and includematcher

login
register
mail settings
Submitter via Mercurial-devel
Date July 6, 2017, 5:59 p.m.
Message ID <1174e71dbffd4a1b6ce6.1499363968@martinvonz.svl.corp.google.com>
Download mbox | patch
Permalink /patch/22029/
State Accepted
Headers show

Comments

via Mercurial-devel - July 6, 2017, 5:59 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1496987361 25200
#      Thu Jun 08 22:49:21 2017 -0700
# Node ID 1174e71dbffd4a1b6ce6eaf8d91f2452d4724071
# Parent  348b491c093401f849ea4c4106b164672efc6bed
match: minor cleanups to patternmatcher and includematcher

The "patterns"/"include" in "patternspat"/"includepat" is redundant,
so drop it. Also a "_" prefix since it's "private".

Inline the "pm"/"im" variables.
Sean Farley - July 6, 2017, 6:11 p.m.
Martin von Zweigbergk via Mercurial-devel <mercurial-devel@mercurial-scm.org> writes:

> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz@google.com>
> # Date 1496987361 25200
> #      Thu Jun 08 22:49:21 2017 -0700
> # Node ID 1174e71dbffd4a1b6ce6eaf8d91f2452d4724071
> # Parent  348b491c093401f849ea4c4106b164672efc6bed
> match: minor cleanups to patternmatcher and includematcher
>
> The "patterns"/"include" in "patternspat"/"includepat" is redundant,
> so drop it. Also a "_" prefix since it's "private".
>
> Inline the "pm"/"im" variables.

Looks good, queued!

Patch

diff --git a/mercurial/match.py b/mercurial/match.py
--- a/mercurial/match.py
+++ b/mercurial/match.py
@@ -358,9 +358,8 @@ 
 
         self._files = _explicitfiles(kindpats)
         self._anypats = _anypats(kindpats)
-        self.patternspat, pm = _buildmatch(ctx, kindpats, '$', listsubrepos,
-                                           root)
-        self.matchfn = pm
+        self._pats, self.matchfn = _buildmatch(ctx, kindpats, '$', listsubrepos,
+                                               root)
 
     @propertycache
     def _dirs(self):
@@ -379,7 +378,7 @@ 
         return self._anypats
 
     def __repr__(self):
-        return ('<patternmatcher patterns=%r>' % self.patternspat)
+        return ('<patternmatcher patterns=%r>' % self._pats)
 
 class includematcher(basematcher):
 
@@ -387,15 +386,14 @@ 
                  badfn=None):
         super(includematcher, self).__init__(root, cwd, badfn)
 
-        self.includepat, im = _buildmatch(ctx, kindpats, '(?:/|$)',
-                                          listsubrepos, root)
+        self._pats, self.matchfn = _buildmatch(ctx, kindpats, '(?:/|$)',
+                                               listsubrepos, root)
         self._anypats = _anypats(kindpats)
         roots, dirs = _rootsanddirs(kindpats)
         # roots are directories which are recursively included.
         self._roots = set(roots)
         # dirs are directories which are non-recursively included.
         self._dirs = set(dirs)
-        self.matchfn = im
 
     def visitdir(self, dir):
         if not self._anypats and dir in self._roots:
@@ -411,7 +409,7 @@ 
         return True
 
     def __repr__(self):
-        return ('<includematcher includes=%r>' % self.includepat)
+        return ('<includematcher includes=%r>' % self._pats)
 
 class exactmatcher(basematcher):
     '''Matches the input files exactly. They are interpreted as paths, not