##// END OF EJS Templates
tests: improve test coverage of branch command and existing branches
Mads Kiilerich -
r22363:9510b0e9 default
parent child Browse files
Show More
@@ -1,344 +1,355
1 1 $ branchcache=.hg/cache/branch2
2 2
3 3 $ listbranchcaches() {
4 4 > for f in .hg/cache/branch2*;
5 5 > do echo === $f ===;
6 6 > cat $f;
7 7 > done;
8 8 > }
9 9 $ purgebranchcaches() {
10 10 > rm .hg/cache/branch2*
11 11 > }
12 12
13 13 $ hg init t
14 14 $ cd t
15 15
16 16 $ hg branches
17 17 $ echo foo > a
18 18 $ hg add a
19 19 $ hg ci -m "initial"
20 20 $ hg branch foo
21 21 marked working directory as branch foo
22 22 (branches are permanent and global, did you want a bookmark?)
23 23 $ hg branch
24 24 foo
25 25 $ hg ci -m "add branch name"
26 26 $ hg branch bar
27 27 marked working directory as branch bar
28 28 (branches are permanent and global, did you want a bookmark?)
29 29 $ hg ci -m "change branch name"
30 30
31 31 Branch shadowing:
32 32
33 33 $ hg branch default
34 34 abort: a branch of the same name already exists
35 35 (use 'hg update' to switch to it)
36 36 [255]
37 37
38 38 $ hg branch -f default
39 39 marked working directory as branch default
40 40 (branches are permanent and global, did you want a bookmark?)
41 41
42 42 $ hg ci -m "clear branch name"
43 43 created new head
44 44
45 45 There should be only one default branch head
46 46
47 47 $ hg heads .
48 48 changeset: 3:1c28f494dae6
49 49 tag: tip
50 50 user: test
51 51 date: Thu Jan 01 00:00:00 1970 +0000
52 52 summary: clear branch name
53 53
54 Merging and branches
54 55
55 56 $ hg co foo
56 57 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
57 58 $ hg branch
58 59 foo
60
61 set existing branch name fails unless force - setting existing parent branch works without force:
62
63 $ hg branch bar
64 abort: a branch of the same name already exists
65 (use 'hg update' to switch to it)
66 [255]
67
68 $ hg branch -f bar
69 marked working directory as branch bar
70 (branches are permanent and global, did you want a bookmark?)
71
72 $ hg branch foo
73 marked working directory as branch foo
74 (branches are permanent and global, did you want a bookmark?)
75
59 76 $ echo bleah > a
60 77 $ hg ci -m "modify a branch"
61 78
62 79 $ hg merge default
63 80 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
64 81 (branch merge, don't forget to commit)
65 82
66 83 $ hg branch
67 84 foo
85
86 set existing branch name where branch head is ancestor:
87
88 $ hg branch bar
89 abort: a branch of the same name already exists
90 (use 'hg update' to switch to it)
91 [255]
92
93 set (other) parent branch as branch name
94
95 $ hg branch default
96 marked working directory as branch default
97 (branches are permanent and global, did you want a bookmark?)
98
99 set (first) parent branch as branch name
100
101 $ hg branch foo
102 marked working directory as branch foo
103 (branches are permanent and global, did you want a bookmark?)
104
68 105 $ hg ci -m "merge"
69 106
70 $ hg log
71 changeset: 5:530046499edf
72 branch: foo
73 tag: tip
74 parent: 4:adf1a74a7f7b
75 parent: 3:1c28f494dae6
76 user: test
77 date: Thu Jan 01 00:00:00 1970 +0000
78 summary: merge
79
80 changeset: 4:adf1a74a7f7b
81 branch: foo
82 parent: 1:6c0e42da283a
83 user: test
84 date: Thu Jan 01 00:00:00 1970 +0000
85 summary: modify a branch
86
87 changeset: 3:1c28f494dae6
88 user: test
89 date: Thu Jan 01 00:00:00 1970 +0000
90 summary: clear branch name
91
92 changeset: 2:c21617b13b22
93 branch: bar
94 user: test
95 date: Thu Jan 01 00:00:00 1970 +0000
96 summary: change branch name
97
98 changeset: 1:6c0e42da283a
99 branch: foo
100 user: test
101 date: Thu Jan 01 00:00:00 1970 +0000
102 summary: add branch name
103
104 changeset: 0:db01e8ea3388
105 user: test
106 date: Thu Jan 01 00:00:00 1970 +0000
107 summary: initial
107 $ hg log -G -T '{rev}:{node|short} {branch} {desc}\n'
108 @ 5:530046499edf foo merge
109 |\
110 | o 4:adf1a74a7f7b foo modify a branch
111 | |
112 o | 3:1c28f494dae6 default clear branch name
113 | |
114 o | 2:c21617b13b22 bar change branch name
115 |/
116 o 1:6c0e42da283a foo add branch name
117 |
118 o 0:db01e8ea3388 default initial
108 119
109 120 $ hg branches
110 121 foo 5:530046499edf
111 122 default 3:1c28f494dae6 (inactive)
112 123 bar 2:c21617b13b22 (inactive)
113 124
114 125 $ hg branches -q
115 126 foo
116 127 default
117 128 bar
118 129
119 130 Test for invalid branch cache:
120 131
121 132 $ hg rollback
122 133 repository tip rolled back to revision 4 (undo commit)
123 134 working directory now based on revisions 4 and 3
124 135
125 136 $ cp ${branchcache}-served .hg/bc-invalid
126 137
127 138 $ hg log -r foo
128 139 changeset: 4:adf1a74a7f7b
129 140 branch: foo
130 141 tag: tip
131 142 parent: 1:6c0e42da283a
132 143 user: test
133 144 date: Thu Jan 01 00:00:00 1970 +0000
134 145 summary: modify a branch
135 146
136 147 $ cp .hg/bc-invalid $branchcache
137 148
138 149 $ hg --debug log -r foo
139 150 changeset: 4:adf1a74a7f7b4cd193d12992f5d0d6a004ed21d6
140 151 branch: foo
141 152 tag: tip
142 153 phase: draft
143 154 parent: 1:6c0e42da283a56b5edc5b4fadb491365ec7f5fa8
144 155 parent: -1:0000000000000000000000000000000000000000
145 156 manifest: 1:8c342a37dfba0b3d3ce073562a00d8a813c54ffe
146 157 user: test
147 158 date: Thu Jan 01 00:00:00 1970 +0000
148 159 files: a
149 160 extra: branch=foo
150 161 description:
151 162 modify a branch
152 163
153 164
154 165 $ purgebranchcaches
155 166 $ echo corrupted > $branchcache
156 167
157 168 $ hg log -qr foo
158 169 4:adf1a74a7f7b
159 170
160 171 $ listbranchcaches
161 172 === .hg/cache/branch2 ===
162 173 corrupted
163 174 === .hg/cache/branch2-served ===
164 175 adf1a74a7f7b4cd193d12992f5d0d6a004ed21d6 4
165 176 c21617b13b220988e7a2e26290fbe4325ffa7139 o bar
166 177 1c28f494dae69a2f8fc815059d257eccf3fcfe75 o default
167 178 adf1a74a7f7b4cd193d12992f5d0d6a004ed21d6 o foo
168 179
169 180 Push should update the branch cache:
170 181
171 182 $ hg init ../target
172 183
173 184 Pushing just rev 0:
174 185
175 186 $ hg push -qr 0 ../target
176 187
177 188 $ (cd ../target/; listbranchcaches)
178 189 === .hg/cache/branch2-base ===
179 190 db01e8ea3388fd3c7c94e1436ea2bd6a53d581c5 0
180 191 db01e8ea3388fd3c7c94e1436ea2bd6a53d581c5 o default
181 192
182 193 Pushing everything:
183 194
184 195 $ hg push -qf ../target
185 196
186 197 $ (cd ../target/; listbranchcaches)
187 198 === .hg/cache/branch2-base ===
188 199 adf1a74a7f7b4cd193d12992f5d0d6a004ed21d6 4
189 200 c21617b13b220988e7a2e26290fbe4325ffa7139 o bar
190 201 1c28f494dae69a2f8fc815059d257eccf3fcfe75 o default
191 202 adf1a74a7f7b4cd193d12992f5d0d6a004ed21d6 o foo
192 203
193 204 Update with no arguments: tipmost revision of the current branch:
194 205
195 206 $ hg up -q -C 0
196 207 $ hg up -q
197 208 $ hg id
198 209 1c28f494dae6
199 210
200 211 $ hg up -q 1
201 212 $ hg up -q
202 213 $ hg id
203 214 adf1a74a7f7b (foo) tip
204 215
205 216 $ hg branch foobar
206 217 marked working directory as branch foobar
207 218 (branches are permanent and global, did you want a bookmark?)
208 219
209 220 $ hg up
210 221 abort: branch foobar not found
211 222 [255]
212 223
213 224 Fast-forward merge:
214 225
215 226 $ hg branch ff
216 227 marked working directory as branch ff
217 228 (branches are permanent and global, did you want a bookmark?)
218 229
219 230 $ echo ff > ff
220 231 $ hg ci -Am'fast forward'
221 232 adding ff
222 233
223 234 $ hg up foo
224 235 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
225 236
226 237 $ hg merge ff
227 238 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
228 239 (branch merge, don't forget to commit)
229 240
230 241 $ hg branch
231 242 foo
232 243 $ hg commit -m'Merge ff into foo'
233 244 $ hg parents
234 245 changeset: 6:185ffbfefa30
235 246 branch: foo
236 247 tag: tip
237 248 parent: 4:adf1a74a7f7b
238 249 parent: 5:1a3c27dc5e11
239 250 user: test
240 251 date: Thu Jan 01 00:00:00 1970 +0000
241 252 summary: Merge ff into foo
242 253
243 254 $ hg manifest
244 255 a
245 256 ff
246 257
247 258
248 259 Test merging, add 3 default heads and one test head:
249 260
250 261 $ cd ..
251 262 $ hg init merges
252 263 $ cd merges
253 264 $ echo a > a
254 265 $ hg ci -Ama
255 266 adding a
256 267
257 268 $ echo b > b
258 269 $ hg ci -Amb
259 270 adding b
260 271
261 272 $ hg up 0
262 273 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
263 274 $ echo c > c
264 275 $ hg ci -Amc
265 276 adding c
266 277 created new head
267 278
268 279 $ hg up 0
269 280 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
270 281 $ echo d > d
271 282 $ hg ci -Amd
272 283 adding d
273 284 created new head
274 285
275 286 $ hg up 0
276 287 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
277 288 $ hg branch test
278 289 marked working directory as branch test
279 290 (branches are permanent and global, did you want a bookmark?)
280 291 $ echo e >> e
281 292 $ hg ci -Ame
282 293 adding e
283 294
284 295 $ hg log
285 296 changeset: 4:3a1e01ed1df4
286 297 branch: test
287 298 tag: tip
288 299 parent: 0:cb9a9f314b8b
289 300 user: test
290 301 date: Thu Jan 01 00:00:00 1970 +0000
291 302 summary: e
292 303
293 304 changeset: 3:980f7dc84c29
294 305 parent: 0:cb9a9f314b8b
295 306 user: test
296 307 date: Thu Jan 01 00:00:00 1970 +0000
297 308 summary: d
298 309
299 310 changeset: 2:d36c0562f908
300 311 parent: 0:cb9a9f314b8b
301 312 user: test
302 313 date: Thu Jan 01 00:00:00 1970 +0000
303 314 summary: c
304 315
305 316 changeset: 1:d2ae7f538514
306 317 user: test
307 318 date: Thu Jan 01 00:00:00 1970 +0000
308 319 summary: b
309 320
310 321 changeset: 0:cb9a9f314b8b
311 322 user: test
312 323 date: Thu Jan 01 00:00:00 1970 +0000
313 324 summary: a
314 325
315 326 Implicit merge with test branch as parent:
316 327
317 328 $ hg merge
318 329 abort: branch 'test' has one head - please merge with an explicit rev
319 330 (run 'hg heads' to see all heads)
320 331 [255]
321 332 $ hg up -C default
322 333 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
323 334
324 335 Implicit merge with default branch as parent:
325 336
326 337 $ hg merge
327 338 abort: branch 'default' has 3 heads - please merge with an explicit rev
328 339 (run 'hg heads .' to see heads)
329 340 [255]
330 341
331 342 3 branch heads, explicit merge required:
332 343
333 344 $ hg merge 2
334 345 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
335 346 (branch merge, don't forget to commit)
336 347 $ hg ci -m merge
337 348
338 349 2 branch heads, implicit merge works:
339 350
340 351 $ hg merge
341 352 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
342 353 (branch merge, don't forget to commit)
343 354
344 355 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now