Mercurial > public > mercurial-scm > hg-stable
diff mercurial/commands.py @ 27671:067d87feeb11
debugignore: find out if a file is being ignored
Before this patch debugignore was just displaying the list of ignore patterns.
This patch makes it support a list of filename as argument and tells the user
if those given files are ignored or not.
author | Laurent Charignon <lcharignon@fb.com> |
---|---|
date | Tue, 05 Jan 2016 07:47:08 -0800 |
parents | b1824a1725ed |
children | f2da9bb87ae0 |
line wrap: on
line diff
--- a/mercurial/commands.py Tue Jan 05 07:52:04 2016 -0800 +++ b/mercurial/commands.py Tue Jan 05 07:47:08 2016 -0800 @@ -2435,15 +2435,41 @@ raise error.Abort(_('unknown bundle type specified with --type')) changegroup.writebundle(ui, bundle, bundlepath, bundletype) -@command('debugignore', [], '') -def debugignore(ui, repo, *values, **opts): - """display the combined ignore pattern""" +@command('debugignore', [], '[FILE]') +def debugignore(ui, repo, *files, **opts): + """display the combined ignore pattern and information about ignored files + + With no argument display the combined ignore pattern. + + Given space separated file names, shows if the given file is ignored. + """ ignore = repo.dirstate._ignore - includepat = getattr(ignore, 'includepat', None) - if includepat is not None: - ui.write("%s\n" % includepat) + if not files: + # Show all the patterns + includepat = getattr(ignore, 'includepat', None) + if includepat is not None: + ui.write("%s\n" % includepat) + else: + raise error.Abort(_("no ignore patterns found")) else: - raise error.Abort(_("no ignore patterns found")) + for f in files: + ignored = None + if f != '.': + if ignore(f): + ignored = f + else: + for p in util.finddirs(f): + if ignore(p): + ignored = p + break + if ignored: + if ignored == f: + ui.write("%s is ignored\n" % f) + else: + ui.write("%s is ignored because of containing folder %s\n" + % (f, ignored)) + else: + ui.write("%s is not ignored\n" % f) @command('debugindex', debugrevlogopts + [('f', 'format', 0, _('revlog format'), _('FORMAT'))],