Mercurial > hg
comparison mercurial/match.py @ 12268:83aaeba32b88
narrowmatcher: propagate bad method
The full path is propagated to the original match object since this is
often used directly for printing an error to the user.
author | Martin Geisler <mg@lazybytes.net> |
---|---|
date | Mon, 13 Sep 2010 13:09:09 +0200 |
parents | 69e43c0515f2 |
children | 1f4721de2ca9 |
comparison
equal
deleted
inserted
replaced
12267:69e43c0515f2 | 12268:83aaeba32b88 |
---|---|
129 ['b.txt'] | 129 ['b.txt'] |
130 >>> m2.exact('b.txt') | 130 >>> m2.exact('b.txt') |
131 True | 131 True |
132 >>> m2.rel('b.txt') | 132 >>> m2.rel('b.txt') |
133 'b.txt' | 133 'b.txt' |
134 >>> def bad(f, msg): | |
135 ... print "%s: %s" % (f, msg) | |
136 >>> m1.bad = bad | |
137 >>> m2.bad('x.txt', 'No such file') | |
138 sub/x.txt: No such file | |
134 """ | 139 """ |
135 | 140 |
136 def __init__(self, path, matcher): | 141 def __init__(self, path, matcher): |
137 self._root = matcher._root | 142 self._root = matcher._root |
138 self._cwd = matcher._cwd | 143 self._cwd = matcher._cwd |
142 self._files = [f[len(path) + 1:] for f in matcher._files | 147 self._files = [f[len(path) + 1:] for f in matcher._files |
143 if f.startswith(path + "/")] | 148 if f.startswith(path + "/")] |
144 self._anypats = matcher._anypats | 149 self._anypats = matcher._anypats |
145 self.matchfn = lambda fn: matcher.matchfn(self._path + "/" + fn) | 150 self.matchfn = lambda fn: matcher.matchfn(self._path + "/" + fn) |
146 self._fmap = set(self._files) | 151 self._fmap = set(self._files) |
152 | |
153 def bad(self, f, msg): | |
154 self._matcher.bad(self._path + "/" + f, msg) | |
147 | 155 |
148 def patkind(pat): | 156 def patkind(pat): |
149 return _patsplit(pat, None)[0] | 157 return _patsplit(pat, None)[0] |
150 | 158 |
151 def _patsplit(pat, default): | 159 def _patsplit(pat, default): |