[PATCH 3 of 5 V2] dirstate: add a way to get the ignore file/line matching an ignored file
Laurent Charignon
lcharignon at fb.com
Sat Dec 26 21:41:32 CST 2015
# HG changeset patch
# User Laurent Charignon <lcharignon at fb.com>
# Date 1450902341 28800
# Wed Dec 23 12:25:41 2015 -0800
# Node ID 674616200041c2bfd72cd93ea4dc4083804db6b6
# Parent 6b3004e5fd2b94fbe2397263465ab8d3acf683d1
dirstate: add a way to get the ignore file/line matching an ignored file
This information will be used to improve debugignore (issue4856).
diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -8,7 +8,7 @@
from node import nullid
from i18n import _
import scmutil, util, osutil, parsers, encoding, pathutil, error
-import os, stat, errno
+import os, stat, errno, collections
import match as matchmod
propertycache = util.propertycache
@@ -738,6 +738,26 @@
files.append(os.path.join(self._rootdir, util.expandpath(path)))
return files
+ def _ignorefileandline(self, f):
+ files = collections.deque(self._ignorefiles())
+ visited = set()
+ while files:
+ i = files.popleft()
+ patterns = matchmod.readpatternfile(i, self._ui.warn,
+ sourceinfo=True)
+ for pattern, lineno, line in patterns:
+ kind, p = matchmod._patsplit(pattern, 'glob')
+ if kind == "subinclude":
+ if p not in visited:
+ files.append(p)
+ continue
+ m = matchmod.match(self._root, '', [], [pattern],
+ warn=self._ui.warn)
+ if m(f):
+ return (i, lineno, line)
+ visited.add(i)
+ return (None, -1, "")
+
def _walkexplicit(self, match, subrepos):
'''Get stat data about the files explicitly specified by match.
More information about the Mercurial-devel
mailing list