##// END OF EJS Templates
test: extract the `genmerges` out of test-merge-combination.t...
marmoute -
r46891:8045e4aa default
parent child Browse files
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 }
@@ -5,70 +5,7 b' involve executable bit changing, but not'
5 5 merge ancestors, nor copies/renames, and nor identical file contents
6 6 with different filelog revisions.
7 7
8 genmerges is the workhorse. Given:
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 > }
8 $ . $TESTDIR/testlib/merge-combination-util.sh
72 9
73 10 All the merges of various file contents.
74 11
General Comments 0
You need to be logged in to leave comments. Login now