7731
|
1 #!/bin/sh
|
|
2
|
|
3 # test merge-tools configuration - mostly exercising filemerge.py
|
|
4
|
|
5 unset HGMERGE # make sure HGMERGE doesn't interfere with the test
|
|
6
|
|
7 hg init
|
|
8
|
|
9 echo "# revision 0"
|
|
10 echo "revision 0" > f
|
|
11 echo "space" >> f
|
|
12 hg commit -Am "revision 0" -d "1000000 0"
|
|
13
|
|
14 echo "# revision 1"
|
|
15 echo "revision 1" > f
|
|
16 echo "space" >> f
|
|
17 hg commit -Am "revision 1" -d "1000000 0"
|
|
18
|
|
19 hg update 0 > /dev/null
|
|
20 echo "# revision 2"
|
|
21 echo "revision 2" > f
|
|
22 echo "space" >> f
|
|
23 hg commit -Am "revision 2" -d "1000000 0"
|
|
24
|
|
25 hg update 0 > /dev/null
|
|
26 echo "# revision 3 - simple to merge"
|
|
27 echo "revision 3" >> f
|
|
28 hg commit -Am "revision 3" -d "1000000 0"
|
|
29
|
|
30
|
|
31 echo "[merge-tools]" > .hg/hgrc
|
|
32 echo
|
|
33
|
|
34 beforemerge() {
|
|
35 cat .hg/hgrc
|
|
36 echo "# hg update -C 1"
|
|
37 hg update -C 1 > /dev/null
|
|
38 }
|
|
39
|
|
40 aftermerge() {
|
|
41 echo "# cat f"
|
|
42 cat f
|
|
43 echo "# hg stat"
|
|
44 hg stat
|
|
45 rm -f f.orig
|
|
46 echo
|
|
47 }
|
|
48
|
|
49 domerge() {
|
|
50 beforemerge
|
|
51 echo "# hg merge $*"
|
|
52 hg merge $*
|
|
53 aftermerge
|
|
54 }
|
|
55
|
|
56 echo
|
|
57 echo Tool selection
|
|
58 echo
|
|
59
|
|
60 echo "# default is internal merge:"
|
|
61 domerge -r 2
|
|
62
|
|
63 echo "# simplest hgrc using false for merge:"
|
|
64 echo "false.whatever=" >> .hg/hgrc
|
|
65 domerge -r 2
|
|
66
|
|
67 echo "# true with higher .priority gets precedence:"
|
|
68 echo "true.priority=1" >> .hg/hgrc
|
|
69 domerge -r 2
|
|
70
|
|
71 echo "# unless lowered on command line:"
|
|
72 domerge -r 2 --config merge-tools.true.priority=-7
|
|
73
|
|
74 echo "# or false set higher on command line:"
|
|
75 domerge -r 2 --config merge-tools.false.priority=117
|
|
76
|
|
77 echo "# or true.executable not found in PATH:"
|
|
78 domerge -r 2 --config merge-tools.true.executable=nonexistingmergetool
|
|
79
|
|
80 echo "# or true.executable with bogus path:"
|
|
81 domerge -r 2 --config merge-tools.true.executable=/bin/nonexistingmergetool
|
|
82
|
|
83 echo "# but true.executable set to cat found in PATH works:"
|
|
84 echo "true.executable=cat" >> .hg/hgrc
|
|
85 domerge -r 2
|
|
86
|
|
87 echo "# and true.executable set to cat with path works:"
|
|
88 domerge -r 2 --config merge-tools.true.executable=/bin/cat
|
|
89
|
|
90
|
|
91 echo
|
|
92 echo Tool selection and merge-patterns
|
|
93 echo
|
|
94
|
|
95 echo "# merge-patterns specifies new tool tac:"
|
|
96 domerge -r 2 --config merge-patterns.f=tac
|
|
97
|
|
98 echo "# merge-patterns specifies executable not found in PATH and gets warning:"
|
|
99 domerge -r 2 --config merge-patterns.f=true --config merge-tools.true.executable=nonexistingmergetool
|
|
100
|
|
101 echo "# merge-patterns specifies executable with bogus path and gets warning:"
|
|
102 domerge -r 2 --config merge-patterns.f=true --config merge-tools.true.executable=/bin/nonexistingmergetool
|
|
103
|
|
104
|
|
105 echo
|
|
106 echo Premerge
|
|
107 echo
|
|
108
|
|
109 echo "# Default is silent simplemerge:"
|
|
110 domerge -r 3
|
|
111
|
|
112 echo "# .premerge=True is same:"
|
|
113 domerge -r 3 --config merge-tools.true.premerge=True
|
|
114
|
|
115 echo "# .premerge=False executes merge-tool:"
|
|
116 domerge -r 3 --config merge-tools.true.premerge=False
|
|
117
|
|
118
|
|
119 echo
|
|
120 echo Tool execution
|
|
121 echo
|
|
122
|
|
123 echo '# set tools.args explicit to include $base $local $other $output:' # default '$local $base $other'
|
|
124 beforemerge
|
|
125 hg merge -r 2 --config merge-tools.true.executable=head --config merge-tools.true.args='$base $local $other $output' \
|
|
126 | sed 's,==> .* <==,==> ... <==,g'
|
|
127 aftermerge
|
|
128
|
|
129 echo '# Merge with "echo mergeresult > $local":'
|
|
130 beforemerge
|
|
131 hg merge -r 2 --config merge-tools.true.executable=echo --config merge-tools.true.args='mergeresult > $local'
|
|
132 aftermerge
|
|
133
|
|
134 echo '# - and $local is the file f:'
|
|
135 beforemerge
|
|
136 hg merge -r 2 --config merge-tools.true.executable=echo --config merge-tools.true.args='mergeresult > f'
|
|
137 aftermerge
|
|
138
|
|
139 echo '# Merge with "echo mergeresult > $output" - the variable is a bit magic:'
|
|
140 beforemerge
|
|
141 hg merge -r 2 --config merge-tools.true.executable=echo --config merge-tools.true.args='mergeresult > $output'
|
|
142 aftermerge
|
|
143
|
|
144
|
|
145 echo
|
|
146 echo Merge post-processing
|
|
147 echo
|
|
148
|
|
149 echo "# cat is a bad merge-tool and doesn't change:"
|
|
150 domerge -r 2 --config merge-tools.true.checkchanged=1
|