author | Adrian Buehlmann <adrian@cadifra.com> |
Tue, 14 Sep 2010 12:20:51 +0200 | |
changeset 12279 | 28e2e3804f2e |
parent 9716 | tests/test-update-branches@ea8c207a0f78 |
child 12328 | b63f6422d2a7 |
permissions | -rwxr-xr-x |
9716
ea8c207a0f78
update: add comments and test cases for updating across branches
Stuart W Marks <smarks@smarks.org>
parents:
diff
changeset
|
1 |
# Construct the following history tree: |
ea8c207a0f78
update: add comments and test cases for updating across branches
Stuart W Marks <smarks@smarks.org>
parents:
diff
changeset
|
2 |
# |
ea8c207a0f78
update: add comments and test cases for updating across branches
Stuart W Marks <smarks@smarks.org>
parents:
diff
changeset
|
3 |
# @ 5:e1bb631146ca b1 |
ea8c207a0f78
update: add comments and test cases for updating across branches
Stuart W Marks <smarks@smarks.org>
parents:
diff
changeset
|
4 |
# | |
ea8c207a0f78
update: add comments and test cases for updating across branches
Stuart W Marks <smarks@smarks.org>
parents:
diff
changeset
|
5 |
# o 4:a4fdb3b883c4 0:b608b9236435 b1 |
ea8c207a0f78
update: add comments and test cases for updating across branches
Stuart W Marks <smarks@smarks.org>
parents:
diff
changeset
|
6 |
# | |
ea8c207a0f78
update: add comments and test cases for updating across branches
Stuart W Marks <smarks@smarks.org>
parents:
diff
changeset
|
7 |
# | o 3:4b57d2520816 1:44592833ba9f |
ea8c207a0f78
update: add comments and test cases for updating across branches
Stuart W Marks <smarks@smarks.org>
parents:
diff
changeset
|
8 |
# | | |
ea8c207a0f78
update: add comments and test cases for updating across branches
Stuart W Marks <smarks@smarks.org>
parents:
diff
changeset
|
9 |
# | | o 2:063f31070f65 |
ea8c207a0f78
update: add comments and test cases for updating across branches
Stuart W Marks <smarks@smarks.org>
parents:
diff
changeset
|
10 |
# | |/ |
ea8c207a0f78
update: add comments and test cases for updating across branches
Stuart W Marks <smarks@smarks.org>
parents:
diff
changeset
|
11 |
# | o 1:44592833ba9f |
ea8c207a0f78
update: add comments and test cases for updating across branches
Stuart W Marks <smarks@smarks.org>
parents:
diff
changeset
|
12 |
# |/ |
ea8c207a0f78
update: add comments and test cases for updating across branches
Stuart W Marks <smarks@smarks.org>
parents:
diff
changeset
|
13 |
# o 0:b608b9236435 |
ea8c207a0f78
update: add comments and test cases for updating across branches
Stuart W Marks <smarks@smarks.org>
parents:
diff
changeset
|
14 |
|
12279 | 15 |
$ hg init |
16 |
$ echo foo > foo |
|
17 |
$ echo zero > a |
|
18 |
$ hg ci -qAm0 |
|
19 |
$ echo one > a ; hg ci -m1 |
|
20 |
$ echo two > a ; hg ci -m2 |
|
21 |
$ hg up -q 1 |
|
22 |
$ echo three > a ; hg ci -qm3 |
|
23 |
$ hg up -q 0 |
|
24 |
$ hg branch -q b1 |
|
25 |
$ echo four > a ; hg ci -qm4 |
|
26 |
$ echo five > a ; hg ci -qm5 |
|
9716
ea8c207a0f78
update: add comments and test cases for updating across branches
Stuart W Marks <smarks@smarks.org>
parents:
diff
changeset
|
27 |
|
12279 | 28 |
Initial repo state: |
9716
ea8c207a0f78
update: add comments and test cases for updating across branches
Stuart W Marks <smarks@smarks.org>
parents:
diff
changeset
|
29 |
|
12279 | 30 |
$ hg --config 'extensions.graphlog=' \ |
31 |
> glog --template '{rev}:{node|short} {parents} {branches}\n' |
|
32 |
@ 5:e1bb631146ca b1 |
|
33 |
| |
|
34 |
o 4:a4fdb3b883c4 0:b608b9236435 b1 |
|
35 |
| |
|
36 |
| o 3:4b57d2520816 1:44592833ba9f |
|
37 |
| | |
|
38 |
| | o 2:063f31070f65 |
|
39 |
| |/ |
|
40 |
| o 1:44592833ba9f |
|
41 |
|/ |
|
42 |
o 0:b608b9236435 |
|
43 |
||
44 |
||
45 |
Test helper functions: |
|
9716
ea8c207a0f78
update: add comments and test cases for updating across branches
Stuart W Marks <smarks@smarks.org>
parents:
diff
changeset
|
46 |
|
12279 | 47 |
$ revtest () { |
48 |
> msg=$1 |
|
49 |
> dirtyflag=$2 # 'clean' or 'dirty' |
|
50 |
> startrev=$3 |
|
51 |
> targetrev=$4 |
|
52 |
> opt=$5 |
|
53 |
> hg up -qC $startrev |
|
54 |
> test $dirtyflag = dirty && echo dirty > foo |
|
55 |
> hg up $opt $targetrev |
|
56 |
> hg parent --template 'parent={rev}\n' |
|
57 |
> hg stat |
|
58 |
> } |
|
59 |
||
60 |
$ norevtest () { |
|
61 |
> msg=$1 |
|
62 |
> dirtyflag=$2 # 'clean' or 'dirty' |
|
63 |
> startrev=$3 |
|
64 |
> opt=$4 |
|
65 |
> hg up -qC $startrev |
|
66 |
> test $dirtyflag = dirty && echo dirty > foo |
|
67 |
> hg up $opt |
|
68 |
> hg parent --template 'parent={rev}\n' |
|
69 |
> hg stat |
|
70 |
> } |
|
9716
ea8c207a0f78
update: add comments and test cases for updating across branches
Stuart W Marks <smarks@smarks.org>
parents:
diff
changeset
|
71 |
|
ea8c207a0f78
update: add comments and test cases for updating across branches
Stuart W Marks <smarks@smarks.org>
parents:
diff
changeset
|
72 |
# Test cases are documented in a table in the update function of merge.py. |
ea8c207a0f78
update: add comments and test cases for updating across branches
Stuart W Marks <smarks@smarks.org>
parents:
diff
changeset
|
73 |
# Cases are run as shown in that table, row by row. |
ea8c207a0f78
update: add comments and test cases for updating across branches
Stuart W Marks <smarks@smarks.org>
parents:
diff
changeset
|
74 |
|
12279 | 75 |
$ norevtest 'none clean linear' clean 4 |
76 |
1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
77 |
parent=5 |
|
78 |
||
79 |
$ norevtest 'none clean same' clean 2 |
|
80 |
abort: crosses branches (use 'hg merge' or use 'hg update -c') |
|
81 |
parent=2 |
|
82 |
||
83 |
||
84 |
$ revtest 'none clean linear' clean 1 2 |
|
85 |
1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
86 |
parent=2 |
|
9716
ea8c207a0f78
update: add comments and test cases for updating across branches
Stuart W Marks <smarks@smarks.org>
parents:
diff
changeset
|
87 |
|
12279 | 88 |
$ revtest 'none clean same' clean 2 3 |
89 |
1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
90 |
parent=3 |
|
91 |
||
92 |
$ revtest 'none clean cross' clean 3 4 |
|
93 |
1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
94 |
parent=4 |
|
95 |
||
96 |
||
97 |
$ revtest 'none dirty linear' dirty 1 2 |
|
98 |
1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
99 |
parent=2 |
|
100 |
M foo |
|
9716
ea8c207a0f78
update: add comments and test cases for updating across branches
Stuart W Marks <smarks@smarks.org>
parents:
diff
changeset
|
101 |
|
12279 | 102 |
$ revtest 'none dirty same' dirty 2 3 |
103 |
abort: crosses branches (use 'hg merge' to merge or use 'hg update -C' to discard changes) |
|
104 |
parent=2 |
|
105 |
M foo |
|
106 |
||
107 |
$ revtest 'none dirty cross' dirty 3 4 |
|
108 |
abort: crosses branches (use 'hg merge' to merge or use 'hg update -C' to discard changes) |
|
109 |
parent=3 |
|
110 |
M foo |
|
111 |
||
112 |
||
113 |
$ revtest '-C dirty linear' dirty 1 2 -C |
|
114 |
2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
115 |
parent=2 |
|
9716
ea8c207a0f78
update: add comments and test cases for updating across branches
Stuart W Marks <smarks@smarks.org>
parents:
diff
changeset
|
116 |
|
12279 | 117 |
$ revtest '-c dirty linear' dirty 1 2 -c |
118 |
abort: uncommitted local changes |
|
119 |
parent=1 |
|
120 |
M foo |
|
121 |
||
122 |
$ norevtest '-c clean same' clean 2 -c |
|
123 |
1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
124 |
parent=3 |
|
125 |
||
126 |
$ revtest '-cC dirty linear' dirty 1 2 -cC |
|
127 |
abort: cannot specify both -c/--check and -C/--clean |
|
128 |
parent=1 |
|
129 |
M foo |
|
130 |