Mercurial > hg-stable
changeset 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 | fcd7a91dec23 |
children | bf777c1e78dd |
files | mercurial/match.py |
diffstat | 1 files changed, 17 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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):