changeset 7419:efe31fbe6cf0

color: don't run status twice for -n Just cut off the status characters.
author Brendan Cully <brendan@kublai.com>
date Tue, 25 Nov 2008 18:32:44 -0800
parents 0e04753de3ec
children b4ac1e2cd38c
files hgext/color.py
diffstat 1 files changed, 7 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/color.py	Tue Nov 25 18:21:00 2008 -0800
+++ b/hgext/color.py	Tue Nov 25 18:32:44 2008 -0800
@@ -94,23 +94,18 @@
 
     delimiter = opts['print0'] and '\0' or '\n'
 
-    # run status and capture it's output
+    nostatus = opts.get('no_status')
+    opts['no_status'] = False
+    # run status and capture its output
     ui.pushbuffer()
     retval = orig(ui, repo, *pats, **opts)
     # filter out empty strings
-    lines = [ line for line in ui.popbuffer().split(delimiter) if line ]
+    lines_with_status = [ line for line in ui.popbuffer().split(delimiter) if line ]
 
-    if opts['no_status']:
-        # if --no-status, run the command again without that option to get
-        # output with status abbreviations
-        opts['no_status'] = False
-        ui.pushbuffer()
-        orig(ui, repo, *pats, **opts)
-        # filter out empty strings
-        lines_with_status = [ line for
-                              line in ui.popbuffer().split(delimiter) if line ]
+    if nostatus:
+        lines = [l[2:] for l in lines_with_status]
     else:
-        lines_with_status = lines
+        lines = lines_with_status
 
     # apply color to output and display it
     for i in xrange(0, len(lines)):