diff -r c01143cef2c7 -r 2b60823c4506 hgkw/keyword.py --- a/hgkw/keyword.py Thu Sep 17 22:39:38 2009 -0700 +++ b/hgkw/keyword.py Mon Oct 19 22:37:14 2009 +0200 @@ -244,12 +244,14 @@ return t2 != text return revlog.revlog.cmp(self, node, text) -def _status(ui, repo, kwt, unknown, *pats, **opts): +def _status(ui, repo, kwt, *pats, **opts): '''Bails out if [keyword] configuration is not active. Returns status of working directory.''' if kwt: - match = cmdutil.match(repo, pats, opts) - return repo.status(match=match, unknown=unknown, clean=True) + unknown = (opts.get('unknown') or opts.get('all') + or opts.get('untracked')) + return repo.status(match=cmdutil.match(repo, pats, opts), clean=True, + unknown=unknown) if ui.configitems('keyword'): raise util.Abort(_('[keyword] patterns cannot match')) raise util.Abort(_('no [keyword] patterns configured')) @@ -259,7 +261,7 @@ if repo.dirstate.parents()[1] != nullid: raise util.Abort(_('outstanding uncommitted merge')) kwt = kwtools['templater'] - status = _status(ui, repo, kwt, False, *pats, **opts) + status = _status(ui, repo, kwt, *pats, **opts) modified, added, removed, deleted = status[:4] if modified or added or removed or deleted: raise util.Abort(_('outstanding uncommitted changes')) @@ -380,30 +382,32 @@ See "hg help keyword" on how to construct patterns both for inclusion and exclusion of files. - Use -u/--untracked to list untracked files as well. - - With -a/--all and -v/--verbose the codes used to show the status + With -A/--all and -v/--verbose the codes used to show the status of files are:: K = keyword expansion candidate - k = keyword expansion candidate (untracked) + k = keyword expansion candidate (not tracked) I = ignored - i = ignored (untracked) + i = ignored (not tracked) ''' kwt = kwtools['templater'] - status = _status(ui, repo, kwt, opts.get('untracked'), *pats, **opts) + 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)] - kwuntracked = [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', kwuntracked),) or ()) + kwunknown = [f for f in unknown if kwt.iskwfile(f, wctx.flags)] + 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 kwuntracked]),) - 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)) @@ -545,9 +549,12 @@ _('hg kwexpand [OPTION]... [FILE]...')), 'kwfiles': (files, - [('a', 'all', None, _('show keyword status flags of all files')), + [('A', 'all', None, _('show keyword status flags of all files')), ('i', 'ignore', None, _('show files excluded from expansion')), - ('u', 'untracked', None, _('additionally show untracked files')), + ('u', 'unknown', None, _('only show unknown (not tracked) files')), + ('a', 'all', None, + _('show keyword status flags of all files (DEPRECATED)')), + ('u', 'untracked', None, _('only show untracked files (DEPRECATED)')), ] + commands.walkopts, _('hg kwfiles [OPTION]... [FILE]...')), 'kwshrink': (shrink, commands.walkopts,