Patchwork [01,of,17] match: make matchfn a method on the class

login
register
mail settings
Submitter via Mercurial-devel
Date May 25, 2017, 6:24 p.m.
Message ID <e9e0159ca48dd1771b53.1495736682@martinvonz.svl.corp.google.com>
Download mbox | patch
Permalink /patch/20903/
State Accepted
Headers show

Comments

via Mercurial-devel - May 25, 2017, 6:24 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1495731169 25200
#      Thu May 25 09:52:49 2017 -0700
# Node ID e9e0159ca48dd1771b53c3091c7def2f6f77d5bd
# Parent  2b5953a49f1407f825d65b45986d213cb5c79203
match: make matchfn a method on the class

This makes it easier to override in subclasses, so they don't have to
assign the attribute with a lambda.

Patch

diff --git a/mercurial/match.py b/mercurial/match.py
--- a/mercurial/match.py
+++ b/mercurial/match.py
@@ -209,7 +209,6 @@ 
         self._cwd = cwd
         if badfn is not None:
             self.bad = badfn
-        self.matchfn = lambda f: False
 
     def __call__(self, fn):
         return self.matchfn(fn)
@@ -266,6 +265,9 @@ 
         '''Returns True if f is in .files().'''
         return f in self._fileset
 
+    def matchfn(self, f):
+        return False
+
     def visitdir(self, dir):
         '''Decides whether a directory should be visited based on whether it
         has potential matches in it or one of its subdirectories. This is