##// END OF EJS Templates
Add -D/--nodates options to hg diff/export that removes dates from diff headers...
Stephen Darnell -
r3199:096f1c73 default
parent child Browse files
Show More
@@ -2852,6 +2852,7 b' table = {'
2852 ('p', 'show-function', None,
2852 ('p', 'show-function', None,
2853 _('show which function each change is in')),
2853 _('show which function each change is in')),
2854 ('g', 'git', None, _('use git extended diff format')),
2854 ('g', 'git', None, _('use git extended diff format')),
2855 ('D', 'nodates', None, _("don't include dates in diff headers")),
2855 ('w', 'ignore-all-space', None,
2856 ('w', 'ignore-all-space', None,
2856 _('ignore white space when comparing lines')),
2857 _('ignore white space when comparing lines')),
2857 ('b', 'ignore-space-change', None,
2858 ('b', 'ignore-space-change', None,
@@ -2865,6 +2866,7 b' table = {'
2865 [('o', 'output', '', _('print output to file with formatted name')),
2866 [('o', 'output', '', _('print output to file with formatted name')),
2866 ('a', 'text', None, _('treat all files as text')),
2867 ('a', 'text', None, _('treat all files as text')),
2867 ('g', 'git', None, _('use git extended diff format')),
2868 ('g', 'git', None, _('use git extended diff format')),
2869 ('D', 'nodates', None, _("don't include dates in diff headers")),
2868 ('', 'switch-parent', None, _('diff against the second parent'))],
2870 ('', 'switch-parent', None, _('diff against the second parent'))],
2869 _('hg export [-a] [-o OUTFILESPEC] REV...')),
2871 _('hg export [-a] [-o OUTFILESPEC] REV...')),
2870 "debugforget|forget":
2872 "debugforget|forget":
@@ -24,6 +24,7 b' class diffopts(object):'
24 text treats all files as text
24 text treats all files as text
25 showfunc enables diff -p output
25 showfunc enables diff -p output
26 git enables the git extended patch format
26 git enables the git extended patch format
27 nodates removes dates from diff headers
27 ignorews ignores all whitespace changes in the diff
28 ignorews ignores all whitespace changes in the diff
28 ignorewsamount ignores changes in the amount of whitespace
29 ignorewsamount ignores changes in the amount of whitespace
29 ignoreblanklines ignores changes whose lines are all blank'''
30 ignoreblanklines ignores changes whose lines are all blank'''
@@ -33,6 +34,7 b' class diffopts(object):'
33 'text': False,
34 'text': False,
34 'showfunc': True,
35 'showfunc': True,
35 'git': False,
36 'git': False,
37 'nodates': False,
36 'ignorews': False,
38 'ignorews': False,
37 'ignorewsamount': False,
39 'ignorewsamount': False,
38 'ignoreblanklines': False,
40 'ignoreblanklines': False,
@@ -51,7 +53,7 b' defaultopts = diffopts()'
51
53
52 def unidiff(a, ad, b, bd, fn, r=None, opts=defaultopts):
54 def unidiff(a, ad, b, bd, fn, r=None, opts=defaultopts):
53 def datetag(date):
55 def datetag(date):
54 return opts.git and '\n' or '\t%s\n' % date
56 return (opts.git or opts.nodates) and '\n' or '\t%s\n' % date
55
57
56 if not a and not b: return ""
58 if not a and not b: return ""
57 epoch = util.datestr((0, 0))
59 epoch = util.datestr((0, 0))
@@ -291,6 +291,8 b' def diffopts(ui, opts={}):'
291 text=opts.get('text'),
291 text=opts.get('text'),
292 git=(opts.get('git') or
292 git=(opts.get('git') or
293 ui.configbool('diff', 'git', None)),
293 ui.configbool('diff', 'git', None)),
294 nodates=(opts.get('nodates') or
295 ui.configbool('diff', 'nodates', None)),
294 showfunc=(opts.get('show_function') or
296 showfunc=(opts.get('show_function') or
295 ui.configbool('diff', 'showfunc', None)),
297 ui.configbool('diff', 'showfunc', None)),
296 ignorews=(opts.get('ignore_all_space') or
298 ignorews=(opts.get('ignore_all_space') or
@@ -26,11 +26,9 b' writing tests:'
26
26
27 use commit -m "test" -u test -d "1000000 0"
27 use commit -m "test" -u test -d "1000000 0"
28
28
29 - diff will show the current time
29 - diff and export may show the current time
30
30
31 use hg diff | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
31 use -D/--nodates to strip the dates
32 -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
33 to strip dates
34
32
35 - You can append your own hgrc settings to the file that the environment
33 - You can append your own hgrc settings to the file that the environment
36 variable HGRCPATH points to. This file is cleared before running a test.
34 variable HGRCPATH points to. This file is cleared before running a test.
@@ -3,8 +3,7 b''
3 # GNU diff is the reference for all of these results.
3 # GNU diff is the reference for all of these results.
4
4
5 hgdiff() {
5 hgdiff() {
6 hg diff "$@" | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
6 hg diff --nodates "$@"
7 -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
8 }
7 }
9
8
10 test_added_blank_lines() {
9 test_added_blank_lines() {
@@ -14,14 +14,11 b' echo 1 > alpha/one'
14 echo 2 > beta/two
14 echo 2 > beta/two
15
15
16 echo EVERYTHING
16 echo EVERYTHING
17 hg diff | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
17 hg diff --nodates
18 -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
19
18
20 echo BETA ONLY
19 echo BETA ONLY
21 hg diff beta | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
20 hg diff --nodates beta
22 -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
23
21
24 echo INSIDE BETA
22 echo INSIDE BETA
25 cd beta
23 cd beta
26 hg diff . | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
24 hg diff --nodates .
27 -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
@@ -7,12 +7,9 b' hg ci -m "a" -d "1000000 0"'
7
7
8 echo 123 > b
8 echo 123 > b
9 hg add b
9 hg add b
10 hg diff | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
10 hg diff --nodates
11 -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
12
11
13 hg diff -r tip | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
12 hg diff --nodates -r tip
14 -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
15
13
16 echo foo > a
14 echo foo > a
17 hg diff | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
15 hg diff --nodates
18 -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
@@ -8,26 +8,22 b" hg ci -Amstart -d '0 0'"
8 echo new > new
8 echo new > new
9 hg ci -Amnew -d '0 0'
9 hg ci -Amnew -d '0 0'
10 echo '% new file'
10 echo '% new file'
11 hg diff --git -r 0 | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
11 hg diff --git -r 0
12 -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
13
12
14 hg cp new copy
13 hg cp new copy
15 hg ci -mcopy -d '0 0'
14 hg ci -mcopy -d '0 0'
16 echo '% copy'
15 echo '% copy'
17 hg diff --git -r 1:tip | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
16 hg diff --git -r 1:tip
18 -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
19
17
20 hg mv copy rename
18 hg mv copy rename
21 hg ci -mrename -d '0 0'
19 hg ci -mrename -d '0 0'
22 echo '% rename'
20 echo '% rename'
23 hg diff --git -r 2:tip | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
21 hg diff --git -r 2:tip
24 -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
25
22
26 hg rm rename
23 hg rm rename
27 hg ci -mdelete -d '0 0'
24 hg ci -mdelete -d '0 0'
28 echo '% delete'
25 echo '% delete'
29 hg diff --git -r 3:tip | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
26 hg diff --git -r 3:tip
30 -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
31
27
32 cat > src <<EOF
28 cat > src <<EOF
33 1
29 1
@@ -40,17 +36,14 b" hg ci -Amsrc -d '0 0'"
40 chmod +x src
36 chmod +x src
41 hg ci -munexec -d '0 0'
37 hg ci -munexec -d '0 0'
42 echo '% chmod 644'
38 echo '% chmod 644'
43 hg diff --git -r 5:tip | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
39 hg diff --git -r 5:tip
44 -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
45
40
46 hg mv src dst
41 hg mv src dst
47 chmod -x dst
42 chmod -x dst
48 echo a >> dst
43 echo a >> dst
49 hg ci -mrenamemod -d '0 0'
44 hg ci -mrenamemod -d '0 0'
50 echo '% rename+mod+chmod'
45 echo '% rename+mod+chmod'
51 hg diff --git -r 6:tip | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
46 hg diff --git -r 6:tip
52 -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
53
47
54 echo '% nonexistent in tip+chmod'
48 echo '% nonexistent in tip+chmod'
55 hg diff --git -r 5:6 | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
49 hg diff --git -r 5:6
56 -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
@@ -179,6 +179,7 b' options:'
179 -a --text treat all files as text
179 -a --text treat all files as text
180 -p --show-function show which function each change is in
180 -p --show-function show which function each change is in
181 -g --git use git extended diff format
181 -g --git use git extended diff format
182 -D --nodates don't include dates in diff headers
182 -w --ignore-all-space ignore white space when comparing lines
183 -w --ignore-all-space ignore white space when comparing lines
183 -b --ignore-space-change ignore changes in the amount of white space
184 -b --ignore-space-change ignore changes in the amount of white space
184 -B --ignore-blank-lines ignore changes whose lines are all blank
185 -B --ignore-blank-lines ignore changes whose lines are all blank
@@ -27,8 +27,8 b' hg id'
27 hg update -C 0
27 hg update -C 0
28 echo "changed file1 different" >> file1
28 echo "changed file1 different" >> file1
29 HGMERGE=merge hg update
29 HGMERGE=merge hg update
30 hg diff | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" -e "s/\(<<<<<<<\) .*/\1/" \
30 #hg diff --nodates | sed -e "s/\(<<<<<<<\) .*/\1/" -e "s/\(>>>>>>>\) .*/\1/"
31 -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/" -e "s/\(>>>>>>>\) .*/\1/"
31 hg diff --nodates | sed -e "s/\(<<<<<<<\|>>>>>>>\) .*/\1/"
32 hg status
32 hg status
33 hg id
33 hg id
34 hg revert --no-backup --all
34 hg revert --no-backup --all
@@ -13,8 +13,8 b' hg revert --all'
13 rm foo
13 rm foo
14 hg remove --after
14 hg remove --after
15 hg commit -m 2 -d "1000000 0"
15 hg commit -m 2 -d "1000000 0"
16 hg export 0
16 hg export --nodates 0
17 hg export 1
17 hg export --nodates 1
18 hg log -p -r 0
18 hg log -p -r 0
19 hg log -p -r 1
19 hg log -p -r 1
20
20
@@ -10,8 +10,8 b' removing foo'
10 1
10 1
11
11
12 diff -r 000000000000 -r 8ba83d44753d foo
12 diff -r 000000000000 -r 8ba83d44753d foo
13 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
13 --- /dev/null
14 +++ b/foo Mon Jan 12 13:46:40 1970 +0000
14 +++ b/foo
15 @@ -0,0 +1,1 @@
15 @@ -0,0 +1,1 @@
16 +a
16 +a
17 # HG changeset patch
17 # HG changeset patch
@@ -22,8 +22,8 b' diff -r 000000000000 -r 8ba83d44753d foo'
22 2
22 2
23
23
24 diff -r 8ba83d44753d -r a1fce69c50d9 foo
24 diff -r 8ba83d44753d -r a1fce69c50d9 foo
25 --- a/foo Mon Jan 12 13:46:40 1970 +0000
25 --- a/foo
26 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
26 +++ /dev/null
27 @@ -1,1 +0,0 @@
27 @@ -1,1 +0,0 @@
28 -a
28 -a
29 changeset: 0:8ba83d44753d
29 changeset: 0:8ba83d44753d
@@ -12,8 +12,7 b' hg clone . ../r2'
12 cd ../r2
12 cd ../r2
13 hg up
13 hg up
14 echo abc > a
14 echo abc > a
15 hg diff | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
15 hg diff --nodates
16 -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
17
16
18 cd ../r1
17 cd ../r1
19 echo b > b
18 echo b > b
@@ -34,8 +33,7 b' hg parents'
34 hg --debug up
33 hg --debug up
35 hg parents
34 hg parents
36 hg -v history
35 hg -v history
37 hg diff | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
36 hg diff --nodates
38 -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
39
37
40 # create a second head
38 # create a second head
41 cd ../r1
39 cd ../r1
@@ -53,8 +51,7 b' hg --debug up || echo failed'
53 hg --debug merge || echo failed
51 hg --debug merge || echo failed
54 hg --debug merge -f
52 hg --debug merge -f
55 hg parents
53 hg parents
56 hg diff | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
54 hg diff --nodates
57 -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
58
55
59 # test a local add
56 # test a local add
60 cd ..
57 cd ..
General Comments 0
You need to be logged in to leave comments. Login now