narrowmatcher: propagate bad method
authorMartin Geisler <mg@lazybytes.net>
Mon, 13 Sep 2010 13:09:09 +0200
changeset 12268 83aaeba32b88
parent 12267 69e43c0515f2
child 12269 877236cdd437
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.
mercurial/match.py
--- a/mercurial/match.py	Mon Sep 13 13:08:18 2010 +0200
+++ b/mercurial/match.py	Mon Sep 13 13:09:09 2010 +0200
@@ -131,6 +131,11 @@
     True
     >>> m2.rel('b.txt')
     'b.txt'
+    >>> def bad(f, msg):
+    ...     print "%s: %s" % (f, msg)
+    >>> m1.bad = bad
+    >>> m2.bad('x.txt', 'No such file')
+    sub/x.txt: No such file
     """
 
     def __init__(self, path, matcher):
@@ -145,6 +150,9 @@
         self.matchfn = lambda fn: matcher.matchfn(self._path + "/" + fn)
         self._fmap = set(self._files)
 
+    def bad(self, f, msg):
+        self._matcher.bad(self._path + "/" + f, msg)
+
 def patkind(pat):
     return _patsplit(pat, None)[0]