[PATCH 1 of 8] match: add doctest examples for exactmatcher

Denis Laxalde denis at laxalde.org
Mon Apr 8 04:23:45 EDT 2019


# HG changeset patch
# User Denis Laxalde <denis at laxalde.org>
# Date 1554632483 -7200
#      Sun Apr 07 12:21:23 2019 +0200
# Node ID 9514c11ecebac78d47f1b174a4bbc4d17971ab05
# Parent  675775c33ab66cd157b9929bb0371bf05cbceee6
match: add doctest examples for exactmatcher

Make the docstring raw, since it now includes escape characters.

diff --git a/mercurial/match.py b/mercurial/match.py
--- a/mercurial/match.py
+++ b/mercurial/match.py
@@ -568,8 +568,24 @@ class includematcher(basematcher):
         return ('<includematcher includes=%r>' % pycompat.bytestr(self._pats))
 
 class exactmatcher(basematcher):
-    '''Matches the input files exactly. They are interpreted as paths, not
+    r'''Matches the input files exactly. They are interpreted as paths, not
     patterns (so no kind-prefixes).
+
+    >>> m = exactmatcher(['a.txt', 're:.*\.c$'])
+    >>> m('a.txt')
+    True
+    >>> m('b.txt')
+    False
+
+    Input files that would be matched are exactly those returned by .files()
+    >>> m.files()
+    ['a.txt', 're:.*\\.c$']
+
+    So pattern 're:.*\.c$' is not considered as a regex, but as a file name
+    >>> m('main.c')
+    False
+    >>> m('re:.*\.c$')
+    True
     '''
 
     def __init__(self, files, badfn=None):


More information about the Mercurial-devel mailing list