[PATCH V2] progress: add output-prefix for GUI clients

Jason Harris jason.f.harris at gmail.com
Sat Nov 5 06:12:15 UTC 2011


# HG changeset patch
# User Jason Harris <jason at jasonfharris.com>
# Date 1320467623 -3600
# Node ID 6e27ea968dd0110eb378b5512fe64cac63dd36e7
# Parent  dc9d0189f60e6d216e79bbc162525b1d0324752c
progress: add output-prefix for GUI clients

For GUI clients which use the progress extension, the progress gets
reported on stderr and so to differentiate progress from errors it is
convenient to be able to specify a prefix before any progress reporting.

diff --git a/hgext/progress.py b/hgext/progress.py
--- a/hgext/progress.py
+++ b/hgext/progress.py
@@ -38,6 +38,8 @@
   disable = False # if true, don't show a progress bar
   assume-tty = False # if true, ALWAYS show a progress bar, unless
                      # disable is given
+  output-prefix = <none> # if given then any output shown by progress is
+                         # prefixed by the given prefix
 
 Valid entries for the format field are topic, bar, number, unit,
 estimate, speed, and item. item defaults to the last 20 characters of
@@ -124,7 +126,7 @@
             return
         termwidth = self.width()
         self.printed = True
-        head = ''
+        head = str(self.ui.config('progress', 'output-prefix', default=''))
         needprogress = False
         tail = ''
         for indicator in self.order:
diff --git a/tests/test-progress.t b/tests/test-progress.t
--- a/tests/test-progress.t
+++ b/tests/test-progress.t
@@ -214,3 +214,15 @@
   loop [ <=>                                              ] 2
   loop [  <=>                                             ] 3
                                                               \r (esc)
+
+Test the output-prefix option
+  $ echo "output-prefix=gui:" >> $HGRCPATH
+  $ hg -y loop 8 2>&1 | python $TESTDIR/filtercr.py
+  
+  gui: loop [========>                            ] 2/8 1m07s
+  gui: loop [=============>                         ] 3/8 56s
+  gui: loop [==================>                    ] 4/8 45s
+  gui: loop [=======================>               ] 5/8 34s
+  gui: loop [============================>          ] 6/8 23s
+  gui: loop [=================================>     ] 7/8 12s
+                                                              \r (esc)



More information about the Mercurial-devel mailing list