diff --git a/hgext/keyword.py b/hgext/keyword.py --- a/hgext/keyword.py +++ b/hgext/keyword.py @@ -382,8 +382,6 @@ def files(ui, repo, *pats, **opts): See "hg help keyword" on how to construct patterns both for inclusion and exclusion of files. - Use -u/--unknown to list unknown (not tracked) files as well. - With -a/--all and -v/--verbose the codes used to show the status of files are:: @@ -394,18 +392,22 @@ def files(ui, repo, *pats, **opts): ''' kwt = kwtools['templater'] status = _status(ui, repo, kwt, *pats, **opts) + cwd = pats and repo.getcwd() or '' modified, added, removed, deleted, unknown, ignored, clean = status - files = sorted(modified + added + clean) + files = [] + if not (opts.get('unknown') or opts.get('untracked')) or opts.get('all'): + files = sorted(modified + added + clean) wctx = repo[None] kwfiles = [f for f in files if kwt.iskwfile(f, wctx.flags)] kwunknown = [f for f in unknown if kwt.iskwfile(f, wctx.flags)] - cwd = pats and repo.getcwd() or '' - kwfstats = (not opts.get('ignore') and - (('K', kwfiles), ('k', kwunknown),) or ()) + if not opts.get('ignore') or opts.get('all'): + showfiles = kwfiles, kwunknown + else: + showfiles = [], [] if opts.get('all') or opts.get('ignore'): - kwfstats += (('I', [f for f in files if f not in kwfiles]), - ('i', [f for f in unknown if f not in kwunknown]),) - for char, filenames in kwfstats: + showfiles += ([f for f in files if f not in kwfiles], + [f for f in unknown if f not in kwunknown]) + for char, filenames in zip('KkIi', showfiles): fmt = (opts.get('all') or ui.verbose) and '%s %%s\n' % char or '%s\n' for f in filenames: ui.write(fmt % repo.pathto(f, cwd)) @@ -549,10 +551,8 @@ cmdtable = { (files, [('a', 'all', None, _('show keyword status flags of all files')), ('i', 'ignore', None, _('show files excluded from expansion')), - ('u', 'unknown', None, - _('additionally show unknown (not tracked) files')), - ('u', 'untracked', None, - _('additionally show untracked files (DEPRECATED)')), + ('u', 'unknown', None, _('only show unknown (not tracked) files')), + ('u', 'untracked', None, _('only show untracked files (DEPRECATED)')), ] + commands.walkopts, _('hg kwfiles [OPTION]... [FILE]...')), 'kwshrink': (shrink, commands.walkopts, diff --git a/tests/test-keyword b/tests/test-keyword --- a/tests/test-keyword +++ b/tests/test-keyword @@ -48,6 +48,11 @@ echo 'ignore $Id$' > b echo % cat cat a b +echo % no kwfiles +hg kwfiles +echo % untracked candidates +hg -v kwfiles --unknown + echo % addremove hg addremove echo % status @@ -162,6 +167,10 @@ hg status echo % kwfiles hg kwfiles +echo % ignored files +hg -v kwfiles --ignore +echo % all files +hg kwfiles --all echo % diff --rev hg diff --rev 1 | grep -v 'b/c' diff --git a/tests/test-keyword.out b/tests/test-keyword.out --- a/tests/test-keyword.out +++ b/tests/test-keyword.out @@ -42,6 +42,9 @@ expand $Id$ do not process $Id: xxx $ ignore $Id$ +% no kwfiles +% untracked candidates +k a % addremove adding a adding b @@ -181,6 +184,14 @@ xxx $ % kwfiles a c +% ignored files +I b +I sym +% all files +K a +K c +I b +I sym % diff --rev diff -r ef63ca68695b c --- /dev/null Thu Jan 01 00:00:00 1970 +0000