[PATCH 1 of 3 resend] mq: fix opts['unified'] = '0' to take effect when qdiff --stat

Yuya Nishihara yuya at tcha.org
Tue Apr 6 11:08:56 CDT 2010


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1270566654 -32400
# Node ID f60b5d4a2ad929be67fa2f011f28730a7203f25c
# Parent  1b82ab3c7194b263d3e012894fe8a959960351b2
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.

diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -477,8 +477,6 @@ class queue(object):
     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 @@ class queue(object):
             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),
diff --git a/tests/test-mq-qdiff b/tests/test-mq-qdiff
--- a/tests/test-mq-qdiff
+++ b/tests/test-mq-qdiff
@@ -68,3 +68,5 @@ hg qrefresh --git
 echo a >> lines
 hg qdiff
 
+echo % qdiff --stat
+hg qdiff --stat
diff --git a/tests/test-mq-qdiff.out b/tests/test-mq-qdiff.out
--- a/tests/test-mq-qdiff.out
+++ b/tests/test-mq-qdiff.out
@@ -122,3 +122,6 @@ diff --git a/lines b/lines
  8
  9
 +a
+% qdiff --stat
+ lines |  7 +++++--
+ 1 files changed, 5 insertions(+), 2 deletions(-)


More information about the Mercurial-devel mailing list