match: add doctest examples for exactmatcher
authorDenis Laxalde <denis@laxalde.org>
Sun, 07 Apr 2019 12:21:23 +0200
changeset 42080 f3db5c805a67
parent 42079 fcd7a91dec23
child 42081 bf777c1e78dd
match: add doctest examples for exactmatcher Make the docstring raw, since it now includes escape characters.
mercurial/match.py
--- a/mercurial/match.py	Fri Apr 05 11:24:00 2019 -0700
+++ b/mercurial/match.py	Sun Apr 07 12:21:23 2019 +0200
@@ -568,8 +568,24 @@
         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):