changeset 11049:a84f14228b1d

mq: fix opts['unified'] = '0' to take effect when qdiff --stat `opts['unified'] = '0'` tries to reduce the number of lines to be processed by patch.diffstat, but here it does not affect diffopts, thus it does not make sense. Instead, we can change `diffopts.context` directly. Added test case for qdiff --stat.
author Yuya Nishihara <yuya@tcha.org>
date Wed, 07 Apr 2010 00:10:54 +0900
parents 9e643a0c3278
children 5d35f7d93514
files hgext/mq.py tests/test-mq-qdiff tests/test-mq-qdiff.out
diffstat 3 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/mq.py	Mon Apr 26 15:32:23 2010 +0200
+++ b/hgext/mq.py	Wed Apr 07 00:10:54 2010 +0900
@@ -477,8 +477,6 @@
     def printdiff(self, repo, diffopts, 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)
         if fp is None:
@@ -487,6 +485,7 @@
             def write(s, **kw):
                 fp.write(s)
         if stat:
+            diffopts.context = 0
             width = self.ui.interactive() and util.termwidth() or 80
             chunks = patch.diff(repo, node1, node2, m, changes, diffopts)
             for chunk, label in patch.diffstatui(util.iterlines(chunks),
--- a/tests/test-mq-qdiff	Mon Apr 26 15:32:23 2010 +0200
+++ b/tests/test-mq-qdiff	Wed Apr 07 00:10:54 2010 +0900
@@ -68,3 +68,5 @@
 echo a >> lines
 hg qdiff
 
+echo % qdiff --stat
+hg qdiff --stat
--- a/tests/test-mq-qdiff.out	Mon Apr 26 15:32:23 2010 +0200
+++ b/tests/test-mq-qdiff.out	Wed Apr 07 00:10:54 2010 +0900
@@ -122,3 +122,6 @@
  8
  9
 +a
+% qdiff --stat
+ lines |  7 +++++--
+ 1 files changed, 5 insertions(+), 2 deletions(-)