[PATCH 1 of 3] dirstate: add a way to get the ignore file/line matching an ignored file
Laurent Charignon
lcharignon at fb.com
Tue Jan 5 16:06:33 UTC 2016
# HG changeset patch
# User Laurent Charignon <lcharignon at fb.com>
# Date 1452009124 28800
# Tue Jan 05 07:52:04 2016 -0800
# Node ID 6019e5e7842a8c474f38c5933555f6cc514d8a68
# Parent b8405d739149cdd6d8d9bd5e3dd2ad8487b1f09a
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
@@ -7,6 +7,7 @@
from __future__ import absolute_import
+import collections
import errno
import os
import stat
@@ -777,6 +778,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