Patchwork [4,of,4] match: override matchfn instead of __call__ for consistency

login
register
mail settings
Submitter via Mercurial-devel
Date July 10, 2017, 5:27 p.m.
Message ID <34caff173340d2b9a197.1499707664@martinvonz.svl.corp.google.com>
Download mbox | patch
Permalink /patch/22210/
State Accepted
Headers show

Comments

via Mercurial-devel - July 10, 2017, 5:27 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1499442912 25200
#      Fri Jul 07 08:55:12 2017 -0700
# Node ID 34caff173340d2b9a19762e94edf1d96db439382
# Parent  b90074c6fa4739ae6b817d853ebcffd931671933
match: override matchfn instead of __call__ for consistency

The matchers that were recently moved into core from the sparse
extension override __call__, while the previously existing matchers
override matchfn. Let's switch to the latter for consistency.

Patch

diff --git a/mercurial/match.py b/mercurial/match.py
--- a/mercurial/match.py
+++ b/mercurial/match.py
@@ -654,8 +654,8 @@ 
         self._matcher = matcher
         self._includes = includes
 
-    def __call__(self, value):
-        return value in self._includes or self._matcher(value)
+    def matchfn(self, f):
+        return f in self._includes or self._matcher(f)
 
     def __repr__(self):
         return ('<forceincludematcher matcher=%r, includes=%r>' %
@@ -666,9 +666,9 @@ 
     def __init__(self, matchers):
         self._matchers = matchers
 
-    def __call__(self, value):
+    def matchfn(self, f):
         for match in self._matchers:
-            if match(value):
+            if match(f):
                 return True
         return False
 
@@ -679,8 +679,8 @@ 
     def __init__(self, matcher):
         self._matcher = matcher
 
-    def __call__(self, value):
-        return not self._matcher(value)
+    def matchfn(self, f):
+        return not self._matcher(f)
 
     def __repr__(self):
         return ('<negatematcher matcher=%r>' % self._matcher)