changeset 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 877236cdd437
files mercurial/match.py
diffstat 1 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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]