[PATCH 3 of 5] ignore: trace ignore files behaviour with debugignore()

Patrick Mezard pmezard at gmail.com
Sat Sep 15 14:29:51 CDT 2007


# HG changeset patch
# User Patrick Mezard <pmezard at gmail.com>
# Date 1189882289 -7200
# Node ID ce98ef6f3898983f74bb0c879ce82982812eaee0
# Parent  ac83580a203978458fb36336816de772ef2c2d0a
ignore: trace ignore files behaviour with debugignore().

diff --git a/mercurial/ignore.py b/mercurial/ignore.py
--- a/mercurial/ignore.py
+++ b/mercurial/ignore.py
@@ -91,3 +91,24 @@ def ignore(root, files, warn):
                 util.matcher(root, inc=patlist, src=f))
 
     return ignorefunc
+
+def debugignore(root, files, warn):
+    '''Like ignore() but the returned function returns a tuple
+    (hgignorepath, linenumber, line) instead of True.
+    '''
+    pats = _parsefiles(files, warn)
+
+    matchers = []
+    for f, patlist in pats.items():
+        for linenum, line in patlist:
+            files, matcher, anypats = util.matcher(root, inc=[line], src=f)
+            matchers.append((matcher, (f, linenum, line)))
+
+    def ignorefunc(filename):
+        for matcher, location in matchers:
+            if matcher(filename):
+                return location
+        return False
+    
+    return ignorefunc
+


More information about the Mercurial-devel mailing list