diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -1351,6 +1351,11 @@ def debugdate(ui, date, range=None, **op m = util.matchdate(range) ui.write("match: %s\n" % m(d[0])) +def debugignore(ui, repo, *values, **opts): + """display the combined ignore pattern""" + ignore = repo.dirstate._ignore + ui.write("%s\n" % ignore.includepat) + def debugindex(ui, repo, file_, **opts): """dump the contents of an index file""" r = None @@ -4347,6 +4352,7 @@ table = { _('[-e] DATE [RANGE]')), "debugdata": (debugdata, [], _('FILE REV')), "debugfsinfo": (debugfsinfo, [], _('[PATH]')), + "debugignore": (debugignore, [], ''), "debugindex": (debugindex, [('f', 'format', 0, _('revlog format'), _('FORMAT'))], _('FILE')), diff --git a/mercurial/match.py b/mercurial/match.py --- a/mercurial/match.py +++ b/mercurial/match.py @@ -39,11 +39,11 @@ class match(object): self._anypats = bool(include or exclude) if include: - im = _buildmatch(_normalize(include, 'glob', root, cwd, auditor), - '(?:/|$)') + pats = _normalize(include, 'glob', root, cwd, auditor) + self.includepat, im = _buildmatch(pats, '(?:/|$)') if exclude: - em = _buildmatch(_normalize(exclude, 'glob', root, cwd, auditor), - '(?:/|$)') + pats = _normalize(exclude, 'glob', root, cwd, auditor) + self.excludepat, em = _buildmatch(pats, '(?:/|$)') if exact: self._files = patterns pm = self.exact @@ -51,7 +51,7 @@ class match(object): pats = _normalize(patterns, default, root, cwd, auditor) self._files = _roots(pats) self._anypats = self._anypats or _anypats(pats) - pm = _buildmatch(pats, '$') + self.patternspat, pm = _buildmatch(pats, '$') if patterns or exact: if include: @@ -246,7 +246,7 @@ def _buildmatch(pats, tail): pat = '(?:%s)' % '|'.join([_regex(k, p, tail) for (k, p) in pats]) if len(pat) > 20000: raise OverflowError() - return re.compile(pat).match + return pat, re.compile(pat).match except OverflowError: # We're using a Python with a tiny regex engine and we # made it explode, so we'll divide the pattern list in two @@ -254,8 +254,9 @@ def _buildmatch(pats, tail): l = len(pats) if l < 2: raise - a, b = _buildmatch(pats[:l//2], tail), _buildmatch(pats[l//2:], tail) - return lambda s: a(s) or b(s) + pata, a = _buildmatch(pats[:l//2], tail), + patb, b = _buildmatch(pats[l//2:], tail) + return pat, lambda s: a(s) or b(s) except re.error: for k, p in pats: try: diff --git a/tests/test-debugcomplete.t b/tests/test-debugcomplete.t --- a/tests/test-debugcomplete.t +++ b/tests/test-debugcomplete.t @@ -75,6 +75,7 @@ Show debug commands if there are no othe debugdata debugdate debugfsinfo + debugignore debugindex debugindexdot debuginstall @@ -214,6 +215,7 @@ Show all commands + options debugdata: debugdate: extended debugfsinfo: + debugignore: debugindex: format debugindexdot: debuginstall: diff --git a/tests/test-hgignore.t b/tests/test-hgignore.t --- a/tests/test-hgignore.t +++ b/tests/test-hgignore.t @@ -120,3 +120,5 @@ Check it does not ignore the current dir $ hg status . A b.o + $ hg debugignore + (?:(?:|.*/)[^/]*(?:/|$))