changeset 10823:581d5e3095ef

qdiff: make use of output labeling
author Brodie Rao <brodie@bitheap.org>
date Fri, 02 Apr 2010 15:22:11 -0500
parents 4c63f8e787b8
children 18def0d5692d
files hgext/mq.py
diffstat 1 files changed, 13 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/mq.py	Fri Apr 02 15:22:12 2010 -0500
+++ b/hgext/mq.py	Fri Apr 02 15:22:11 2010 -0500
@@ -481,15 +481,22 @@
             opts['unified'] = '0'
 
         m = cmdutil.match(repo, files, opts)
-        chunks = patch.diff(repo, node1, node2, m, changes, diffopts)
-        write = fp is None and repo.ui.write or fp.write
+        if fp is None:
+            write = repo.ui.write
+        else:
+            def write(s, **kw):
+                fp.write(s)
         if stat:
             width = self.ui.interactive() and util.termwidth() or 80
-            write(patch.diffstat(util.iterlines(chunks), width=width,
-                                 git=diffopts.git))
+            chunks = patch.diff(repo, node1, node2, m, changes, diffopts)
+            for chunk, label in patch.diffstatui(util.iterlines(chunks),
+                                                 width=width,
+                                                 git=diffopts.git):
+                write(chunk, label=label)
         else:
-            for chunk in chunks:
-                write(chunk)
+            for chunk, label in patch.diffui(repo, node1, node2, m, changes,
+                                              diffopts):
+                write(chunk, label=label)
 
     def mergeone(self, repo, mergeq, head, patch, rev, diffopts):
         # first try just applying the patch