Show More
@@ -1,392 +1,414 | |||
|
1 | 1 | # Construct the following history tree: |
|
2 | 2 | # |
|
3 | 3 | # @ 5:e1bb631146ca b1 |
|
4 | 4 | # | |
|
5 | 5 | # o 4:a4fdb3b883c4 0:b608b9236435 b1 |
|
6 | 6 | # | |
|
7 | 7 | # | o 3:4b57d2520816 1:44592833ba9f |
|
8 | 8 | # | | |
|
9 | 9 | # | | o 2:063f31070f65 |
|
10 | 10 | # | |/ |
|
11 | 11 | # | o 1:44592833ba9f |
|
12 | 12 | # |/ |
|
13 | 13 | # o 0:b608b9236435 |
|
14 | 14 | |
|
15 | 15 | $ mkdir b1 |
|
16 | 16 | $ cd b1 |
|
17 | 17 | $ hg init |
|
18 | 18 | $ echo foo > foo |
|
19 | 19 | $ echo zero > a |
|
20 | 20 | $ hg init sub |
|
21 | 21 | $ echo suba > sub/suba |
|
22 | 22 | $ hg --cwd sub ci -Am addsuba |
|
23 | 23 | adding suba |
|
24 | 24 | $ echo 'sub = sub' > .hgsub |
|
25 | 25 | $ hg ci -qAm0 |
|
26 | 26 | $ echo one > a ; hg ci -m1 |
|
27 | 27 | $ echo two > a ; hg ci -m2 |
|
28 | 28 | $ hg up -q 1 |
|
29 | 29 | $ echo three > a ; hg ci -qm3 |
|
30 | 30 | $ hg up -q 0 |
|
31 | 31 | $ hg branch -q b1 |
|
32 | 32 | $ echo four > a ; hg ci -qm4 |
|
33 | 33 | $ echo five > a ; hg ci -qm5 |
|
34 | 34 | |
|
35 | 35 | Initial repo state: |
|
36 | 36 | |
|
37 | 37 | $ hg log -G --template '{rev}:{node|short} {parents} {branches}\n' |
|
38 | 38 | @ 5:ff252e8273df b1 |
|
39 | 39 | | |
|
40 | 40 | o 4:d047485b3896 0:60829823a42a b1 |
|
41 | 41 | | |
|
42 | 42 | | o 3:6efa171f091b 1:0786582aa4b1 |
|
43 | 43 | | | |
|
44 | 44 | | | o 2:bd10386d478c |
|
45 | 45 | | |/ |
|
46 | 46 | | o 1:0786582aa4b1 |
|
47 | 47 | |/ |
|
48 | 48 | o 0:60829823a42a |
|
49 | 49 | |
|
50 | 50 | |
|
51 | 51 | Make sure update doesn't assume b1 is a repository if invoked from outside: |
|
52 | 52 | |
|
53 | 53 | $ cd .. |
|
54 | 54 | $ hg update b1 |
|
55 | 55 | abort: no repository found in '$TESTTMP' (.hg not found)! |
|
56 | 56 | [255] |
|
57 | 57 | $ cd b1 |
|
58 | 58 | |
|
59 | 59 | Test helper functions: |
|
60 | 60 | |
|
61 | 61 | $ revtest () { |
|
62 | 62 | > msg=$1 |
|
63 | 63 | > dirtyflag=$2 # 'clean', 'dirty' or 'dirtysub' |
|
64 | 64 | > startrev=$3 |
|
65 | 65 | > targetrev=$4 |
|
66 | 66 | > opt=$5 |
|
67 | 67 | > hg up -qC $startrev |
|
68 | 68 | > test $dirtyflag = dirty && echo dirty > foo |
|
69 | 69 | > test $dirtyflag = dirtysub && echo dirty > sub/suba |
|
70 | 70 | > hg up $opt $targetrev |
|
71 | 71 | > hg parent --template 'parent={rev}\n' |
|
72 | 72 | > hg stat -S |
|
73 | 73 | > } |
|
74 | 74 | |
|
75 | 75 | $ norevtest () { |
|
76 | 76 | > msg=$1 |
|
77 | 77 | > dirtyflag=$2 # 'clean', 'dirty' or 'dirtysub' |
|
78 | 78 | > startrev=$3 |
|
79 | 79 | > opt=$4 |
|
80 | 80 | > hg up -qC $startrev |
|
81 | 81 | > test $dirtyflag = dirty && echo dirty > foo |
|
82 | 82 | > test $dirtyflag = dirtysub && echo dirty > sub/suba |
|
83 | 83 | > hg up $opt |
|
84 | 84 | > hg parent --template 'parent={rev}\n' |
|
85 | 85 | > hg stat -S |
|
86 | 86 | > } |
|
87 | 87 | |
|
88 | 88 | Test cases are documented in a table in the update function of merge.py. |
|
89 | 89 | Cases are run as shown in that table, row by row. |
|
90 | 90 | |
|
91 | 91 | $ norevtest 'none clean linear' clean 4 |
|
92 | 92 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
93 | 93 | parent=5 |
|
94 | 94 | |
|
95 | 95 | $ norevtest 'none clean same' clean 2 |
|
96 | 96 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
97 | 97 | 1 other heads for branch "default" |
|
98 | 98 | parent=2 |
|
99 | 99 | |
|
100 | 100 | |
|
101 | 101 | $ revtest 'none clean linear' clean 1 2 |
|
102 | 102 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
103 | 103 | parent=2 |
|
104 | 104 | |
|
105 | 105 | $ revtest 'none clean same' clean 2 3 |
|
106 | 106 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
107 | 107 | parent=3 |
|
108 | 108 | |
|
109 | 109 | $ revtest 'none clean cross' clean 3 4 |
|
110 | 110 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
111 | 111 | parent=4 |
|
112 | 112 | |
|
113 | 113 | |
|
114 | 114 | $ revtest 'none dirty linear' dirty 1 2 |
|
115 | 115 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
116 | 116 | parent=2 |
|
117 | 117 | M foo |
|
118 | 118 | |
|
119 | 119 | $ revtest 'none dirtysub linear' dirtysub 1 2 |
|
120 | 120 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
121 | 121 | parent=2 |
|
122 | 122 | M sub/suba |
|
123 | 123 | |
|
124 | 124 | $ revtest 'none dirty same' dirty 2 3 |
|
125 | 125 | abort: uncommitted changes |
|
126 | 126 | (commit or update --clean to discard changes) |
|
127 | 127 | parent=2 |
|
128 | 128 | M foo |
|
129 | 129 | |
|
130 | 130 | $ revtest 'none dirtysub same' dirtysub 2 3 |
|
131 | 131 | abort: uncommitted changes |
|
132 | 132 | (commit or update --clean to discard changes) |
|
133 | 133 | parent=2 |
|
134 | 134 | M sub/suba |
|
135 | 135 | |
|
136 | 136 | $ revtest 'none dirty cross' dirty 3 4 |
|
137 | 137 | abort: uncommitted changes |
|
138 | 138 | (commit or update --clean to discard changes) |
|
139 | 139 | parent=3 |
|
140 | 140 | M foo |
|
141 | 141 | |
|
142 | 142 | $ norevtest 'none dirty cross' dirty 2 |
|
143 | 143 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
144 | 144 | 1 other heads for branch "default" |
|
145 | 145 | parent=2 |
|
146 | 146 | M foo |
|
147 | 147 | |
|
148 | 148 | $ revtest 'none dirtysub cross' dirtysub 3 4 |
|
149 | 149 | abort: uncommitted changes |
|
150 | 150 | (commit or update --clean to discard changes) |
|
151 | 151 | parent=3 |
|
152 | 152 | M sub/suba |
|
153 | 153 | |
|
154 | 154 | $ revtest '-C dirty linear' dirty 1 2 -C |
|
155 | 155 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
156 | 156 | parent=2 |
|
157 | 157 | |
|
158 | 158 | $ revtest '-c dirty linear' dirty 1 2 -c |
|
159 | 159 | abort: uncommitted changes |
|
160 | 160 | parent=1 |
|
161 | 161 | M foo |
|
162 | 162 | |
|
163 | 163 | $ revtest '-c dirtysub linear' dirtysub 1 2 -c |
|
164 | 164 | abort: uncommitted changes in subrepository 'sub' |
|
165 | 165 | parent=1 |
|
166 | 166 | M sub/suba |
|
167 | 167 | |
|
168 | 168 | $ norevtest '-c clean same' clean 2 -c |
|
169 | 169 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
170 | 170 | 1 other heads for branch "default" |
|
171 | 171 | parent=2 |
|
172 | 172 | |
|
173 | 173 | $ revtest '-cC dirty linear' dirty 1 2 -cC |
|
174 | 174 | abort: cannot specify both -c/--check and -C/--clean |
|
175 | 175 | parent=1 |
|
176 | 176 | M foo |
|
177 | 177 | |
|
178 | 178 | $ cd .. |
|
179 | 179 | |
|
180 | Test updating to null revision | |
|
181 | ||
|
182 | $ hg init null-repo | |
|
183 | $ cd null-repo | |
|
184 | $ echo a > a | |
|
185 | $ hg add a | |
|
186 | $ hg ci -m a | |
|
187 | $ hg up -qC 0 | |
|
188 | $ echo b > b | |
|
189 | $ hg add b | |
|
190 | $ hg up null | |
|
191 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
|
192 | $ hg st | |
|
193 | A b | |
|
194 | $ hg up -q 0 | |
|
195 | $ hg st | |
|
196 | A b | |
|
197 | $ hg up -qC null | |
|
198 | $ hg st | |
|
199 | ? b | |
|
200 | $ cd .. | |
|
201 | ||
|
180 | 202 | Test updating with closed head |
|
181 | 203 | --------------------------------------------------------------------- |
|
182 | 204 | |
|
183 | 205 | $ hg clone -U -q b1 closed-heads |
|
184 | 206 | $ cd closed-heads |
|
185 | 207 | |
|
186 | 208 | Test updating if at least one non-closed branch head exists |
|
187 | 209 | |
|
188 | 210 | if on the closed branch head: |
|
189 | 211 | - update to "." |
|
190 | 212 | - "updated to a closed branch head ...." message is displayed |
|
191 | 213 | - "N other heads for ...." message is displayed |
|
192 | 214 | |
|
193 | 215 | $ hg update -q -C 3 |
|
194 | 216 | $ hg commit --close-branch -m 6 |
|
195 | 217 | $ norevtest "on closed branch head" clean 6 |
|
196 | 218 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
197 | 219 | no open descendant heads on branch "default", updating to a closed head |
|
198 | 220 | (committing will reopen the head, use 'hg heads .' to see 1 other heads) |
|
199 | 221 | parent=6 |
|
200 | 222 | |
|
201 | 223 | if descendant non-closed branch head exists, and it is only one branch head: |
|
202 | 224 | - update to it, even if its revision is less than closed one |
|
203 | 225 | - "N other heads for ...." message isn't displayed |
|
204 | 226 | |
|
205 | 227 | $ norevtest "non-closed 2 should be chosen" clean 1 |
|
206 | 228 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
207 | 229 | parent=2 |
|
208 | 230 | |
|
209 | 231 | if all descendant branch heads are closed, but there is another branch head: |
|
210 | 232 | - update to the tipmost descendant head |
|
211 | 233 | - "updated to a closed branch head ...." message is displayed |
|
212 | 234 | - "N other heads for ...." message is displayed |
|
213 | 235 | |
|
214 | 236 | $ norevtest "all descendant branch heads are closed" clean 3 |
|
215 | 237 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
216 | 238 | no open descendant heads on branch "default", updating to a closed head |
|
217 | 239 | (committing will reopen the head, use 'hg heads .' to see 1 other heads) |
|
218 | 240 | parent=6 |
|
219 | 241 | |
|
220 | 242 | Test updating if all branch heads are closed |
|
221 | 243 | |
|
222 | 244 | if on the closed branch head: |
|
223 | 245 | - update to "." |
|
224 | 246 | - "updated to a closed branch head ...." message is displayed |
|
225 | 247 | - "all heads of branch ...." message is displayed |
|
226 | 248 | |
|
227 | 249 | $ hg update -q -C 2 |
|
228 | 250 | $ hg commit --close-branch -m 7 |
|
229 | 251 | $ norevtest "all heads of branch default are closed" clean 6 |
|
230 | 252 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
231 | 253 | no open descendant heads on branch "default", updating to a closed head |
|
232 | 254 | (committing will reopen branch "default") |
|
233 | 255 | parent=6 |
|
234 | 256 | |
|
235 | 257 | if not on the closed branch head: |
|
236 | 258 | - update to the tipmost descendant (closed) head |
|
237 | 259 | - "updated to a closed branch head ...." message is displayed |
|
238 | 260 | - "all heads of branch ...." message is displayed |
|
239 | 261 | |
|
240 | 262 | $ norevtest "all heads of branch default are closed" clean 1 |
|
241 | 263 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
242 | 264 | no open descendant heads on branch "default", updating to a closed head |
|
243 | 265 | (committing will reopen branch "default") |
|
244 | 266 | parent=7 |
|
245 | 267 | |
|
246 | 268 | $ cd .. |
|
247 | 269 | |
|
248 | 270 | Test updating if "default" branch doesn't exist and no revision is |
|
249 | 271 | checked out (= "default" is used as current branch) |
|
250 | 272 | |
|
251 | 273 | $ hg init no-default-branch |
|
252 | 274 | $ cd no-default-branch |
|
253 | 275 | |
|
254 | 276 | $ hg branch foobar |
|
255 | 277 | marked working directory as branch foobar |
|
256 | 278 | (branches are permanent and global, did you want a bookmark?) |
|
257 | 279 | $ echo a > a |
|
258 | 280 | $ hg commit -m "#0" -A |
|
259 | 281 | adding a |
|
260 | 282 | $ echo 1 >> a |
|
261 | 283 | $ hg commit -m "#1" |
|
262 | 284 | $ hg update -q 0 |
|
263 | 285 | $ echo 3 >> a |
|
264 | 286 | $ hg commit -m "#2" |
|
265 | 287 | created new head |
|
266 | 288 | $ hg commit --close-branch -m "#3" |
|
267 | 289 | |
|
268 | 290 | if there is at least one non-closed branch head: |
|
269 | 291 | - update to the tipmost branch head |
|
270 | 292 | |
|
271 | 293 | $ norevtest "non-closed 1 should be chosen" clean null |
|
272 | 294 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
273 | 295 | parent=1 |
|
274 | 296 | |
|
275 | 297 | if all branch heads are closed |
|
276 | 298 | - update to "tip" |
|
277 | 299 | - "updated to a closed branch head ...." message is displayed |
|
278 | 300 | - "all heads for branch "XXXX" are closed" message is displayed |
|
279 | 301 | |
|
280 | 302 | $ hg update -q -C 1 |
|
281 | 303 | $ hg commit --close-branch -m "#4" |
|
282 | 304 | |
|
283 | 305 | $ norevtest "all branches are closed" clean null |
|
284 | 306 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
285 | 307 | no open descendant heads on branch "foobar", updating to a closed head |
|
286 | 308 | (committing will reopen branch "foobar") |
|
287 | 309 | parent=4 |
|
288 | 310 | |
|
289 | 311 | $ cd ../b1 |
|
290 | 312 | |
|
291 | 313 | Test obsolescence behavior |
|
292 | 314 | --------------------------------------------------------------------- |
|
293 | 315 | |
|
294 | 316 | successors should be taken in account when checking head destination |
|
295 | 317 | |
|
296 | 318 | $ cat << EOF >> $HGRCPATH |
|
297 | 319 | > [ui] |
|
298 | 320 | > logtemplate={rev}:{node|short} {desc|firstline} |
|
299 | 321 | > [experimental] |
|
300 | 322 | > evolution=createmarkers |
|
301 | 323 | > EOF |
|
302 | 324 | |
|
303 | 325 | Test no-argument update to a successor of an obsoleted changeset |
|
304 | 326 | |
|
305 | 327 | $ hg log -G |
|
306 | 328 | o 5:ff252e8273df 5 |
|
307 | 329 | | |
|
308 | 330 | o 4:d047485b3896 4 |
|
309 | 331 | | |
|
310 | 332 | | o 3:6efa171f091b 3 |
|
311 | 333 | | | |
|
312 | 334 | | | o 2:bd10386d478c 2 |
|
313 | 335 | | |/ |
|
314 | 336 | | @ 1:0786582aa4b1 1 |
|
315 | 337 | |/ |
|
316 | 338 | o 0:60829823a42a 0 |
|
317 | 339 | |
|
318 | 340 | $ hg book bm -r 3 |
|
319 | 341 | $ hg status |
|
320 | 342 | M foo |
|
321 | 343 | |
|
322 | 344 | We add simple obsolescence marker between 3 and 4 (indirect successors) |
|
323 | 345 | |
|
324 | 346 | $ hg id --debug -i -r 3 |
|
325 | 347 | 6efa171f091b00a3c35edc15d48c52a498929953 |
|
326 | 348 | $ hg id --debug -i -r 4 |
|
327 | 349 | d047485b3896813b2a624e86201983520f003206 |
|
328 | 350 | $ hg debugobsolete 6efa171f091b00a3c35edc15d48c52a498929953 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
|
329 | 351 | $ hg debugobsolete aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa d047485b3896813b2a624e86201983520f003206 |
|
330 | 352 | |
|
331 | 353 | Test that 5 is detected as a valid destination from 3 and also accepts moving |
|
332 | 354 | the bookmark (issue4015) |
|
333 | 355 | |
|
334 | 356 | $ hg up --quiet --hidden 3 |
|
335 | 357 | $ hg up 5 |
|
336 | 358 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
337 | 359 | $ hg book bm |
|
338 | 360 | moving bookmark 'bm' forward from 6efa171f091b |
|
339 | 361 | $ hg bookmarks |
|
340 | 362 | * bm 5:ff252e8273df |
|
341 | 363 | |
|
342 | 364 | Test that 4 is detected as the no-argument destination from 3 and also moves |
|
343 | 365 | the bookmark with it |
|
344 | 366 | $ hg up --quiet 0 # we should be able to update to 3 directly |
|
345 | 367 | $ hg up --quiet --hidden 3 # but not implemented yet. |
|
346 | 368 | $ hg book -f bm |
|
347 | 369 | $ hg up |
|
348 | 370 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
349 | 371 | updating bookmark bm |
|
350 | 372 | $ hg book |
|
351 | 373 | * bm 4:d047485b3896 |
|
352 | 374 | |
|
353 | 375 | Test that 5 is detected as a valid destination from 1 |
|
354 | 376 | $ hg up --quiet 0 # we should be able to update to 3 directly |
|
355 | 377 | $ hg up --quiet --hidden 3 # but not implemented yet. |
|
356 | 378 | $ hg up 5 |
|
357 | 379 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
358 | 380 | |
|
359 | 381 | Test that 5 is not detected as a valid destination from 2 |
|
360 | 382 | $ hg up --quiet 0 |
|
361 | 383 | $ hg up --quiet 2 |
|
362 | 384 | $ hg up 5 |
|
363 | 385 | abort: uncommitted changes |
|
364 | 386 | (commit or update --clean to discard changes) |
|
365 | 387 | [255] |
|
366 | 388 | |
|
367 | 389 | Test that we don't crash when updating from a pruned changeset (i.e. has no |
|
368 | 390 | successors). Behavior should probably be that we update to the first |
|
369 | 391 | non-obsolete parent but that will be decided later. |
|
370 | 392 | $ hg id --debug -r 2 |
|
371 | 393 | bd10386d478cd5a9faf2e604114c8e6da62d3889 |
|
372 | 394 | $ hg up --quiet 0 |
|
373 | 395 | $ hg up --quiet 2 |
|
374 | 396 | $ hg debugobsolete bd10386d478cd5a9faf2e604114c8e6da62d3889 |
|
375 | 397 | $ hg up |
|
376 | 398 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
377 | 399 | |
|
378 | 400 | Test experimental revset support |
|
379 | 401 | |
|
380 | 402 | $ hg log -r '_destupdate()' |
|
381 | 403 | 2:bd10386d478c 2 (no-eol) |
|
382 | 404 | |
|
383 | 405 | Test that boolean flags allow --no-flag specification to override [defaults] |
|
384 | 406 | $ cat >> $HGRCPATH <<EOF |
|
385 | 407 | > [defaults] |
|
386 | 408 | > update = --check |
|
387 | 409 | > EOF |
|
388 | 410 | $ hg co 2 |
|
389 | 411 | abort: uncommitted changes |
|
390 | 412 | [255] |
|
391 | 413 | $ hg co --no-check 2 |
|
392 | 414 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
General Comments 0
You need to be logged in to leave comments.
Login now