Mercurial > hg
comparison mercurial/match.py @ 42080:f3db5c805a67
match: add doctest examples for exactmatcher
Make the docstring raw, since it now includes escape characters.
author | Denis Laxalde <denis@laxalde.org> |
---|---|
date | Sun, 07 Apr 2019 12:21:23 +0200 |
parents | 0531dff73d0b |
children | bf777c1e78dd |
comparison
equal
deleted
inserted
replaced
42079:fcd7a91dec23 | 42080:f3db5c805a67 |
---|---|
566 @encoding.strmethod | 566 @encoding.strmethod |
567 def __repr__(self): | 567 def __repr__(self): |
568 return ('<includematcher includes=%r>' % pycompat.bytestr(self._pats)) | 568 return ('<includematcher includes=%r>' % pycompat.bytestr(self._pats)) |
569 | 569 |
570 class exactmatcher(basematcher): | 570 class exactmatcher(basematcher): |
571 '''Matches the input files exactly. They are interpreted as paths, not | 571 r'''Matches the input files exactly. They are interpreted as paths, not |
572 patterns (so no kind-prefixes). | 572 patterns (so no kind-prefixes). |
573 | |
574 >>> m = exactmatcher(['a.txt', 're:.*\.c$']) | |
575 >>> m('a.txt') | |
576 True | |
577 >>> m('b.txt') | |
578 False | |
579 | |
580 Input files that would be matched are exactly those returned by .files() | |
581 >>> m.files() | |
582 ['a.txt', 're:.*\\.c$'] | |
583 | |
584 So pattern 're:.*\.c$' is not considered as a regex, but as a file name | |
585 >>> m('main.c') | |
586 False | |
587 >>> m('re:.*\.c$') | |
588 True | |
573 ''' | 589 ''' |
574 | 590 |
575 def __init__(self, files, badfn=None): | 591 def __init__(self, files, badfn=None): |
576 super(exactmatcher, self).__init__(badfn) | 592 super(exactmatcher, self).__init__(badfn) |
577 | 593 |