Patchwork match: simplify nevermatcher

login
register
mail settings
Submitter via Mercurial-devel
Date June 1, 2017, 3:38 p.m.
Message ID <48de4aeae6788ae9a7f0.1496331497@martinvonz.svl.corp.google.com>
Download mbox | patch
Permalink /patch/21129/
State Accepted
Headers show

Comments

via Mercurial-devel - June 1, 2017, 3:38 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1496331081 25200
#      Thu Jun 01 08:31:21 2017 -0700
# Node ID 48de4aeae6788ae9a7f0c55e8c8e834ddc98b047
# Parent  899dae771ddc4f993005485050545cd85599974a
match: simplify nevermatcher

Most of it does the same as its superclass, so it can simply be
removed. It also seems to make more sense for it to use relative
paths, as we do for everything except alwaysmatcher, although
nevermatcher.uipath() will probably never get called anyway, so it
won't matter.
Sean Farley - June 1, 2017, 8:51 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 1496331081 25200
> #      Thu Jun 01 08:31:21 2017 -0700
> # Node ID 48de4aeae6788ae9a7f0c55e8c8e834ddc98b047
> # Parent  899dae771ddc4f993005485050545cd85599974a
> match: simplify nevermatcher
>
> Most of it does the same as its superclass, so it can simply be
> removed. It also seems to make more sense for it to use relative
> paths, as we do for everything except alwaysmatcher, although
> nevermatcher.uipath() will probably never get called anyway, so it
> won't matter.

Sure, queued. Thanks!

Patch

diff --git a/mercurial/match.py b/mercurial/match.py
--- a/mercurial/match.py
+++ b/mercurial/match.py
@@ -153,8 +153,7 @@ 
                                listsubrepos=listsubrepos, badfn=badfn)
     else:
         # It's a little strange that no patterns means to match everything.
-        # Consider changing this to match nothing (probably adding a
-        # "nevermatcher").
+        # Consider changing this to match nothing (probably using nevermatcher).
         m = alwaysmatcher(root, cwd, badfn)
 
     if include:
@@ -345,18 +344,8 @@ 
 class nevermatcher(basematcher):
     '''Matches nothing.'''
 
-    def __init__(self, root, cwd, badfn=None, relativeuipath=False):
-        super(nevermatcher, self).__init__(root, cwd, badfn,
-                                           relativeuipath=relativeuipath)
-
-    def always(self):
-        return False
-
-    def matchfn(self, f):
-        return False
-
-    def visitdir(self, dir):
-        return False
+    def __init__(self, root, cwd, badfn=None):
+        super(nevermatcher, self).__init__(root, cwd, badfn)
 
     def __repr__(self):
         return '<nevermatcher>'