diff hgext/mq.py @ 9640:9e76232fbfbe

diff: add --stat for diffstat output diff/qdiff --stat invokes patch.diffstat() on the diff output. When in interactive mode, the output's maximum width is determined by the terminal's width.
author Brodie Rao <me+hg@dackz.net>
date Sun, 25 Oct 2009 02:52:35 +0200
parents f3404b7f37ca
children 7d17794f08a9
line wrap: on
line diff
--- a/hgext/mq.py	Sun Oct 25 02:35:35 2009 +0200
+++ b/hgext/mq.py	Sun Oct 25 02:52:35 2009 +0200
@@ -420,11 +420,19 @@
 
     def printdiff(self, repo, node1, node2=None, files=None,
                   fp=None, changes=None, opts={}):
+        stat = opts.get('stat')
+        if stat:
+            opts['unified'] = '0'
+
         m = cmdutil.match(repo, files, opts)
         chunks = patch.diff(repo, node1, node2, m, changes, self.diffopts())
         write = fp is None and repo.ui.write or fp.write
-        for chunk in chunks:
-            write(chunk)
+        if stat:
+            width = self.ui.interactive() and util.termwidth() or 80
+            write(patch.diffstat(util.iterlines(chunks), width=width))
+        else:
+            for chunk in chunks:
+                write(chunk)
 
     def mergeone(self, repo, mergeq, head, patch, rev):
         # first try just applying the patch