##// END OF EJS Templates
diff: add --change option to display single changeset diff (issue1420)
Stepan Koltsov -
r7628:9c6ae2e0 default
parent child Browse files
Show More
@@ -0,0 +1,61 b''
1 #!/bin/sh -e
2
3 # test of hg diff --change
4
5 set -e
6
7 ec() {
8 echo "invoking $@:"
9 "$@"
10 }
11
12 hg init a
13 cd a
14
15 echo "first" > file.txt
16 hg add file.txt
17 hg commit -m 'first commit' # 0
18
19 echo "second" > file.txt
20 hg commit -m 'second commit' # 1
21
22 echo "third" > file.txt
23 hg commit -m 'third commit' # 2
24
25 ec hg diff --nodates --change 1
26
27 echo
28
29 #rev=$(hg log -r 1 --template '{node|short}')
30 rev=e9b286083166
31 ec hg diff --nodates --change "$rev"
32
33 ##
34 # Testing diff -c when merge
35
36 for i in 1 2 3 4 5 6 7 8 9 10; do
37 echo $i >> file.txt
38 done
39 hg commit -m "lots of text" # 3
40
41 sed -i -e 's,^2$,x,' file.txt
42 hg commit -m "changed 2 to x" # 4
43
44 hg up -r 3 > /dev/null 2>&1 # updated, merged, removed, unresolved
45 sed -i -e 's,^8$,y,' file.txt
46 hg commit -m "change 8 to y" > /dev/null 2>&1 # 5 # created new head
47
48 hg up -C -r 4 > /dev/null 2>&1 # updated, merged, removed, unresolved
49 hg merge -r 5 > /dev/null 2>&1 # updated, merged, removed, unresolved
50 hg commit -m "merging 8 to y" # 6
51
52 echo
53 ec hg diff --nodates --change 6 # must be similar to hg diff --nodates --change 5
54
55 #echo
56 #hg log
57
58 echo
59 echo "EOF"
60
61 # vim: set ts=4 sw=4 et:
@@ -0,0 +1,30 b''
1 invoking hg diff --nodates --change 1:
2 diff -r 4bb65dda5db4 -r e9b286083166 file.txt
3 --- a/file.txt
4 +++ b/file.txt
5 @@ -1,1 +1,1 @@
6 -first
7 +second
8
9 invoking hg diff --nodates --change e9b286083166:
10 diff -r 4bb65dda5db4 -r e9b286083166 file.txt
11 --- a/file.txt
12 +++ b/file.txt
13 @@ -1,1 +1,1 @@
14 -first
15 +second
16
17 invoking hg diff --nodates --change 6:
18 diff -r e8a0797e73a6 -r aa9873050139 file.txt
19 --- a/file.txt
20 +++ b/file.txt
21 @@ -6,6 +6,6 @@
22 5
23 6
24 7
25 -8
26 +y
27 9
28 10
29
30 EOF
@@ -1015,7 +1015,18 b' def diff(ui, repo, *pats, **opts):'
1015 Use the --git option to generate diffs in the git extended diff
1015 Use the --git option to generate diffs in the git extended diff
1016 format. Read the diffs help topic for more information.
1016 format. Read the diffs help topic for more information.
1017 """
1017 """
1018 node1, node2 = cmdutil.revpair(repo, opts.get('rev'))
1018
1019 revs = opts.get('rev')
1020 change = opts.get('change')
1021
1022 if revs and change:
1023 msg = _('cannot specify --rev and --change at the same time')
1024 raise util.Abort(msg)
1025 elif change:
1026 node2 = repo.lookup(change)
1027 node1 = repo[node2].parents()[0].node()
1028 else:
1029 node1, node2 = cmdutil.revpair(repo, revs)
1019
1030
1020 m = cmdutil.match(repo, pats, opts)
1031 m = cmdutil.match(repo, pats, opts)
1021 it = patch.diff(repo, node1, node2, match=m, opts=patch.diffopts(ui, opts))
1032 it = patch.diff(repo, node1, node2, match=m, opts=patch.diffopts(ui, opts))
@@ -3172,7 +3183,8 b' table = {'
3172 "debugwalk": (debugwalk, walkopts, _('[OPTION]... [FILE]...')),
3183 "debugwalk": (debugwalk, walkopts, _('[OPTION]... [FILE]...')),
3173 "^diff":
3184 "^diff":
3174 (diff,
3185 (diff,
3175 [('r', 'rev', [], _('revision'))
3186 [('r', 'rev', [], _('revision')),
3187 ('c', 'change', '', _('change made by revision'))
3176 ] + diffopts + diffopts2 + walkopts,
3188 ] + diffopts + diffopts2 + walkopts,
3177 _('[OPTION]... [-r REV1 [-r REV2]] [FILE]...')),
3189 _('[OPTION]... [-r REV1 [-r REV2]] [FILE]...')),
3178 "^export":
3190 "^export":
@@ -221,6 +221,7 b' diff repository (or selected files)'
221 options:
221 options:
222
222
223 -r --rev revision
223 -r --rev revision
224 -c --change change made by revision
224 -a --text treat all files as text
225 -a --text treat all files as text
225 -g --git use git extended diff format
226 -g --git use git extended diff format
226 --nodates don't include dates in diff headers
227 --nodates don't include dates in diff headers
General Comments 0
You need to be logged in to leave comments. Login now