Show More
@@ -0,0 +1,73 b'' | |||||
|
1 | # genmerges is the workhorse of the test-merge-combination.t tests. | |||
|
2 | ||||
|
3 | # Given: | |||
|
4 | # - a `range` function describing the possible values for file a | |||
|
5 | # - a `isgood` function to filter out uninteresting combination | |||
|
6 | # - a `createfile` function to actually write the values for file a on the | |||
|
7 | # filesystem | |||
|
8 | # | |||
|
9 | # it print a series of lines that look like: abcd C: output of -T {files} | |||
|
10 | # describing the file a at respectively the base, p2, p1, merge | |||
|
11 | # revision. "C" indicates that hg merge had conflicts. | |||
|
12 | ||||
|
13 | genmerges () { | |||
|
14 | ||||
|
15 | (LC_ALL=C type range | grep -q 'function') || (echo >&2 "missing function: range") | |||
|
16 | (LC_ALL=C type isgood | grep -q 'function') || (echo >&2 "missing function: isgood") | |||
|
17 | (LC_ALL=C type createfile | grep -q 'function') || (echo >&2 "missing function: createfile") | |||
|
18 | ||||
|
19 | for base in `range` -; do | |||
|
20 | for r1 in `range $base` -; do | |||
|
21 | for r2 in `range $base $r1` -; do | |||
|
22 | for m in `range $base $r1 $r2` -; do | |||
|
23 | line="$base$r1$r2$m" | |||
|
24 | isgood $line || continue | |||
|
25 | hg init repo | |||
|
26 | cd repo | |||
|
27 | make_commit () { | |||
|
28 | v=$1; msg=$2; file=$3; | |||
|
29 | if [ $v != - ]; then | |||
|
30 | createfile $v | |||
|
31 | else | |||
|
32 | if [ -f a ] | |||
|
33 | then rm a | |||
|
34 | else touch $file | |||
|
35 | fi | |||
|
36 | fi | |||
|
37 | hg commit -q -Am $msg || exit 123 | |||
|
38 | } | |||
|
39 | echo foo > foo | |||
|
40 | make_commit $base base b | |||
|
41 | make_commit $r1 r1 c | |||
|
42 | hg up -r 0 -q | |||
|
43 | make_commit $r2 r2 d | |||
|
44 | hg merge -q -r 1 > ../output 2>&1 | |||
|
45 | if [ $? -ne 0 ]; then rm -f *.orig; hg resolve -m --all -q; fi | |||
|
46 | if [ -s ../output ]; then conflicts=" C"; else conflicts=" "; fi | |||
|
47 | make_commit $m m e | |||
|
48 | if [ $m = $r1 ] && [ $m = $r2 ] | |||
|
49 | then expected= | |||
|
50 | elif [ $m = $r1 ] | |||
|
51 | then if [ $base = $r2 ] | |||
|
52 | then expected= | |||
|
53 | else expected=a | |||
|
54 | fi | |||
|
55 | elif [ $m = $r2 ] | |||
|
56 | then if [ $base = $r1 ] | |||
|
57 | then expected= | |||
|
58 | else expected=a | |||
|
59 | fi | |||
|
60 | else expected=a | |||
|
61 | fi | |||
|
62 | got=`hg log -r 3 --template '{files}\n' | tr -d 'e '` | |||
|
63 | if [ "$got" = "$expected" ] | |||
|
64 | then echo "$line$conflicts: agree on \"$got\"" | |||
|
65 | else echo "$line$conflicts: hg said \"$got\", expected \"$expected\"" | |||
|
66 | fi | |||
|
67 | cd ../ | |||
|
68 | rm -rf repo | |||
|
69 | done | |||
|
70 | done | |||
|
71 | done | |||
|
72 | done | |||
|
73 | } |
@@ -1,220 +1,157 b'' | |||||
1 | This file shows what hg says are "modified" files for a merge commit |
|
1 | This file shows what hg says are "modified" files for a merge commit | |
2 | (hg log -T {files}), somewhat exhaustively. |
|
2 | (hg log -T {files}), somewhat exhaustively. | |
3 | It shows merges that involves files contents changing, and merges that |
|
3 | It shows merges that involves files contents changing, and merges that | |
4 | involve executable bit changing, but not merges with multiple or zero |
|
4 | involve executable bit changing, but not merges with multiple or zero | |
5 | merge ancestors, nor copies/renames, and nor identical file contents |
|
5 | merge ancestors, nor copies/renames, and nor identical file contents | |
6 | with different filelog revisions. |
|
6 | with different filelog revisions. | |
7 |
|
7 | |||
8 | genmerges is the workhorse. Given: |
|
8 | $ . $TESTDIR/testlib/merge-combination-util.sh | |
9 | - a range function describing the possible values for file a |
|
|||
10 | - a isgood function to filter out uninteresting combination |
|
|||
11 | - a createfile function to actually write the values for file a on the |
|
|||
12 | filesystem |
|
|||
13 | it print a series of lines that look like: abcd C: output of -T {files} |
|
|||
14 | describing the file a at respectively the base, p2, p1, merge |
|
|||
15 | revision. "C" indicates that hg merge had conflicts. |
|
|||
16 | $ genmerges () { |
|
|||
17 | > for base in `range` -; do |
|
|||
18 | > for r1 in `range $base` -; do |
|
|||
19 | > for r2 in `range $base $r1` -; do |
|
|||
20 | > for m in `range $base $r1 $r2` -; do |
|
|||
21 | > line="$base$r1$r2$m" |
|
|||
22 | > isgood $line || continue |
|
|||
23 | > hg init repo |
|
|||
24 | > cd repo |
|
|||
25 | > make_commit () { |
|
|||
26 | > v=$1; msg=$2; file=$3; |
|
|||
27 | > if [ $v != - ]; then |
|
|||
28 | > createfile $v |
|
|||
29 | > else |
|
|||
30 | > if [ -f a ] |
|
|||
31 | > then rm a |
|
|||
32 | > else touch $file |
|
|||
33 | > fi |
|
|||
34 | > fi |
|
|||
35 | > hg commit -q -Am $msg || exit 123 |
|
|||
36 | > } |
|
|||
37 | > echo foo > foo |
|
|||
38 | > make_commit $base base b |
|
|||
39 | > make_commit $r1 r1 c |
|
|||
40 | > hg up -r 0 -q |
|
|||
41 | > make_commit $r2 r2 d |
|
|||
42 | > hg merge -q -r 1 > ../output 2>&1 |
|
|||
43 | > if [ $? -ne 0 ]; then rm -f *.orig; hg resolve -m --all -q; fi |
|
|||
44 | > if [ -s ../output ]; then conflicts=" C"; else conflicts=" "; fi |
|
|||
45 | > make_commit $m m e |
|
|||
46 | > if [ $m = $r1 ] && [ $m = $r2 ] |
|
|||
47 | > then expected= |
|
|||
48 | > elif [ $m = $r1 ] |
|
|||
49 | > then if [ $base = $r2 ] |
|
|||
50 | > then expected= |
|
|||
51 | > else expected=a |
|
|||
52 | > fi |
|
|||
53 | > elif [ $m = $r2 ] |
|
|||
54 | > then if [ $base = $r1 ] |
|
|||
55 | > then expected= |
|
|||
56 | > else expected=a |
|
|||
57 | > fi |
|
|||
58 | > else expected=a |
|
|||
59 | > fi |
|
|||
60 | > got=`hg log -r 3 --template '{files}\n' | tr -d 'e '` |
|
|||
61 | > if [ "$got" = "$expected" ] |
|
|||
62 | > then echo "$line$conflicts: agree on \"$got\"" |
|
|||
63 | > else echo "$line$conflicts: hg said \"$got\", expected \"$expected\"" |
|
|||
64 | > fi |
|
|||
65 | > cd ../ |
|
|||
66 | > rm -rf repo |
|
|||
67 | > done |
|
|||
68 | > done |
|
|||
69 | > done |
|
|||
70 | > done |
|
|||
71 | > } |
|
|||
72 |
|
9 | |||
73 | All the merges of various file contents. |
|
10 | All the merges of various file contents. | |
74 |
|
11 | |||
75 | $ range () { |
|
12 | $ range () { | |
76 | > max=0 |
|
13 | > max=0 | |
77 | > for i in $@; do |
|
14 | > for i in $@; do | |
78 | > if [ $i = - ]; then continue; fi |
|
15 | > if [ $i = - ]; then continue; fi | |
79 | > if [ $i -gt $max ]; then max=$i; fi |
|
16 | > if [ $i -gt $max ]; then max=$i; fi | |
80 | > done |
|
17 | > done | |
81 | > $TESTDIR/seq.py `expr $max + 1` |
|
18 | > $TESTDIR/seq.py `expr $max + 1` | |
82 | > } |
|
19 | > } | |
83 | $ isgood () { true; } |
|
20 | $ isgood () { true; } | |
84 | $ createfile () { |
|
21 | $ createfile () { | |
85 | > if [ -f a ] && [ "`cat a`" = $1 ] |
|
22 | > if [ -f a ] && [ "`cat a`" = $1 ] | |
86 | > then touch $file |
|
23 | > then touch $file | |
87 | > else echo $v > a |
|
24 | > else echo $v > a | |
88 | > fi |
|
25 | > fi | |
89 | > } |
|
26 | > } | |
90 |
|
27 | |||
91 | $ genmerges |
|
28 | $ genmerges | |
92 | 1111 : agree on "" |
|
29 | 1111 : agree on "" | |
93 | 1112 : agree on "a" |
|
30 | 1112 : agree on "a" | |
94 | 111- : agree on "a" |
|
31 | 111- : agree on "a" | |
95 | 1121 : agree on "a" |
|
32 | 1121 : agree on "a" | |
96 | 1122 : agree on "" |
|
33 | 1122 : agree on "" | |
97 | 1123 : agree on "a" |
|
34 | 1123 : agree on "a" | |
98 | 112- : agree on "a" |
|
35 | 112- : agree on "a" | |
99 | 11-1 : hg said "", expected "a" |
|
36 | 11-1 : hg said "", expected "a" | |
100 | 11-2 : agree on "a" |
|
37 | 11-2 : agree on "a" | |
101 | 11-- : agree on "" |
|
38 | 11-- : agree on "" | |
102 | 1211 : agree on "a" |
|
39 | 1211 : agree on "a" | |
103 | 1212 : agree on "" |
|
40 | 1212 : agree on "" | |
104 | 1213 : agree on "a" |
|
41 | 1213 : agree on "a" | |
105 | 121- : agree on "a" |
|
42 | 121- : agree on "a" | |
106 | 1221 : agree on "a" |
|
43 | 1221 : agree on "a" | |
107 | 1222 : agree on "" |
|
44 | 1222 : agree on "" | |
108 | 1223 : agree on "a" |
|
45 | 1223 : agree on "a" | |
109 | 122- : agree on "a" |
|
46 | 122- : agree on "a" | |
110 | 1231 C: agree on "a" |
|
47 | 1231 C: agree on "a" | |
111 | 1232 C: agree on "a" |
|
48 | 1232 C: agree on "a" | |
112 | 1233 C: agree on "a" |
|
49 | 1233 C: agree on "a" | |
113 | 1234 C: agree on "a" |
|
50 | 1234 C: agree on "a" | |
114 | 123- C: agree on "a" |
|
51 | 123- C: agree on "a" | |
115 | 12-1 C: agree on "a" |
|
52 | 12-1 C: agree on "a" | |
116 | 12-2 C: hg said "", expected "a" |
|
53 | 12-2 C: hg said "", expected "a" | |
117 | 12-3 C: agree on "a" |
|
54 | 12-3 C: agree on "a" | |
118 | 12-- C: agree on "a" |
|
55 | 12-- C: agree on "a" | |
119 | 1-11 : hg said "", expected "a" |
|
56 | 1-11 : hg said "", expected "a" | |
120 | 1-12 : agree on "a" |
|
57 | 1-12 : agree on "a" | |
121 | 1-1- : agree on "" |
|
58 | 1-1- : agree on "" | |
122 | 1-21 C: agree on "a" |
|
59 | 1-21 C: agree on "a" | |
123 | 1-22 C: hg said "", expected "a" |
|
60 | 1-22 C: hg said "", expected "a" | |
124 | 1-23 C: agree on "a" |
|
61 | 1-23 C: agree on "a" | |
125 | 1-2- C: agree on "a" |
|
62 | 1-2- C: agree on "a" | |
126 | 1--1 : agree on "a" |
|
63 | 1--1 : agree on "a" | |
127 | 1--2 : agree on "a" |
|
64 | 1--2 : agree on "a" | |
128 | 1--- : agree on "" |
|
65 | 1--- : agree on "" | |
129 | -111 : agree on "" |
|
66 | -111 : agree on "" | |
130 | -112 : agree on "a" |
|
67 | -112 : agree on "a" | |
131 | -11- : agree on "a" |
|
68 | -11- : agree on "a" | |
132 | -121 C: agree on "a" |
|
69 | -121 C: agree on "a" | |
133 | -122 C: agree on "a" |
|
70 | -122 C: agree on "a" | |
134 | -123 C: agree on "a" |
|
71 | -123 C: agree on "a" | |
135 | -12- C: agree on "a" |
|
72 | -12- C: agree on "a" | |
136 | -1-1 : agree on "" |
|
73 | -1-1 : agree on "" | |
137 | -1-2 : agree on "a" |
|
74 | -1-2 : agree on "a" | |
138 | -1-- : agree on "a" |
|
75 | -1-- : agree on "a" | |
139 | --11 : agree on "" |
|
76 | --11 : agree on "" | |
140 | --12 : agree on "a" |
|
77 | --12 : agree on "a" | |
141 | --1- : agree on "a" |
|
78 | --1- : agree on "a" | |
142 | ---1 : agree on "a" |
|
79 | ---1 : agree on "a" | |
143 | ---- : agree on "" |
|
80 | ---- : agree on "" | |
144 |
|
81 | |||
145 | All the merges of executable bit. |
|
82 | All the merges of executable bit. | |
146 |
|
83 | |||
147 | $ range () { |
|
84 | $ range () { | |
148 | > max=a |
|
85 | > max=a | |
149 | > for i in $@; do |
|
86 | > for i in $@; do | |
150 | > if [ $i = - ]; then continue; fi |
|
87 | > if [ $i = - ]; then continue; fi | |
151 | > if [ $i > $max ]; then max=$i; fi |
|
88 | > if [ $i > $max ]; then max=$i; fi | |
152 | > done |
|
89 | > done | |
153 | > if [ $max = a ]; then echo f; else echo f x; fi |
|
90 | > if [ $max = a ]; then echo f; else echo f x; fi | |
154 | > } |
|
91 | > } | |
155 | $ isgood () { case $line in *f*x*) true;; *) false;; esac; } |
|
92 | $ isgood () { case $line in *f*x*) true;; *) false;; esac; } | |
156 | $ createfile () { |
|
93 | $ createfile () { | |
157 | > if [ -f a ] && (([ -x a ] && [ $v = x ]) || (! [ -x a ] && [ $v != x ])) |
|
94 | > if [ -f a ] && (([ -x a ] && [ $v = x ]) || (! [ -x a ] && [ $v != x ])) | |
158 | > then touch $file |
|
95 | > then touch $file | |
159 | > else touch a; if [ $v = x ]; then chmod +x a; else chmod -x a; fi |
|
96 | > else touch a; if [ $v = x ]; then chmod +x a; else chmod -x a; fi | |
160 | > fi |
|
97 | > fi | |
161 | > } |
|
98 | > } | |
162 |
|
99 | |||
163 | #if execbit |
|
100 | #if execbit | |
164 | $ genmerges |
|
101 | $ genmerges | |
165 | fffx : agree on "a" |
|
102 | fffx : agree on "a" | |
166 | ffxf : agree on "a" |
|
103 | ffxf : agree on "a" | |
167 | ffxx : agree on "" |
|
104 | ffxx : agree on "" | |
168 | ffx- : agree on "a" |
|
105 | ffx- : agree on "a" | |
169 | ff-x : hg said "", expected "a" |
|
106 | ff-x : hg said "", expected "a" | |
170 | fxff : hg said "", expected "a" |
|
107 | fxff : hg said "", expected "a" | |
171 | fxfx : hg said "a", expected "" |
|
108 | fxfx : hg said "a", expected "" | |
172 | fxf- : agree on "a" |
|
109 | fxf- : agree on "a" | |
173 | fxxf : agree on "a" |
|
110 | fxxf : agree on "a" | |
174 | fxxx : agree on "" |
|
111 | fxxx : agree on "" | |
175 | fxx- : agree on "a" |
|
112 | fxx- : agree on "a" | |
176 | fx-f : hg said "", expected "a" |
|
113 | fx-f : hg said "", expected "a" | |
177 | fx-x : hg said "", expected "a" |
|
114 | fx-x : hg said "", expected "a" | |
178 | fx-- : hg said "", expected "a" |
|
115 | fx-- : hg said "", expected "a" | |
179 | f-fx : agree on "a" |
|
116 | f-fx : agree on "a" | |
180 | f-xf : agree on "a" |
|
117 | f-xf : agree on "a" | |
181 | f-xx : hg said "", expected "a" |
|
118 | f-xx : hg said "", expected "a" | |
182 | f-x- : agree on "a" |
|
119 | f-x- : agree on "a" | |
183 | f--x : agree on "a" |
|
120 | f--x : agree on "a" | |
184 | -ffx : agree on "a" |
|
121 | -ffx : agree on "a" | |
185 | -fxf C: agree on "a" |
|
122 | -fxf C: agree on "a" | |
186 | -fxx C: hg said "", expected "a" |
|
123 | -fxx C: hg said "", expected "a" | |
187 | -fx- C: agree on "a" |
|
124 | -fx- C: agree on "a" | |
188 | -f-x : hg said "", expected "a" |
|
125 | -f-x : hg said "", expected "a" | |
189 | --fx : agree on "a" |
|
126 | --fx : agree on "a" | |
190 | #endif |
|
127 | #endif | |
191 |
|
128 | |||
192 | Files modified or cleanly merged, with no greatest common ancestors: |
|
129 | Files modified or cleanly merged, with no greatest common ancestors: | |
193 |
|
130 | |||
194 | $ hg init repo; cd repo |
|
131 | $ hg init repo; cd repo | |
195 | $ touch a0 b0; hg commit -qAm 0 |
|
132 | $ touch a0 b0; hg commit -qAm 0 | |
196 | $ hg up -qr null; touch a1 b1; hg commit -qAm 1 |
|
133 | $ hg up -qr null; touch a1 b1; hg commit -qAm 1 | |
197 | $ hg merge -qr 0; rm b*; hg commit -qAm 2 |
|
134 | $ hg merge -qr 0; rm b*; hg commit -qAm 2 | |
198 | $ hg log -r . -T '{files}\n' |
|
135 | $ hg log -r . -T '{files}\n' | |
199 | b0 b1 |
|
136 | b0 b1 | |
200 | $ cd ../ |
|
137 | $ cd ../ | |
201 | $ rm -rf repo |
|
138 | $ rm -rf repo | |
202 |
|
139 | |||
203 | A few cases of criss-cross merges involving deletions (listing all |
|
140 | A few cases of criss-cross merges involving deletions (listing all | |
204 | such merges is probably too much). Both gcas contain $files, so we |
|
141 | such merges is probably too much). Both gcas contain $files, so we | |
205 | expect the final merge to behave like a merge with a single gca |
|
142 | expect the final merge to behave like a merge with a single gca | |
206 | containing $files. |
|
143 | containing $files. | |
207 |
|
144 | |||
208 | $ hg init repo; cd repo |
|
145 | $ hg init repo; cd repo | |
209 | $ files="c1 u1 c2 u2" |
|
146 | $ files="c1 u1 c2 u2" | |
210 | $ touch $files; hg commit -qAm '0 root' |
|
147 | $ touch $files; hg commit -qAm '0 root' | |
211 | $ for f in $files; do echo f > $f; done; hg commit -qAm '1 gca1' |
|
148 | $ for f in $files; do echo f > $f; done; hg commit -qAm '1 gca1' | |
212 | $ hg up -qr0; hg revert -qr 1 --all; hg commit -qAm '2 gca2' |
|
149 | $ hg up -qr0; hg revert -qr 1 --all; hg commit -qAm '2 gca2' | |
213 | $ hg up -qr 1; hg merge -qr 2; rm *1; hg commit -qAm '3 p1' |
|
150 | $ hg up -qr 1; hg merge -qr 2; rm *1; hg commit -qAm '3 p1' | |
214 | $ hg up -qr 2; hg merge -qr 1; rm *2; hg commit -qAm '4 p2' |
|
151 | $ hg up -qr 2; hg merge -qr 1; rm *2; hg commit -qAm '4 p2' | |
215 | $ hg merge -qr 3; echo f > u1; echo f > u2; rm -f c1 c2 |
|
152 | $ hg merge -qr 3; echo f > u1; echo f > u2; rm -f c1 c2 | |
216 | $ hg commit -qAm '5 merge with two gcas' |
|
153 | $ hg commit -qAm '5 merge with two gcas' | |
217 | $ hg log -r . -T '{files}\n' # expecting u1 u2 |
|
154 | $ hg log -r . -T '{files}\n' # expecting u1 u2 | |
218 |
|
155 | |||
219 | $ cd ../ |
|
156 | $ cd ../ | |
220 | $ rm -rf repo |
|
157 | $ rm -rf repo |
General Comments 0
You need to be logged in to leave comments.
Login now