Mercurial > public > mercurial-scm > hg
diff mercurial/commands.py @ 27672:f2da9bb87ae0
debugignore: find out why a file is being ignored (issue4856)
This patch adds a capability to hg debugignore: to explain why a given file is
being ignores by mercurial. We display the filename, line and linenumber of the
rule that lead us to ignore the file.
author | Laurent Charignon <lcharignon@fb.com> |
---|---|
date | Tue, 05 Jan 2016 07:47:08 -0800 |
parents | 067d87feeb11 |
children | 60268a5f731a |
line wrap: on
line diff
--- a/mercurial/commands.py Tue Jan 05 07:47:08 2016 -0800 +++ b/mercurial/commands.py Tue Jan 05 07:47:08 2016 -0800 @@ -2441,7 +2441,8 @@ With no argument display the combined ignore pattern. - Given space separated file names, shows if the given file is ignored. + Given space separated file names, shows if the given file is ignored and + if so, show the ignore rule (file and line number) that matched it. """ ignore = repo.dirstate._ignore if not files: @@ -2454,13 +2455,16 @@ else: for f in files: ignored = None + ignoredata = None if f != '.': if ignore(f): ignored = f + ignoredata = repo.dirstate._ignorefileandline(f) else: for p in util.finddirs(f): if ignore(p): ignored = p + ignoredata = repo.dirstate._ignorefileandline(p) break if ignored: if ignored == f: @@ -2468,6 +2472,9 @@ else: ui.write("%s is ignored because of containing folder %s\n" % (f, ignored)) + ignorefile, lineno, line = ignoredata + ui.write("(ignore rule in %s, line %d: '%s')\n" + % (ignorefile, lineno, line)) else: ui.write("%s is not ignored\n" % f)