Patchwork [1,of,4] match: make nevermatcher an exact matcher and a prefix matcher

login
register
mail settings
Submitter via Mercurial-devel
Date July 10, 2017, 5:27 p.m.
Message ID <0ce91c7d311a808b253c.1499707661@martinvonz.svl.corp.google.com>
Download mbox | patch
Permalink /patch/22207/
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 1499638767 25200
#      Sun Jul 09 15:19:27 2017 -0700
# Node ID 0ce91c7d311a808b253c3b4d406e137168c95130
# Parent  062c1bde178118b7c4d5abb1ead16ac8ad494280
match: make nevermatcher an exact matcher and a prefix matcher

The m.isexact() and m.prefix() methods are used by callers to
determine whether m.files() can be used for fast paths. It seems safe
to let callers to any fast paths it can that rely on the empty
m.files().
Yuya Nishihara - July 11, 2017, 1:18 p.m.
On Mon, 10 Jul 2017 10:27:41 -0700, Martin von Zweigbergk via Mercurial-devel wrote:
> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz@google.com>
> # Date 1499638767 25200
> #      Sun Jul 09 15:19:27 2017 -0700
> # Node ID 0ce91c7d311a808b253c3b4d406e137168c95130
> # Parent  062c1bde178118b7c4d5abb1ead16ac8ad494280
> match: make nevermatcher an exact matcher and a prefix matcher

Queued 1, 2, and 4, thanks.

Patch

diff --git a/mercurial/match.py b/mercurial/match.py
--- a/mercurial/match.py
+++ b/mercurial/match.py
@@ -347,6 +347,17 @@ 
     def __init__(self, root, cwd, badfn=None):
         super(nevermatcher, self).__init__(root, cwd, badfn)
 
+    # It's a little weird to say that the nevermatcher is an exact matcher
+    # or a prefix matcher, but it seems to make sense to let callers take
+    # fast paths based on either. There will be no exact matches, nor any
+    # prefixes (files() returns []), so fast paths iterating over them should
+    # be efficient (and correct).
+    def isexact(self):
+        return True
+
+    def prefix(self):
+        return True
+
     def __repr__(self):
         return '<nevermatcher>'