(stable) merge stable
authorChristian Ebert <blacktrash@gmx.net>
Mon, 19 Oct 2009 22:37:14 +0200
branchstable
changeset 655 2b60823c4506
parent 649 c01143cef2c7 (current diff)
parent 654 e188e35ff4ad (diff)
child 656 89e0584cdc5c
(stable) merge
--- 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,
--- a/tests/test-keyword	Thu Sep 17 22:39:38 2009 -0700
+++ b/tests/test-keyword	Mon Oct 19 22:37:14 2009 +0200
@@ -53,6 +53,11 @@
 echo % cat
 cat a b
 
+echo % no kwfiles
+hg kwfiles
+echo % untracked candidates
+hg -v kwfiles --unknown
+
 echo % addremove
 hg addremove
 echo % status
@@ -167,6 +172,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'
--- a/tests/test-keyword.out	Thu Sep 17 22:39:38 2009 -0700
+++ b/tests/test-keyword.out	Mon Oct 19 22:37:14 2009 +0200
@@ -38,6 +38,9 @@
 do not process $Id:
 xxx $
 ignore $Id$
+% no kwfiles
+% untracked candidates
+k a
 % addremove
 adding a
 adding b
@@ -177,6 +180,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