mercurial/debugcommands.py
changeset 30527 243ecbd4f5c9
parent 30526 9c10905f4b48
child 30528 22683f2f8100
equal deleted inserted replaced
30526:9c10905f4b48 30527:243ecbd4f5c9
   630               'bundle2': 'HG20'}
   630               'bundle2': 'HG20'}
   631     bundletype = btypes.get(bundletype)
   631     bundletype = btypes.get(bundletype)
   632     if bundletype not in bundle2.bundletypes:
   632     if bundletype not in bundle2.bundletypes:
   633         raise error.Abort(_('unknown bundle type specified with --type'))
   633         raise error.Abort(_('unknown bundle type specified with --type'))
   634     bundle2.writebundle(ui, bundle, bundlepath, bundletype)
   634     bundle2.writebundle(ui, bundle, bundlepath, bundletype)
       
   635 
       
   636 @command('debugignore', [], '[FILE]')
       
   637 def debugignore(ui, repo, *files, **opts):
       
   638     """display the combined ignore pattern and information about ignored files
       
   639 
       
   640     With no argument display the combined ignore pattern.
       
   641 
       
   642     Given space separated file names, shows if the given file is ignored and
       
   643     if so, show the ignore rule (file and line number) that matched it.
       
   644     """
       
   645     ignore = repo.dirstate._ignore
       
   646     if not files:
       
   647         # Show all the patterns
       
   648         includepat = getattr(ignore, 'includepat', None)
       
   649         if includepat is not None:
       
   650             ui.write("%s\n" % includepat)
       
   651         else:
       
   652             raise error.Abort(_("no ignore patterns found"))
       
   653     else:
       
   654         for f in files:
       
   655             nf = util.normpath(f)
       
   656             ignored = None
       
   657             ignoredata = None
       
   658             if nf != '.':
       
   659                 if ignore(nf):
       
   660                     ignored = nf
       
   661                     ignoredata = repo.dirstate._ignorefileandline(nf)
       
   662                 else:
       
   663                     for p in util.finddirs(nf):
       
   664                         if ignore(p):
       
   665                             ignored = p
       
   666                             ignoredata = repo.dirstate._ignorefileandline(p)
       
   667                             break
       
   668             if ignored:
       
   669                 if ignored == nf:
       
   670                     ui.write(_("%s is ignored\n") % f)
       
   671                 else:
       
   672                     ui.write(_("%s is ignored because of "
       
   673                                "containing folder %s\n")
       
   674                              % (f, ignored))
       
   675                 ignorefile, lineno, line = ignoredata
       
   676                 ui.write(_("(ignore rule in %s, line %d: '%s')\n")
       
   677                          % (ignorefile, lineno, line))
       
   678             else:
       
   679                 ui.write(_("%s is not ignored\n") % f)