hgext/keyword.py
changeset 9493 fe1ecd15c6bd
parent 9492 3b1864bcc58f
child 9494 bdd8a41ea6f6
equal deleted inserted replaced
9492:3b1864bcc58f 9493:fe1ecd15c6bd
   380     expansion.
   380     expansion.
   381 
   381 
   382     See "hg help keyword" on how to construct patterns both for
   382     See "hg help keyword" on how to construct patterns both for
   383     inclusion and exclusion of files.
   383     inclusion and exclusion of files.
   384 
   384 
   385     Use -u/--unknown to list unknown (not tracked) files as well.
       
   386 
       
   387     With -a/--all and -v/--verbose the codes used to show the status
   385     With -a/--all and -v/--verbose the codes used to show the status
   388     of files are::
   386     of files are::
   389 
   387 
   390       K = keyword expansion candidate
   388       K = keyword expansion candidate
   391       k = keyword expansion candidate (not tracked)
   389       k = keyword expansion candidate (not tracked)
   392       I = ignored
   390       I = ignored
   393       i = ignored (not tracked)
   391       i = ignored (not tracked)
   394     '''
   392     '''
   395     kwt = kwtools['templater']
   393     kwt = kwtools['templater']
   396     status = _status(ui, repo, kwt, *pats, **opts)
   394     status = _status(ui, repo, kwt, *pats, **opts)
       
   395     cwd = pats and repo.getcwd() or ''
   397     modified, added, removed, deleted, unknown, ignored, clean = status
   396     modified, added, removed, deleted, unknown, ignored, clean = status
   398     files = sorted(modified + added + clean)
   397     files = []
       
   398     if not (opts.get('unknown') or opts.get('untracked')) or opts.get('all'):
       
   399         files = sorted(modified + added + clean)
   399     wctx = repo[None]
   400     wctx = repo[None]
   400     kwfiles = [f for f in files if kwt.iskwfile(f, wctx.flags)]
   401     kwfiles = [f for f in files if kwt.iskwfile(f, wctx.flags)]
   401     kwunknown = [f for f in unknown if kwt.iskwfile(f, wctx.flags)]
   402     kwunknown = [f for f in unknown if kwt.iskwfile(f, wctx.flags)]
   402     cwd = pats and repo.getcwd() or ''
   403     if not opts.get('ignore') or opts.get('all'):
   403     kwfstats = (not opts.get('ignore') and
   404         showfiles = kwfiles, kwunknown
   404                 (('K', kwfiles), ('k', kwunknown),) or ())
   405     else:
       
   406         showfiles = [], []
   405     if opts.get('all') or opts.get('ignore'):
   407     if opts.get('all') or opts.get('ignore'):
   406         kwfstats += (('I', [f for f in files if f not in kwfiles]),
   408         showfiles += ([f for f in files if f not in kwfiles],
   407                      ('i', [f for f in unknown if f not in kwunknown]),)
   409                       [f for f in unknown if f not in kwunknown])
   408     for char, filenames in kwfstats:
   410     for char, filenames in zip('KkIi', showfiles):
   409         fmt = (opts.get('all') or ui.verbose) and '%s %%s\n' % char or '%s\n'
   411         fmt = (opts.get('all') or ui.verbose) and '%s %%s\n' % char or '%s\n'
   410         for f in filenames:
   412         for f in filenames:
   411             ui.write(fmt % repo.pathto(f, cwd))
   413             ui.write(fmt % repo.pathto(f, cwd))
   412 
   414 
   413 def shrink(ui, repo, *pats, **opts):
   415 def shrink(ui, repo, *pats, **opts):
   547                  _('hg kwexpand [OPTION]... [FILE]...')),
   549                  _('hg kwexpand [OPTION]... [FILE]...')),
   548     'kwfiles':
   550     'kwfiles':
   549         (files,
   551         (files,
   550          [('a', 'all', None, _('show keyword status flags of all files')),
   552          [('a', 'all', None, _('show keyword status flags of all files')),
   551           ('i', 'ignore', None, _('show files excluded from expansion')),
   553           ('i', 'ignore', None, _('show files excluded from expansion')),
   552           ('u', 'unknown', None,
   554           ('u', 'unknown', None, _('only show unknown (not tracked) files')),
   553            _('additionally show unknown (not tracked) files')),
   555           ('u', 'untracked', None, _('only show untracked files (DEPRECATED)')),
   554           ('u', 'untracked', None,
       
   555            _('additionally show untracked files (DEPRECATED)')),
       
   556          ] + commands.walkopts,
   556          ] + commands.walkopts,
   557          _('hg kwfiles [OPTION]... [FILE]...')),
   557          _('hg kwfiles [OPTION]... [FILE]...')),
   558     'kwshrink': (shrink, commands.walkopts,
   558     'kwshrink': (shrink, commands.walkopts,
   559                  _('hg kwshrink [OPTION]... [FILE]...')),
   559                  _('hg kwshrink [OPTION]... [FILE]...')),
   560 }
   560 }