--- a/mercurial/commands.py Thu Apr 03 13:47:05 2008 +0200
+++ b/mercurial/commands.py Fri Apr 04 22:18:38 2008 +0200
@@ -3037,7 +3037,7 @@
_('ignore changes in the amount of white space')),
('B', 'ignore-blank-lines', None,
_('ignore changes whose lines are all blank')),
- ('U', 'unified', 3,
+ ('U', 'unified', '',
_('number of lines of context to show'))
] + walkopts,
_('hg diff [OPTION]... [-r REV1 [-r REV2]] [FILE]...')),
--- a/mercurial/mdiff.py Thu Apr 03 13:47:05 2008 +0200
+++ b/mercurial/mdiff.py Fri Apr 04 22:18:38 2008 +0200
@@ -5,6 +5,7 @@
# This software may be used and distributed according to the terms
# of the GNU General Public License, incorporated herein by reference.
+from i18n import _
import bdiff, mpatch, re, struct, util, md5
def splitnewlines(text):
@@ -47,6 +48,12 @@
v = self.defaults[k]
setattr(self, k, v)
+ try:
+ self.context = int(self.context)
+ except ValueError:
+ raise util.Abort(_('diff context lines count must be '
+ 'an integer, not %r') % self.context)
+
defaultopts = diffopts()
def wsclean(opts, text):
--- a/mercurial/patch.py Thu Apr 03 13:47:05 2008 +0200
+++ b/mercurial/patch.py Fri Apr 04 22:18:38 2008 +0200
@@ -1055,9 +1055,9 @@
return err
def diffopts(ui, opts={}, untrusted=False):
- def get(key, name=None):
+ def get(key, name=None, getter=ui.configbool):
return (opts.get(key) or
- ui.configbool('diff', name or key, None, untrusted=untrusted))
+ getter('diff', name or key, None, untrusted=untrusted))
return mdiff.diffopts(
text=opts.get('text'),
git=get('git'),
@@ -1066,7 +1066,7 @@
ignorews=get('ignore_all_space', 'ignorews'),
ignorewsamount=get('ignore_space_change', 'ignorewsamount'),
ignoreblanklines=get('ignore_blank_lines', 'ignoreblanklines'),
- context=get('unified'))
+ context=get('unified', getter=ui.config))
def updatedir(ui, repo, patches):
'''Update dirstate after patch application according to metadata'''
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-diff-unified Fri Apr 04 22:18:38 2008 +0200
@@ -0,0 +1,49 @@
+#!/bin/sh
+
+hg init repo
+cd repo
+cat > a <<EOF
+c
+c
+a
+a
+b
+a
+a
+c
+c
+EOF
+hg ci -Am adda
+cat > a <<EOF
+c
+c
+a
+a
+dd
+a
+a
+c
+c
+EOF
+
+echo '% default context'
+hg diff --nodates
+
+echo '% invalid --unified'
+hg diff --nodates -U foo
+
+echo '% --unified=2'
+hg diff --nodates -U 2
+
+echo '% diff.unified=2'
+hg --config diff.unified=2 diff --nodates
+
+echo '% diff.unified=2 --unified=1'
+hg diff --nodates -U 1
+
+echo '% invalid diff.unified'
+hg --config diff.unified=foo diff --nodates
+
+exit 0
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-diff-unified.out Fri Apr 04 22:18:38 2008 +0200
@@ -0,0 +1,49 @@
+adding a
+% default context
+diff -r cf9f4ba66af2 a
+--- a/a
++++ b/a
+@@ -2,7 +2,7 @@
+ c
+ a
+ a
+-b
++dd
+ a
+ a
+ c
+% invalid --unified
+abort: diff context lines count must be an integer, not 'foo'
+% --unified=2
+diff -r cf9f4ba66af2 a
+--- a/a
++++ b/a
+@@ -3,5 +3,5 @@
+ a
+ a
+-b
++dd
+ a
+ a
+% diff.unified=2
+diff -r cf9f4ba66af2 a
+--- a/a
++++ b/a
+@@ -3,5 +3,5 @@
+ a
+ a
+-b
++dd
+ a
+ a
+% diff.unified=2 --unified=1
+diff -r cf9f4ba66af2 a
+--- a/a
++++ b/a
+@@ -4,3 +4,3 @@
+ a
+-b
++dd
+ a
+% invalid diff.unified
+abort: diff context lines count must be an integer, not 'foo'
--- a/tests/test-help.out Thu Apr 03 13:47:05 2008 +0200
+++ b/tests/test-help.out Fri Apr 04 22:18:38 2008 +0200
@@ -205,7 +205,7 @@
-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
- -U --unified number of lines of context to show (default: 3)
+ -U --unified number of lines of context to show
-I --include include names matching the given patterns
-X --exclude exclude names matching the given patterns