Add -D/--nodates options to hg diff/export that removes dates from diff headers
and replace uses of sed in the tests with --nodates.
--- a/mercurial/commands.py Fri Sep 29 23:14:22 2006 +0200
+++ b/mercurial/commands.py Tue Sep 26 00:05:24 2006 +0100
@@ -2852,6 +2852,7 @@
('p', 'show-function', None,
_('show which function each change is in')),
('g', 'git', None, _('use git extended diff format')),
+ ('D', '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,
@@ -2865,6 +2866,7 @@
[('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')),
+ ('D', 'nodates', None, _("don't include dates in diff headers")),
('', 'switch-parent', None, _('diff against the second parent'))],
_('hg export [-a] [-o OUTFILESPEC] REV...')),
"debugforget|forget":
--- a/mercurial/mdiff.py Fri Sep 29 23:14:22 2006 +0200
+++ b/mercurial/mdiff.py Tue Sep 26 00:05:24 2006 +0100
@@ -24,6 +24,7 @@
text treats all files as text
showfunc enables diff -p output
git enables the git extended patch format
+ nodates removes dates from diff headers
ignorews ignores all whitespace changes in the diff
ignorewsamount ignores changes in the amount of whitespace
ignoreblanklines ignores changes whose lines are all blank'''
@@ -33,6 +34,7 @@
'text': False,
'showfunc': True,
'git': False,
+ 'nodates': False,
'ignorews': False,
'ignorewsamount': False,
'ignoreblanklines': False,
@@ -51,7 +53,7 @@
def unidiff(a, ad, b, bd, fn, r=None, opts=defaultopts):
def datetag(date):
- return opts.git and '\n' or '\t%s\n' % date
+ return (opts.git or opts.nodates) and '\n' or '\t%s\n' % date
if not a and not b: return ""
epoch = util.datestr((0, 0))
--- a/mercurial/patch.py Fri Sep 29 23:14:22 2006 +0200
+++ b/mercurial/patch.py Tue Sep 26 00:05:24 2006 +0100
@@ -291,6 +291,8 @@
text=opts.get('text'),
git=(opts.get('git') or
ui.configbool('diff', 'git', None)),
+ nodates=(opts.get('nodates') or
+ ui.configbool('diff', 'nodates', None)),
showfunc=(opts.get('show_function') or
ui.configbool('diff', 'showfunc', None)),
ignorews=(opts.get('ignore_all_space') or
--- a/tests/README Fri Sep 29 23:14:22 2006 +0200
+++ b/tests/README Tue Sep 26 00:05:24 2006 +0100
@@ -26,11 +26,9 @@
use commit -m "test" -u test -d "1000000 0"
-- diff will show the current time
+- diff and export may show the current time
- use hg diff | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
- -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
- to strip dates
+ use -D/--nodates to strip the dates
- You can append your own hgrc settings to the file that the environment
variable HGRCPATH points to. This file is cleared before running a test.
--- a/tests/test-diff-ignore-whitespace Fri Sep 29 23:14:22 2006 +0200
+++ b/tests/test-diff-ignore-whitespace Tue Sep 26 00:05:24 2006 +0100
@@ -3,8 +3,7 @@
# GNU diff is the reference for all of these results.
hgdiff() {
- hg diff "$@" | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
- -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
+ hg diff --nodates "$@"
}
test_added_blank_lines() {
--- a/tests/test-diff-subdir Fri Sep 29 23:14:22 2006 +0200
+++ b/tests/test-diff-subdir Tue Sep 26 00:05:24 2006 +0100
@@ -14,14 +14,11 @@
echo 2 > beta/two
echo EVERYTHING
-hg diff | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
- -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
+hg diff --nodates
echo BETA ONLY
-hg diff beta | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
- -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
+hg diff --nodates beta
echo INSIDE BETA
cd beta
-hg diff . | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
- -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
+hg diff --nodates .
--- a/tests/test-diffdir Fri Sep 29 23:14:22 2006 +0200
+++ b/tests/test-diffdir Tue Sep 26 00:05:24 2006 +0100
@@ -7,12 +7,9 @@
echo 123 > b
hg add b
-hg diff | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
- -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
+hg diff --nodates
-hg diff -r tip | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
- -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
+hg diff --nodates -r tip
echo foo > a
-hg diff | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
- -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
+hg diff --nodates
--- a/tests/test-git-export Fri Sep 29 23:14:22 2006 +0200
+++ b/tests/test-git-export Tue Sep 26 00:05:24 2006 +0100
@@ -8,26 +8,22 @@
echo new > new
hg ci -Amnew -d '0 0'
echo '% new file'
-hg diff --git -r 0 | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
- -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
+hg diff --git -r 0
hg cp new copy
hg ci -mcopy -d '0 0'
echo '% copy'
-hg diff --git -r 1:tip | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
- -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
+hg diff --git -r 1:tip
hg mv copy rename
hg ci -mrename -d '0 0'
echo '% rename'
-hg diff --git -r 2:tip | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
- -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
+hg diff --git -r 2:tip
hg rm rename
hg ci -mdelete -d '0 0'
echo '% delete'
-hg diff --git -r 3:tip | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
- -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
+hg diff --git -r 3:tip
cat > src <<EOF
1
@@ -40,17 +36,14 @@
chmod +x src
hg ci -munexec -d '0 0'
echo '% chmod 644'
-hg diff --git -r 5:tip | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
- -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
+hg diff --git -r 5:tip
hg mv src dst
chmod -x dst
echo a >> dst
hg ci -mrenamemod -d '0 0'
echo '% rename+mod+chmod'
-hg diff --git -r 6:tip | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
- -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
+hg diff --git -r 6:tip
echo '% nonexistent in tip+chmod'
-hg diff --git -r 5:6 | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
- -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
+hg diff --git -r 5:6
--- a/tests/test-help.out Fri Sep 29 23:14:22 2006 +0200
+++ b/tests/test-help.out Tue Sep 26 00:05:24 2006 +0100
@@ -179,6 +179,7 @@
-a --text treat all files as text
-p --show-function show which function each change is in
-g --git use git extended diff format
+ -D --nodates don't include dates in diff headers
-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-merge-revert2 Fri Sep 29 23:14:22 2006 +0200
+++ b/tests/test-merge-revert2 Tue Sep 26 00:05:24 2006 +0100
@@ -27,8 +27,8 @@
hg update -C 0
echo "changed file1 different" >> file1
HGMERGE=merge hg update
-hg diff | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" -e "s/\(<<<<<<<\) .*/\1/" \
- -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/" -e "s/\(>>>>>>>\) .*/\1/"
+#hg diff --nodates | sed -e "s/\(<<<<<<<\) .*/\1/" -e "s/\(>>>>>>>\) .*/\1/"
+hg diff --nodates | sed -e "s/\(<<<<<<<\|>>>>>>>\) .*/\1/"
hg status
hg id
hg revert --no-backup --all
--- a/tests/test-remove Fri Sep 29 23:14:22 2006 +0200
+++ b/tests/test-remove Tue Sep 26 00:05:24 2006 +0100
@@ -13,8 +13,8 @@
rm foo
hg remove --after
hg commit -m 2 -d "1000000 0"
-hg export 0
-hg export 1
+hg export --nodates 0
+hg export --nodates 1
hg log -p -r 0
hg log -p -r 1
--- a/tests/test-remove.out Fri Sep 29 23:14:22 2006 +0200
+++ b/tests/test-remove.out Tue Sep 26 00:05:24 2006 +0100
@@ -10,8 +10,8 @@
1
diff -r 000000000000 -r 8ba83d44753d foo
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/foo Mon Jan 12 13:46:40 1970 +0000
+--- /dev/null
++++ b/foo
@@ -0,0 +1,1 @@
+a
# HG changeset patch
@@ -22,8 +22,8 @@
2
diff -r 8ba83d44753d -r a1fce69c50d9 foo
---- a/foo Mon Jan 12 13:46:40 1970 +0000
-+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
+--- a/foo
++++ /dev/null
@@ -1,1 +0,0 @@
-a
changeset: 0:8ba83d44753d
--- a/tests/test-up-local-change Fri Sep 29 23:14:22 2006 +0200
+++ b/tests/test-up-local-change Tue Sep 26 00:05:24 2006 +0100
@@ -12,8 +12,7 @@
cd ../r2
hg up
echo abc > a
-hg diff | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
- -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
+hg diff --nodates
cd ../r1
echo b > b
@@ -34,8 +33,7 @@
hg --debug up
hg parents
hg -v history
-hg diff | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
- -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
+hg diff --nodates
# create a second head
cd ../r1
@@ -53,8 +51,7 @@
hg --debug merge || echo failed
hg --debug merge -f
hg parents
-hg diff | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
- -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
+hg diff --nodates
# test a local add
cd ..