annotate tests/test-update-branches.t @ 12681:bc13e17067d9

update: use higher level wording for "crosses branches" error When using "hg update" to update to a revision on another branch, if the user has uncommitted changes in the working directory, hg aborts with the following message: abort: crosses branches (use 'hg merge' to merge or use 'hg update -C' to discard changes) If the user isn't trying to update to tip and they follow the command examples verbatim, they would end up updating to the wrong revision. This patch removes the command examples in favor of just telling the user to either merge or use --clean: abort: crosses branches (merge branches or use --clean to discard changes) hg also aborts if the user tries to use "hg update" to get to tip (without specifying a revision) and tip is on another branch: abort: crosses branches (use 'hg merge' or use 'hg update -c') This message is changed in the same fashion: abort: crosses branches (merge branches or use --check to force update)
author Brodie Rao <brodie@bitheap.org>
date Sat, 09 Oct 2010 17:02:28 -0500
parents b63f6422d2a7
children 610873cf064a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
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
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
15 $ hg init
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
16 $ echo foo > foo
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
17 $ echo zero > a
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
18 $ hg ci -qAm0
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
19 $ echo one > a ; hg ci -m1
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
20 $ echo two > a ; hg ci -m2
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
21 $ hg up -q 1
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
22 $ echo three > a ; hg ci -qm3
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
23 $ hg up -q 0
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
24 $ hg branch -q b1
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
25 $ echo four > a ; hg ci -qm4
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
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
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
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
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
30 $ hg --config 'extensions.graphlog=' \
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
31 > glog --template '{rev}:{node|short} {parents} {branches}\n'
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
32 @ 5:e1bb631146ca b1
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
33 |
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
34 o 4:a4fdb3b883c4 0:b608b9236435 b1
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
35 |
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
36 | o 3:4b57d2520816 1:44592833ba9f
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
37 | |
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
38 | | o 2:063f31070f65
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
39 | |/
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
40 | o 1:44592833ba9f
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
41 |/
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
42 o 0:b608b9236435
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
43
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
44
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
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
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
47 $ revtest () {
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
48 > msg=$1
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
49 > dirtyflag=$2 # 'clean' or 'dirty'
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
50 > startrev=$3
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
51 > targetrev=$4
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
52 > opt=$5
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
53 > hg up -qC $startrev
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
54 > test $dirtyflag = dirty && echo dirty > foo
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
55 > hg up $opt $targetrev
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
56 > hg parent --template 'parent={rev}\n'
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
57 > hg stat
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
58 > }
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
59
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
60 $ norevtest () {
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
61 > msg=$1
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
62 > dirtyflag=$2 # 'clean' or 'dirty'
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
63 > startrev=$3
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
64 > opt=$4
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
65 > hg up -qC $startrev
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
66 > test $dirtyflag = dirty && echo dirty > foo
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
67 > hg up $opt
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
68 > hg parent --template 'parent={rev}\n'
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
69 > hg stat
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
70 > }
9716
ea8c207a0f78 update: add comments and test cases for updating across branches
Stuart W Marks <smarks@smarks.org>
parents:
diff changeset
71
12328
b63f6422d2a7 tests: fix a bunch of pointless #s in unified tests
Matt Mackall <mpm@selenic.com>
parents: 12279
diff changeset
72 Test cases are documented in a table in the update function of merge.py.
b63f6422d2a7 tests: fix a bunch of pointless #s in unified tests
Matt Mackall <mpm@selenic.com>
parents: 12279
diff changeset
73 Cases are run as shown in that table, row by row.
9716
ea8c207a0f78 update: add comments and test cases for updating across branches
Stuart W Marks <smarks@smarks.org>
parents:
diff changeset
74
12279
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
75 $ norevtest 'none clean linear' clean 4
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
76 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
77 parent=5
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
78
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
79 $ norevtest 'none clean same' clean 2
12681
bc13e17067d9 update: use higher level wording for "crosses branches" error
Brodie Rao <brodie@bitheap.org>
parents: 12328
diff changeset
80 abort: crosses branches (merge branches or use --check to force update)
12279
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
81 parent=2
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
82
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
83
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
84 $ revtest 'none clean linear' clean 1 2
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
85 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
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
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
88 $ revtest 'none clean same' clean 2 3
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
89 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
90 parent=3
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
91
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
92 $ revtest 'none clean cross' clean 3 4
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
93 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
94 parent=4
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
95
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
96
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
97 $ revtest 'none dirty linear' dirty 1 2
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
98 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
99 parent=2
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
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
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
102 $ revtest 'none dirty same' dirty 2 3
12681
bc13e17067d9 update: use higher level wording for "crosses branches" error
Brodie Rao <brodie@bitheap.org>
parents: 12328
diff changeset
103 abort: crosses branches (merge branches or use --clean to discard changes)
12279
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
104 parent=2
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
105 M foo
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
106
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
107 $ revtest 'none dirty cross' dirty 3 4
12681
bc13e17067d9 update: use higher level wording for "crosses branches" error
Brodie Rao <brodie@bitheap.org>
parents: 12328
diff changeset
108 abort: crosses branches (merge branches or use --clean to discard changes)
12279
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
109 parent=3
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
110 M foo
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
111
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
112
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
113 $ revtest '-C dirty linear' dirty 1 2 -C
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
114 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
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
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
117 $ revtest '-c dirty linear' dirty 1 2 -c
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
118 abort: uncommitted local changes
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
119 parent=1
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
120 M foo
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
121
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
122 $ norevtest '-c clean same' clean 2 -c
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
123 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
124 parent=3
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
125
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
126 $ revtest '-cC dirty linear' dirty 1 2 -cC
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
127 abort: cannot specify both -c/--check and -C/--clean
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
128 parent=1
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
129 M foo
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
130