[PATCH 08 of 13] qdiff: make use of output labeling

Brodie Rao dackze at gmail.com
Wed Mar 31 10:00:44 CDT 2010


# HG changeset patch
# User Brodie Rao <brodie at bitheap.org>
# Date 1270046420 18000
# Node ID de1ae3033369143222724bd8354d2ecaf63f8a34
# Parent  a3ff52fa5caddff3a4cfcaf5c7dda6575fe66060
qdiff: make use of output labeling

diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -481,15 +481,22 @@ class queue(object):
             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


More information about the Mercurial-devel mailing list