[PATCH 3 of 4] keyword: make kwfiles -u show untracked files only (like status)
Christian Ebert
blacktrash at gmx.net
Sun Sep 27 17:21:41 CDT 2009
# HG changeset patch
# User Christian Ebert <blacktrash at gmx.net>
# Date 1254071715 -7200
# Node ID 0f2b3f52ef58a141e930de003c418abf97efed5c
# Parent 7cd8213e6f62044304dd4e820bdbf898066a43ca
keyword: make kwfiles -u show untracked files only (like status)
Remove extra documentation of -u/--unknown, as this is covered in
the option help already.
Like commands.status the code now zips the status flags.
Add more kwfiles tests.
diff --git a/hgext/keyword.py b/hgext/keyword.py
--- a/hgext/keyword.py
+++ b/hgext/keyword.py
@@ -380,8 +380,6 @@
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::
@@ -392,18 +390,22 @@
'''
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('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))
@@ -547,8 +549,7 @@
(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', 'unknown', None, _('only show unknown (not tracked) files')),
] + 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 % 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 @@
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 @@
do not process $Id:
xxx $
ignore $Id$
+% no kwfiles
+% untracked candidates
+k a
% addremove
adding a
adding b
@@ -181,6 +184,14 @@
% 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
More information about the Mercurial-devel
mailing list