formatter: convert status command
authorMatt Mackall <mpm@selenic.com>
Mon, 20 Feb 2012 16:42:51 -0600
changeset 16136 68007f0557de
parent 16135 ae5f92e154d3
child 16137 8fd18eb8aab7
formatter: convert status command
mercurial/commands.py
--- a/mercurial/commands.py	Mon Feb 20 16:42:48 2012 -0600
+++ b/mercurial/commands.py	Mon Feb 20 16:42:51 2012 -0600
@@ -5277,18 +5277,22 @@
     if (opts.get('all') or opts.get('copies')) and not opts.get('no_status'):
         copy = copies.pathcopies(repo[node1], repo[node2])
 
+    fm = ui.formatter('status', opts)
+    format = '%s %s' + end
+    if opts.get('no_status'):
+        format = '%.0s%s' + end
+
     for state, char, files in changestates:
         if state in show:
-            format = "%s %%s%s" % (char, end)
-            if opts.get('no_status'):
-                format = "%%s%s" % end
-
+            label = 'status.' + state
             for f in files:
-                ui.write(format % repo.pathto(f, cwd),
-                         label='status.' + state)
+                fm.startitem()
+                fm.write("status char", format, char,
+                         repo.pathto(f, cwd), label=label)
                 if f in copy:
-                    ui.write('  %s%s' % (repo.pathto(copy[f], cwd), end),
+                    fm.write("copy", '  %s' + end, repo.pathto(copy[f], cwd),
                              label='status.copied')
+    fm.end()
 
 @command('^summary|sum',
     [('', 'remote', None, _('check for push and pull'))], '[--remote]')