Mercurial > hg
comparison tests/test-merge-combination.t @ 46265:8045e4aa366b
test: extract the `genmerges` out of test-merge-combination.t
This open the way to splitting this slow test in multiple ones.
Differential Revision: https://phab.mercurial-scm.org/D9767
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 14 Jan 2021 11:33:09 +0100 |
parents | 302dbc9d52be |
children |
comparison
equal
deleted
inserted
replaced
46264:7149fb17ff72 | 46265:8045e4aa366b |
---|---|
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 |