Commits

Oleg Oshmyan committed 244a50c

Colorize the output of hg unshelve -i

Also fix a latent bug in the colorizing of the output of hg shelve.

Comments (0)

Files changed (1)

     # wrap ui.write so diff output can be labeled/colorized
     def wrapwrite(orig, *args, **kw):
         label = kw.pop('label', '')
+        if label: label += ' '
         for chunk, l in patch.difflabel(lambda: args):
             orig(chunk, label=label + l)
     oldwrite = ui.write
         patch_diff = repo.opener(shelfpath).read()
         fp = cStringIO.StringIO(patch_diff)
         if opts['inspect']:
-            ui.status(fp.getvalue())
+            # wrap ui.write so diff output can be labeled/colorized
+            def wrapwrite(orig, *args, **kw):
+                label = kw.pop('label', '')
+                if label: label += ' '
+                for chunk, l in patch.difflabel(lambda: args):
+                    orig(chunk, label=label + l)
+            oldwrite = ui.write
+            extensions.wrapfunction(ui, 'write', wrapwrite)
+            try:
+                ui.status(fp.getvalue())
+            finally:
+                ui.write = oldwrite
         else:
             files = []
             ac = parsepatch(fp)