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" |
|
13 |
|
14 echo "# revision 1" |
|
15 echo "revision 1" > f |
|
16 echo "space" >> f |
|
17 hg commit -Am "revision 1" |
|
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" |
|
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" |
|
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 beforemerge |
|
62 echo "# hg merge -r 2" |
|
63 # override $PATH to ensure hgmerge not visible; use $PYTHON in case we're |
|
64 # running from a devel copy, not a temp installation |
|
65 PATH="$BINDIR" $PYTHON "$BINDIR"/hg merge -r 2 |
|
66 aftermerge |
|
67 |
|
68 echo "# simplest hgrc using false for merge:" |
|
69 echo "false.whatever=" >> .hg/hgrc |
|
70 domerge -r 2 |
|
71 |
|
72 echo "# true with higher .priority gets precedence:" |
|
73 echo "true.priority=1" >> .hg/hgrc |
|
74 domerge -r 2 |
|
75 |
|
76 echo "# unless lowered on command line:" |
|
77 domerge -r 2 --config merge-tools.true.priority=-7 |
|
78 |
|
79 echo "# or false set higher on command line:" |
|
80 domerge -r 2 --config merge-tools.false.priority=117 |
|
81 |
|
82 echo "# or true.executable not found in PATH:" |
|
83 domerge -r 2 --config merge-tools.true.executable=nonexistingmergetool |
|
84 |
|
85 echo "# or true.executable with bogus path:" |
|
86 domerge -r 2 --config merge-tools.true.executable=/nonexisting/mergetool |
|
87 |
|
88 echo "# but true.executable set to cat found in PATH works:" |
|
89 echo "true.executable=cat" >> .hg/hgrc |
|
90 domerge -r 2 |
|
91 |
|
92 echo "# and true.executable set to cat with path works:" |
|
93 domerge -r 2 --config merge-tools.true.executable=cat |
|
94 |
|
95 echo |
|
96 echo Tool selection and merge-patterns |
|
97 echo |
|
98 |
|
99 echo "# merge-patterns specifies new tool false:" |
|
100 domerge -r 2 --config merge-patterns.f=false |
|
101 |
|
102 echo "# merge-patterns specifies executable not found in PATH and gets warning:" |
|
103 domerge -r 2 --config merge-patterns.f=true --config merge-tools.true.executable=nonexistingmergetool |
|
104 |
|
105 echo "# merge-patterns specifies executable with bogus path and gets warning:" |
|
106 domerge -r 2 --config merge-patterns.f=true --config merge-tools.true.executable=/nonexisting/mergetool |
|
107 |
|
108 echo |
|
109 echo ui.merge overrules priority |
|
110 echo |
|
111 |
|
112 echo "# ui.merge specifies false:" |
|
113 domerge -r 2 --config ui.merge=false |
|
114 |
|
115 echo "# ui.merge specifies internal:fail:" |
|
116 domerge -r 2 --config ui.merge=internal:fail |
|
117 |
|
118 echo "# ui.merge specifies internal:local:" |
|
119 domerge -r 2 --config ui.merge=internal:local |
|
120 |
|
121 echo "# ui.merge specifies internal:other:" |
|
122 domerge -r 2 --config ui.merge=internal:other |
|
123 |
|
124 echo "# ui.merge specifies internal:prompt:" |
|
125 domerge -r 2 --config ui.merge=internal:prompt |
|
126 |
|
127 echo "# ui.merge specifies internal:dump:" |
|
128 domerge -r 2 --config ui.merge=internal:dump |
|
129 echo f.base: |
|
130 cat f.base |
|
131 echo f.local: |
|
132 cat f.local |
|
133 echo f.other: |
|
134 cat f.other |
|
135 rm f.base f.local f.other |
|
136 echo |
|
137 |
|
138 echo "# ui.merge specifies internal:other but is overruled by pattern for false:" |
|
139 domerge -r 2 --config ui.merge=internal:other --config merge-patterns.f=false |
|
140 |
|
141 echo |
|
142 echo Premerge |
|
143 echo |
|
144 |
|
145 echo "# Default is silent simplemerge:" |
|
146 domerge -r 3 |
|
147 |
|
148 echo "# .premerge=True is same:" |
|
149 domerge -r 3 --config merge-tools.true.premerge=True |
|
150 |
|
151 echo "# .premerge=False executes merge-tool:" |
|
152 domerge -r 3 --config merge-tools.true.premerge=False |
|
153 |
|
154 |
|
155 echo |
|
156 echo Tool execution |
|
157 echo |
|
158 |
|
159 echo '# set tools.args explicit to include $base $local $other $output:' # default '$local $base $other' |
|
160 beforemerge |
|
161 hg merge -r 2 --config merge-tools.true.executable=head --config merge-tools.true.args='$base $local $other $output' \ |
|
162 | sed 's,==> .* <==,==> ... <==,g' |
|
163 aftermerge |
|
164 |
|
165 echo '# Merge with "echo mergeresult > $local":' |
|
166 beforemerge |
|
167 hg merge -r 2 --config merge-tools.true.executable=echo --config merge-tools.true.args='mergeresult > $local' |
|
168 aftermerge |
|
169 |
|
170 echo '# - and $local is the file f:' |
|
171 beforemerge |
|
172 hg merge -r 2 --config merge-tools.true.executable=echo --config merge-tools.true.args='mergeresult > f' |
|
173 aftermerge |
|
174 |
|
175 echo '# Merge with "echo mergeresult > $output" - the variable is a bit magic:' |
|
176 beforemerge |
|
177 hg merge -r 2 --config merge-tools.true.executable=echo --config merge-tools.true.args='mergeresult > $output' |
|
178 aftermerge |
|
179 |
|
180 echo '# Merge using tool with a path that must be quoted:' |
|
181 beforemerge |
|
182 cat <<EOF > 'my merge tool' |
|
183 #!/bin/sh |
|
184 cat "\$1" "\$2" "\$3" > "\$4" |
|
185 EOF |
|
186 chmod +x 'my merge tool' |
|
187 hg merge -r 2 --config merge-tools.true.executable='./my merge tool' --config merge-tools.true.args='$base $local $other $output' |
|
188 rm -f 'my merge tool' |
|
189 aftermerge |
|
190 |
|
191 |
|
192 echo |
|
193 echo Merge post-processing |
|
194 echo |
|
195 |
|
196 echo "# cat is a bad merge-tool and doesn't change:" |
|
197 domerge -y -r 2 --config merge-tools.true.checkchanged=1 |
|