qdiff: make use of output labeling
authorBrodie Rao <brodie@bitheap.org>
Fri, 02 Apr 2010 15:22:11 -0500
changeset 10823 581d5e3095ef
parent 10822 4c63f8e787b8
child 10824 18def0d5692d
qdiff: make use of output labeling
hgext/mq.py
--- 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