[PATCH] keyword: use ui.formatter for kwfiles output

Christian Ebert blacktrash at gmx.net
Fri Jun 22 09:49:56 CDT 2012


# HG changeset patch
# User Christian Ebert <blacktrash at gmx.net>
# Date 1340376561 -3600
# Node ID 2beb0d2091a45d5c1e5ebff1a7db5bf2e82fa70f
# Parent  ec5ef276077f9141f2ee4205ebcec9b48c6a0da0
keyword: use ui.formatter for kwfiles output

diff --git a/hgext/keyword.py b/hgext/keyword.py
--- a/hgext/keyword.py
+++ b/hgext/keyword.py
@@ -505,11 +505,18 @@
         showfiles += ([f for f in files if f not in kwfiles],
                       [f for f in unknown if f not in kwunknown])
     kwlabels = 'enabled deleted enabledunknown ignored ignoredunknown'.split()
-    kwstates = zip('K!kIi', showfiles, kwlabels)
-    for char, filenames, kwstate in kwstates:
-        fmt = (opts.get('all') or ui.verbose) and '%s %%s\n' % char or '%s\n'
+    kwstates = zip(kwlabels, 'K!kIi', showfiles)
+    fm = ui.formatter('kwfiles', opts)
+    fmt = '%.0s%s\n'
+    if opts.get('all') or ui.verbose:
+        fmt = '%s %s\n'
+    for kwstate, char, filenames in kwstates:
+        label = 'kwfiles.' + kwstate
         for f in filenames:
-            ui.write(fmt % repo.pathto(f, cwd), label='kwfiles.' + kwstate)
+            fm.startitem()
+            fm.write('kwstatus path', fmt, char,
+                     repo.pathto(f, cwd), label=label)
+    fm.end()
 
 @command('kwshrink', commands.walkopts, _('hg kwshrink [OPTION]... [FILE]...'))
 def shrink(ui, repo, *pats, **opts):


More information about the Mercurial-devel mailing list