kwfiles print code similar to commands.status
authorChristian Ebert <blacktrash@gmx.net>
Wed, 14 Nov 2007 13:32:33 +0100
changeset 298 c8afb99bb70f
parent 297 9e29992343a1
child 300 583efc0983f1
kwfiles print code similar to commands.status
hgkw/keyword.py
--- a/hgkw/keyword.py	Tue Nov 13 02:06:38 2007 +0100
+++ b/hgkw/keyword.py	Wed Nov 14 13:32:33 2007 +0100
@@ -368,15 +368,19 @@
     cwd = pats and repo.getcwd() or ''
     allf = opts['all']
     ignore = opts['ignore']
-    flag = (allf or ui.verbose) and 1 or 0
-    if not ignore:
-        format = ('%s\n', 'K %s\n')[flag]
-        for k in kwfiles:
-            ui.write(format % repo.pathto(k, cwd))
+    if ignore:
+        kwfstats = ()
+    else:
+        kwfstats = (('K', kwfiles),)
     if allf or ignore:
-        format = ('%s\n', 'I %s\n')[flag]
-        for i in [f for f in files if f not in kwfiles]:
-            ui.write(format % repo.pathto(i, cwd))
+        kwfstats += (('I', [f for f in files if f not in kwfiles]),)
+    for char, filenames in kwfstats:
+        if allf or ui.verbose:
+            format = '%s %%s\n' % char
+        else:
+            format = '%s\n'
+        for f in filenames:
+            ui.write(format % repo.pathto(f, cwd))
 
 def shrink(ui, repo, *pats, **opts):
     '''revert expanded keywords in working directory