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