--- a/hgext/mq.py Thu Jun 12 11:01:36 2008 +0200
+++ b/hgext/mq.py Thu Jun 12 07:38:15 2008 -0500
@@ -967,10 +967,7 @@
self.ui.write("No patches applied\n")
return
qp = self.qparents(repo, top)
- if opts.get('git'):
- self.diffopts().git = True
- if opts.get('unified') is not None:
- self.diffopts().context = opts['unified']
+ self._diffopts = patch.diffopts(self.ui, opts)
self.printdiff(repo, qp, files=pats, opts=opts)
def refresh(self, repo, pats=None, **opts):
@@ -2355,10 +2352,8 @@
_('hg qcommit [OPTION]... [FILE]...')),
"^qdiff":
(diff,
- [('g', 'git', None, _('use git extended diff format')),
- ('U', 'unified', 3, _('number of lines of context to show')),
- ] + commands.walkopts,
- _('hg qdiff [-I] [-X] [-U NUM] [-g] [FILE]...')),
+ commands.diffopts + commands.diffopts2 + commands.walkopts,
+ _('hg qdiff [OPTION]... [FILE]...')),
"qdelete|qremove|qrm":
(delete,
[('k', 'keep', None, _('keep patch file')),
--- a/mercurial/commands.py Thu Jun 12 11:01:36 2008 +0200
+++ b/mercurial/commands.py Thu Jun 12 07:38:15 2008 -0500
@@ -2932,6 +2932,23 @@
('M', 'no-merges', None, _('do not show merges')),
] + templateopts
+diffopts = [
+ ('a', 'text', None, _('treat all files as text')),
+ ('g', 'git', None, _('use git extended diff format')),
+ ('', 'nodates', None, _("don't include dates in diff headers"))
+]
+
+diffopts2 = [
+ ('p', 'show-function', None, _('show which function each change is in')),
+ ('w', 'ignore-all-space', None,
+ _('ignore white space when comparing lines')),
+ ('b', 'ignore-space-change', None,
+ _('ignore changes in the amount of white space')),
+ ('B', 'ignore-blank-lines', None,
+ _('ignore changes whose lines are all blank')),
+ ('U', 'unified', '', _('number of lines of context to show'))
+]
+
table = {
"^add": (add, walkopts + dryrunopts, _('hg add [OPTION]... [FILE]...')),
"addremove":
@@ -3071,29 +3088,14 @@
"debugwalk": (debugwalk, walkopts, _('hg debugwalk [OPTION]... [FILE]...')),
"^diff":
(diff,
- [('r', 'rev', [], _('revision')),
- ('a', 'text', None, _('treat all files as text')),
- ('p', 'show-function', None,
- _('show which function each change is in')),
- ('g', 'git', None, _('use git extended diff format')),
- ('', 'nodates', None, _("don't include dates in diff headers")),
- ('w', 'ignore-all-space', None,
- _('ignore white space when comparing lines')),
- ('b', 'ignore-space-change', None,
- _('ignore changes in the amount of white space')),
- ('B', 'ignore-blank-lines', None,
- _('ignore changes whose lines are all blank')),
- ('U', 'unified', '',
- _('number of lines of context to show'))
- ] + walkopts,
+ [('r', 'rev', [], _('revision'))
+ ] + diffopts + diffopts2 + walkopts,
_('hg diff [OPTION]... [-r REV1 [-r REV2]] [FILE]...')),
"^export":
(export,
[('o', 'output', '', _('print output to file with formatted name')),
- ('a', 'text', None, _('treat all files as text')),
- ('g', 'git', None, _('use git extended diff format')),
- ('', 'nodates', None, _("don't include dates in diff headers")),
- ('', 'switch-parent', None, _('diff against the second parent'))],
+ ('', 'switch-parent', None, _('diff against the second parent'))
+ ] + diffopts,
_('hg export [OPTION]... [-o OUTFILESPEC] REV...')),
"grep":
(grep,
--- a/tests/test-help.out Thu Jun 12 11:01:36 2008 +0200
+++ b/tests/test-help.out Thu Jun 12 07:38:15 2008 -0500
@@ -201,9 +201,9 @@
-r --rev revision
-a --text treat all files as text
- -p --show-function show which function each change is in
-g --git use git extended diff format
--nodates don't include dates in diff headers
+ -p --show-function show which function each change is in
-w --ignore-all-space ignore white space when comparing lines
-b --ignore-space-change ignore changes in the amount of white space
-B --ignore-blank-lines ignore changes whose lines are all blank
--- a/tests/test-mq-qdiff Thu Jun 12 11:01:36 2008 +0200
+++ b/tests/test-mq-qdiff Thu Jun 12 07:38:15 2008 -0500
@@ -25,3 +25,35 @@
echo % qdiff dirname
hg qdiff . | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
-e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
+
+echo % qdiff filename
+hg qdiff --nodates base
+
+echo % revert
+hg revert -a
+
+echo % qpop
+hg qpop
+
+echo % qdelete mqbase
+hg qdelete mqbase
+
+echo % commit 2
+printf '1\n2\n3\n4\nhello world\ngoodbye world\n7\n8\n9\n' > lines
+hg ci -Amlines -d '2 0'
+
+echo % qnew 2
+hg qnew -mmqbase2 mqbase2
+printf '\n\n1\n2\n3\n4\nhello world\n goodbye world\n7\n8\n9\n' > lines
+
+echo % qdiff -U 1
+hg qdiff --nodates -U 1
+
+echo % qdiff -b
+hg qdiff --nodates -b
+
+echo % qdiff -U 1 -B
+hg qdiff --nodates -U 1 -B
+
+echo qdiff -w
+hg qdiff --nodates -w
--- a/tests/test-mq-qdiff.out Thu Jun 12 11:01:36 2008 +0200
+++ b/tests/test-mq-qdiff.out Thu Jun 12 07:38:15 2008 -0500
@@ -17,3 +17,71 @@
@@ -1,1 +1,1 @@
-base
+patched
+% qdiff filename
+diff -r 67e992f2c4f3 base
+--- a/base
++++ b/base
+@@ -1,1 +1,1 @@
+-base
++patched
+% revert
+% qpop
+Patch queue now empty
+% qdelete mqbase
+% commit 2
+adding lines
+% qnew 2
+% qdiff -U 1
+diff -r 35fb829491c1 lines
+--- a/lines
++++ b/lines
+@@ -1,1 +1,3 @@
++
++
+ 1
+@@ -4,4 +6,4 @@
+ 4
+-hello world
+-goodbye world
++hello world
++ goodbye world
+ 7
+% qdiff -b
+diff -r 35fb829491c1 lines
+--- a/lines
++++ b/lines
+@@ -1,9 +1,11 @@
++
++
+ 1
+ 2
+ 3
+ 4
+-hello world
+-goodbye world
++hello world
++ goodbye world
+ 7
+ 8
+ 9
+% qdiff -U 1 -B
+diff -r 35fb829491c1 lines
+--- a/lines
++++ b/lines
+@@ -4,4 +6,4 @@
+ 4
+-hello world
+-goodbye world
++hello world
++ goodbye world
+ 7
+qdiff -w
+diff -r 35fb829491c1 lines
+--- a/lines
++++ b/lines
+@@ -1,3 +1,5 @@
++
++
+ 1
+ 2
+ 3