Debian Codegraph @

tests/test-graft.t

raw
1 $ cat >> $HGRCPATH <<EOF
2 > [extdiff]
3 > # for portability:
4 > pdiff = sh "$RUNTESTDIR/pdiff"
5 > EOF
6
7 Create a repo with some stuff in it:
8
9 $ hg init a
10 $ cd a
11 $ echo a > a
12 $ echo a > d
13 $ echo a > e
14 $ hg ci -qAm0
15 $ echo b > a
16 $ hg ci -m1 -u bar
17 $ hg mv a b
18 $ hg ci -m2
19 $ hg cp b c
20 $ hg ci -m3 -u baz
21 $ echo b > d
22 $ echo f > e
23 $ hg ci -m4
24 $ hg up -q 3
25 $ echo b > e
26 $ hg branch -q stable
27 $ hg ci -m5
28 $ hg merge -q default --tool internal:local # for conflicts in e, choose 5 and ignore 4
29 $ hg branch -q default
30 $ hg ci -m6
31 $ hg phase --public 3
32 $ hg phase --force --secret 6
33
34 $ hg log -G --template '{author}@{rev}.{phase}: {desc}\n'
35 @ [email protected]: 6
36 |\
37 | o [email protected]: 5
38 | |
39 o | [email protected]: 4
40 |/
41 o [email protected]: 3
42 |
43 o [email protected]: 2
44 |
45 o [email protected]: 1
46 |
47 o [email protected]: 0
48
49 Test --base for grafting the merge of 4 from the perspective of 5, thus only getting the change to d
50
51 $ hg up -cqr 3
52 $ hg graft -r 6 --base 5
53 grafting 6:25a2b029d3ae "6" (tip)
54 merging e
55 $ hg st --change .
56 M d
57
58 $ hg -q strip . --config extensions.strip=
59
60 Test --base for collapsing changesets 2 and 3, thus getting both b and c
61
62 $ hg up -cqr 0
63 $ hg graft -r 3 --base 1
64 grafting 3:4c60f11aa304 "3"
65 merging a and b to b
66 merging a and c to c
67 $ hg st --change .
68 A b
69 A c
70 R a
71
72 $ hg -q strip . --config extensions.strip=
73
74 Specifying child as --base revision fails safely (perhaps slightly confusing, but consistent)
75
76 $ hg graft -r 2 --base 3
77 grafting 2:5c095ad7e90f "2"
78 note: possible conflict - c was deleted and renamed to:
79 a
80 note: graft of 2:5c095ad7e90f created no changes to commit
81
82 Can't continue without starting:
83
84 $ hg -q up -cr tip
85 $ hg rm -q e
86 $ hg graft --continue
87 abort: no graft in progress
88 [20]
89 $ hg revert -r . -q e
90
91 Need to specify a rev:
92
93 $ hg graft
94 abort: no revisions specified
95 [10]
96
97 Can't graft ancestor:
98
99 $ hg graft 1 2
100 skipping ancestor revision 1:5d205f8b35b6
101 skipping ancestor revision 2:5c095ad7e90f
102 [255]
103
104 Specify revisions with -r:
105
106 $ hg graft -r 1 -r 2
107 skipping ancestor revision 1:5d205f8b35b6
108 skipping ancestor revision 2:5c095ad7e90f
109 [255]
110
111 $ hg graft -r 1 2
112 warning: inconsistent use of --rev might give unexpected revision ordering!
113 skipping ancestor revision 2:5c095ad7e90f
114 skipping ancestor revision 1:5d205f8b35b6
115 [255]
116
117 Conflicting date/user options:
118
119 $ hg up -q 0
120 $ hg graft -U --user foo 2
121 abort: cannot specify both --user and --currentuser
122 [10]
123 $ hg graft -D --date '0 0' 2
124 abort: cannot specify both --date and --currentdate
125 [10]
126
127 Can't graft with dirty wd:
128
129 $ hg up -q 0
130 $ echo foo > a
131 $ hg graft 1
132 abort: uncommitted changes
133 [20]
134 $ hg revert a
135
136 Graft a rename:
137 (this also tests that editor is invoked if '--edit' is specified)
138
139 $ hg status --rev "2^1" --rev 2
140 A b
141 R a
142 $ HGEDITOR=cat hg graft 2 -u foo --edit
143 grafting 2:5c095ad7e90f "2"
144 merging a and b to b
145 2
146
147
148 HG: Enter commit message. Lines beginning with 'HG:' are removed.
149 HG: Leave message empty to abort commit.
150 HG: --
151 HG: user: foo
152 HG: branch 'default'
153 HG: added b
154 HG: removed a
155 $ hg export tip --git
156 # HG changeset patch
157 # User foo
158 # Date 0 0
159 # Thu Jan 01 00:00:00 1970 +0000
160 # Node ID ef0ef43d49e79e81ddafdc7997401ba0041efc82
161 # Parent 68795b066622ca79a25816a662041d8f78f3cd9e
162 2
163
164 diff --git a/a b/b
165 rename from a
166 rename to b
167
168 Look for extra:source
169
170 $ hg log --debug -r tip
171 changeset: 7:ef0ef43d49e79e81ddafdc7997401ba0041efc82
172 tag: tip
173 phase: draft
174 parent: 0:68795b066622ca79a25816a662041d8f78f3cd9e
175 parent: -1:0000000000000000000000000000000000000000
176 manifest: 7:e59b6b228f9cbf9903d5e9abf996e083a1f533eb
177 user: foo
178 date: Thu Jan 01 00:00:00 1970 +0000
179 files+: b
180 files-: a
181 extra: branch=default
182 extra: source=5c095ad7e90f871700f02dd1fa5012cb4498a2d4
183 description:
184 2
185
186
187
188 Graft out of order, skipping a merge and a duplicate
189 (this also tests that editor is not invoked if '--edit' is not specified)
190
191 $ hg graft 1 5 4 3 'merge()' 2 -n
192 skipping ungraftable merge revision 6
193 skipping revision 2:5c095ad7e90f (already grafted to 7:ef0ef43d49e7)
194 grafting 1:5d205f8b35b6 "1"
195 grafting 5:97f8bfe72746 "5"
196 grafting 4:9c233e8e184d "4"
197 grafting 3:4c60f11aa304 "3"
198
199 $ HGEDITOR=cat hg graft 1 5 'merge()' 2 --debug
200 skipping ungraftable merge revision 6
201 scanning for duplicate grafts
202 skipping revision 2:5c095ad7e90f (already grafted to 7:ef0ef43d49e7)
203 grafting 1:5d205f8b35b6 "1"
204 unmatched files in local:
205 b
206 all copies found (* = to merge, ! = divergent, % = renamed and deleted):
207 on local side:
208 src: 'a' -> dst: 'b' *
209 checking for directory renames
210 resolving manifests
211 branchmerge: True, force: True, partial: False
212 ancestor: 68795b066622, local: ef0ef43d49e7+, remote: 5d205f8b35b6
213 starting 4 threads for background file closing (?)
214 preserving b for resolve of b
215 b: local copied/moved from a -> m
216 picked tool ':merge' for b (binary False symlink False changedelete False)
217 merging b and a to b
218 my b@ef0ef43d49e7+ other a@5d205f8b35b6 ancestor a@68795b066622
219 premerge successful
220 committing files:
221 b
222 committing manifest
223 committing changelog
224 updating the branch cache
225 grafting 5:97f8bfe72746 "5"
226 resolving manifests
227 branchmerge: True, force: True, partial: False
228 ancestor: 4c60f11aa304, local: 6b9e5368ca4e+, remote: 97f8bfe72746
229 e: remote is newer -> g
230 getting e
231 committing files:
232 e
233 committing manifest
234 committing changelog
235 updating the branch cache
236 $ HGEDITOR=cat hg graft 4 3 --log --debug
237 scanning for duplicate grafts
238 grafting 4:9c233e8e184d "4"
239 resolving manifests
240 branchmerge: True, force: True, partial: False
241 ancestor: 4c60f11aa304, local: 1905859650ec+, remote: 9c233e8e184d
242 d: remote is newer -> g
243 getting d
244 preserving e for resolve of e
245 e: versions differ -> m
246 picked tool ':merge' for e (binary False symlink False changedelete False)
247 merging e
248 my e@1905859650ec+ other e@9c233e8e184d ancestor e@4c60f11aa304
249 warning: conflicts while merging e! (edit, then use 'hg resolve --mark')
250 abort: unresolved conflicts, can't continue
251 (use 'hg resolve' and 'hg graft --continue')
252 [1]
253
254 Summary should mention graft:
255
256 $ hg summary |grep graft
257 commit: 2 modified, 2 unknown, 1 unresolved (graft in progress)
258
259 Using status to get more context
260
261 $ hg status --verbose
262 M d
263 M e
264 ? a.orig
265 ? e.orig
266 # The repository is in an unfinished *graft* state.
267
268 # Unresolved merge conflicts:
269 #
270 # e
271 #
272 # To mark files as resolved: hg resolve --mark FILE
273
274 # To continue: hg graft --continue
275 # To abort: hg graft --abort
276 # To stop: hg graft --stop
277
278
279 Commit while interrupted should fail:
280
281 $ hg ci -m 'commit interrupted graft'
282 abort: graft in progress
283 (use 'hg graft --continue' or 'hg graft --stop' to stop)
284 [20]
285
286 Abort the graft and try committing:
287
288 $ hg up -C .
289 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
290 $ echo c >> e
291 $ hg ci -mtest
292
293 $ hg strip . --config extensions.strip=
294 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
295 saved backup bundle to $TESTTMP/a/.hg/strip-backup/*-backup.hg (glob)
296
297 Graft again:
298
299 $ hg graft 1 5 4 3 'merge()' 2
300 skipping ungraftable merge revision 6
301 skipping revision 2:5c095ad7e90f (already grafted to 7:ef0ef43d49e7)
302 skipping revision 1:5d205f8b35b6 (already grafted to 8:6b9e5368ca4e)
303 skipping revision 5:97f8bfe72746 (already grafted to 9:1905859650ec)
304 grafting 4:9c233e8e184d "4"
305 merging e
306 warning: conflicts while merging e! (edit, then use 'hg resolve --mark')
307 abort: unresolved conflicts, can't continue
308 (use 'hg resolve' and 'hg graft --continue')
309 [1]
310
311 Continue without resolve should fail:
312
313 $ hg graft -c
314 grafting 4:9c233e8e184d "4"
315 abort: unresolved merge conflicts (see 'hg help resolve')
316 [20]
317
318 Fix up:
319
320 $ echo b > e
321 $ hg resolve -m e
322 (no more unresolved files)
323 continue: hg graft --continue
324
325 Continue with a revision should fail:
326
327 $ hg graft -c 6
328 abort: can't specify --continue and revisions
329 [10]
330
331 $ hg graft -c -r 6
332 abort: can't specify --continue and revisions
333 [10]
334
335 Continue for real, clobber usernames
336
337 $ hg graft -c -U
338 grafting 4:9c233e8e184d "4"
339 grafting 3:4c60f11aa304 "3"
340
341 Compare with original:
342
343 $ hg diff -r 6
344 $ hg status --rev 0:. -C
345 M d
346 M e
347 A b
348 a
349 A c
350 a
351 R a
352
353 View graph:
354
355 $ hg log -G --template '{author}@{rev}.{phase}: {desc}\n'
356 @ [email protected]: 3
357 |
358 o [email protected]: 4
359 |
360 o [email protected]: 5
361 |
362 o [email protected]: 1
363 |
364 o [email protected]: 2
365 |
366 | o [email protected]: 6
367 | |\
368 | | o [email protected]: 5
369 | | |
370 | o | [email protected]: 4
371 | |/
372 | o [email protected]: 3
373 | |
374 | o [email protected]: 2
375 | |
376 | o [email protected]: 1
377 |/
378 o [email protected]: 0
379
380 Graft again onto another branch should preserve the original source
381 $ hg up -q 0
382 $ echo 'g'>g
383 $ hg add g
384 $ hg ci -m 7
385 created new head
386 $ hg graft 7
387 grafting 7:ef0ef43d49e7 "2"
388
389 $ hg log -r 7 --template '{rev}:{node}\n'
390 7:ef0ef43d49e79e81ddafdc7997401ba0041efc82
391 $ hg log -r 2 --template '{rev}:{node}\n'
392 2:5c095ad7e90f871700f02dd1fa5012cb4498a2d4
393
394 $ hg log --debug -r tip
395 changeset: 13:7a4785234d87ec1aa420ed6b11afe40fa73e12a9
396 tag: tip
397 phase: draft
398 parent: 12:b592ea63bb0c19a6c5c44685ee29a2284f9f1b8f
399 parent: -1:0000000000000000000000000000000000000000
400 manifest: 13:dc313617b8c32457c0d589e0dbbedfe71f3cd637
401 user: foo
402 date: Thu Jan 01 00:00:00 1970 +0000
403 files+: b
404 files-: a
405 extra: branch=default
406 extra: intermediate-source=ef0ef43d49e79e81ddafdc7997401ba0041efc82
407 extra: source=5c095ad7e90f871700f02dd1fa5012cb4498a2d4
408 description:
409 2
410
411
412 Disallow grafting an already grafted cset onto its original branch
413 $ hg up -q 6
414 $ hg graft 7
415 skipping already grafted revision 7:ef0ef43d49e7 (was grafted from 2:5c095ad7e90f)
416 [255]
417
418 $ hg pdiff --config extensions.extdiff= --patch -r 2 -r 13
419 --- */hg-5c095ad7e90f.patch * (glob)
420 +++ */hg-7a4785234d87.patch * (glob)
421 @@ -1,18 +1,18 @@
422 # HG changeset patch
423 -# User test
424 +# User foo
425 # Date 0 0
426 # Thu Jan 01 00:00:00 1970 +0000
427 -# Node ID 5c095ad7e90f871700f02dd1fa5012cb4498a2d4
428 -# Parent 5d205f8b35b66bc36375c9534ffd3237730e8f04
429 +# Node ID 7a4785234d87ec1aa420ed6b11afe40fa73e12a9
430 +# Parent b592ea63bb0c19a6c5c44685ee29a2284f9f1b8f
431 2
432
433 -diff -r 5d205f8b35b6 -r 5c095ad7e90f a
434 +diff -r b592ea63bb0c -r 7a4785234d87 a
435 --- a/a Thu Jan 01 00:00:00 1970 +0000
436 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
437 @@ -1,1 +0,0 @@
438 --b
439 -diff -r 5d205f8b35b6 -r 5c095ad7e90f b
440 +-a
441 +diff -r b592ea63bb0c -r 7a4785234d87 b
442 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
443 +++ b/b Thu Jan 01 00:00:00 1970 +0000
444 @@ -0,0 +1,1 @@
445 -+b
446 ++a
447 [1]
448
449 $ hg pdiff --config extensions.extdiff= --patch -r 2 -r 13 -X .
450 --- */hg-5c095ad7e90f.patch * (glob)
451 +++ */hg-7a4785234d87.patch * (glob)
452 @@ -1,8 +1,8 @@
453 # HG changeset patch
454 -# User test
455 +# User foo
456 # Date 0 0
457 # Thu Jan 01 00:00:00 1970 +0000
458 -# Node ID 5c095ad7e90f871700f02dd1fa5012cb4498a2d4
459 -# Parent 5d205f8b35b66bc36375c9534ffd3237730e8f04
460 +# Node ID 7a4785234d87ec1aa420ed6b11afe40fa73e12a9
461 +# Parent b592ea63bb0c19a6c5c44685ee29a2284f9f1b8f
462 2
463
464 [1]
465
466 Disallow grafting already grafted csets with the same origin onto each other
467 $ hg up -q 13
468 $ hg graft 2
469 skipping revision 2:5c095ad7e90f (already grafted to 13:7a4785234d87)
470 [255]
471 $ hg graft 7
472 skipping already grafted revision 7:ef0ef43d49e7 (13:7a4785234d87 also has origin 2:5c095ad7e90f)
473 [255]
474
475 $ hg up -q 7
476 $ hg graft 2
477 skipping revision 2:5c095ad7e90f (already grafted to 7:ef0ef43d49e7)
478 [255]
479 $ hg graft tip
480 skipping already grafted revision 13:7a4785234d87 (7:ef0ef43d49e7 also has origin 2:5c095ad7e90f)
481 [255]
482
483 Graft with --log
484
485 $ hg up -Cq 1
486 $ hg graft 3 --log -u foo
487 grafting 3:4c60f11aa304 "3"
488 $ hg log --template '{rev}:{node|short} {parents} {desc}\n' -r tip
489 14:0c921c65ef1e 1:5d205f8b35b6 3
490 (grafted from 4c60f11aa304a54ae1c199feb94e7fc771e51ed8)
491
492 Resolve conflicted graft
493 $ hg up -q 0
494 $ echo b > a
495 $ hg ci -m 8
496 created new head
497 $ echo c > a
498 $ hg ci -m 9
499 $ hg graft 1 --tool internal:fail
500 grafting 1:5d205f8b35b6 "1"
501 abort: unresolved conflicts, can't continue
502 (use 'hg resolve' and 'hg graft --continue')
503 [1]
504 $ hg resolve --all
505 merging a
506 warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
507 [1]
508 $ cat a
509 <<<<<<< local: aaa4406d4f0a - test: 9
510 c
511 =======
512 b
513 >>>>>>> graft: 5d205f8b35b6 - bar: 1
514 $ echo b > a
515 $ hg resolve -m a
516 (no more unresolved files)
517 continue: hg graft --continue
518 $ hg graft -c
519 grafting 1:5d205f8b35b6 "1"
520 $ hg export tip --git
521 # HG changeset patch
522 # User bar
523 # Date 0 0
524 # Thu Jan 01 00:00:00 1970 +0000
525 # Node ID f67661df0c4804d301f064f332b57e7d5ddaf2be
526 # Parent aaa4406d4f0ae9befd6e58c82ec63706460cbca6
527 1
528
529 diff --git a/a b/a
530 --- a/a
531 +++ b/a
532 @@ -1,1 +1,1 @@
533 -c
534 +b
535
536 Resolve conflicted graft with rename
537 $ echo c > a
538 $ hg ci -m 10
539 $ hg graft 2 --tool internal:fail
540 grafting 2:5c095ad7e90f "2"
541 abort: unresolved conflicts, can't continue
542 (use 'hg resolve' and 'hg graft --continue')
543 [1]
544 $ hg resolve --all
545 merging a and b to b
546 (no more unresolved files)
547 continue: hg graft --continue
548 $ hg graft -c
549 grafting 2:5c095ad7e90f "2"
550 $ hg export tip --git
551 # HG changeset patch
552 # User test
553 # Date 0 0
554 # Thu Jan 01 00:00:00 1970 +0000
555 # Node ID 9627f653b421c61fc1ea4c4e366745070fa3d2bc
556 # Parent ee295f490a40b97f3d18dd4c4f1c8936c233b612
557 2
558
559 diff --git a/a b/b
560 rename from a
561 rename to b
562
563 Test simple origin(), with and without args
564 $ hg log -r 'origin()'
565 changeset: 1:5d205f8b35b6
566 user: bar
567 date: Thu Jan 01 00:00:00 1970 +0000
568 summary: 1
569
570 changeset: 2:5c095ad7e90f
571 user: test
572 date: Thu Jan 01 00:00:00 1970 +0000
573 summary: 2
574
575 changeset: 3:4c60f11aa304
576 user: baz
577 date: Thu Jan 01 00:00:00 1970 +0000
578 summary: 3
579
580 changeset: 4:9c233e8e184d
581 user: test
582 date: Thu Jan 01 00:00:00 1970 +0000
583 summary: 4
584
585 changeset: 5:97f8bfe72746
586 branch: stable
587 parent: 3:4c60f11aa304
588 user: test
589 date: Thu Jan 01 00:00:00 1970 +0000
590 summary: 5
591
592 $ hg log -r 'origin(7)'
593 changeset: 2:5c095ad7e90f
594 user: test
595 date: Thu Jan 01 00:00:00 1970 +0000
596 summary: 2
597
598 Now transplant a graft to test following through copies
599 $ hg up -q 0
600 $ hg branch -q dev
601 $ hg ci -qm "dev branch"
602 $ hg --config extensions.transplant= transplant -q 7
603 $ hg log -r 'origin(.)'
604 changeset: 2:5c095ad7e90f
605 user: test
606 date: Thu Jan 01 00:00:00 1970 +0000
607 summary: 2
608
609 Test that the graft and transplant markers in extra are converted, allowing
610 origin() to still work. Note that these recheck the immediately preceeding two
611 tests.
612 $ hg --quiet --config extensions.convert= --config convert.hg.saverev=True convert . ../converted
613
614 The graft case
615 $ hg -R ../converted log -r 7 --template "{rev}: {node}\n{join(extras, '\n')}\n"
616 7: 7ae846e9111fc8f57745634250c7b9ac0a60689b
617 branch=default
618 convert_revision=ef0ef43d49e79e81ddafdc7997401ba0041efc82
619 source=e0213322b2c1a5d5d236c74e79666441bee67a7d
620 $ hg -R ../converted log -r 'origin(7)'
621 changeset: 2:e0213322b2c1
622 user: test
623 date: Thu Jan 01 00:00:00 1970 +0000
624 summary: 2
625
626 Test that template correctly expands more than one 'extra' (issue4362), and that
627 'intermediate-source' is converted.
628 $ hg -R ../converted log -r 13 --template "{extras % ' Extra: {extra}\n'}"
629 Extra: branch=default
630 Extra: convert_revision=7a4785234d87ec1aa420ed6b11afe40fa73e12a9
631 Extra: intermediate-source=7ae846e9111fc8f57745634250c7b9ac0a60689b
632 Extra: source=e0213322b2c1a5d5d236c74e79666441bee67a7d
633
634 The transplant case
635 $ hg -R ../converted log -r tip --template "{rev}: {node}\n{join(extras, '\n')}\n"
636 21: fbb6c5cc81002f2b4b49c9d731404688bcae5ade
637 branch=dev
638 convert_revision=7e61b508e709a11d28194a5359bc3532d910af21
639 transplant_source=z\xe8F\xe9\x11\x1f\xc8\xf5wEcBP\xc7\xb9\xac\n`h\x9b
640 $ hg -R ../converted log -r 'origin(tip)'
641 changeset: 2:e0213322b2c1
642 user: test
643 date: Thu Jan 01 00:00:00 1970 +0000
644 summary: 2
645
646
647 Test simple destination
648 $ hg log -r 'destination()'
649 changeset: 7:ef0ef43d49e7
650 parent: 0:68795b066622
651 user: foo
652 date: Thu Jan 01 00:00:00 1970 +0000
653 summary: 2
654
655 changeset: 8:6b9e5368ca4e
656 user: bar
657 date: Thu Jan 01 00:00:00 1970 +0000
658 summary: 1
659
660 changeset: 9:1905859650ec
661 user: test
662 date: Thu Jan 01 00:00:00 1970 +0000
663 summary: 5
664
665 changeset: 10:52dc0b4c6907
666 user: test
667 date: Thu Jan 01 00:00:00 1970 +0000
668 summary: 4
669
670 changeset: 11:882b35362a6b
671 user: test
672 date: Thu Jan 01 00:00:00 1970 +0000
673 summary: 3
674
675 changeset: 13:7a4785234d87
676 user: foo
677 date: Thu Jan 01 00:00:00 1970 +0000
678 summary: 2
679
680 changeset: 14:0c921c65ef1e
681 parent: 1:5d205f8b35b6
682 user: foo
683 date: Thu Jan 01 00:00:00 1970 +0000
684 summary: 3
685
686 changeset: 17:f67661df0c48
687 user: bar
688 date: Thu Jan 01 00:00:00 1970 +0000
689 summary: 1
690
691 changeset: 19:9627f653b421
692 user: test
693 date: Thu Jan 01 00:00:00 1970 +0000
694 summary: 2
695
696 changeset: 21:7e61b508e709
697 branch: dev
698 tag: tip
699 user: foo
700 date: Thu Jan 01 00:00:00 1970 +0000
701 summary: 2
702
703 $ hg log -r 'destination(2)'
704 changeset: 7:ef0ef43d49e7
705 parent: 0:68795b066622
706 user: foo
707 date: Thu Jan 01 00:00:00 1970 +0000
708 summary: 2
709
710 changeset: 13:7a4785234d87
711 user: foo
712 date: Thu Jan 01 00:00:00 1970 +0000
713 summary: 2
714
715 changeset: 19:9627f653b421
716 user: test
717 date: Thu Jan 01 00:00:00 1970 +0000
718 summary: 2
719
720 changeset: 21:7e61b508e709
721 branch: dev
722 tag: tip
723 user: foo
724 date: Thu Jan 01 00:00:00 1970 +0000
725 summary: 2
726
727 Transplants of grafts can find a destination...
728 $ hg log -r 'destination(7)'
729 changeset: 21:7e61b508e709
730 branch: dev
731 tag: tip
732 user: foo
733 date: Thu Jan 01 00:00:00 1970 +0000
734 summary: 2
735
736 ... grafts of grafts unfortunately can't
737 $ hg graft -q 13 --debug
738 scanning for duplicate grafts
739 grafting 13:7a4785234d87 "2"
740 all copies found (* = to merge, ! = divergent, % = renamed and deleted):
741 on local side:
742 src: 'a' -> dst: 'b' *
743 on remote side:
744 src: 'a' -> dst: 'b' *
745 checking for directory renames
746 resolving manifests
747 branchmerge: True, force: True, partial: False
748 ancestor: b592ea63bb0c, local: 7e61b508e709+, remote: 7a4785234d87
749 starting 4 threads for background file closing (?)
750 nothing to commit, clearing merge state
751 note: graft of 13:7a4785234d87 created no changes to commit
752 $ hg log -r 'destination(13)'
753 All copies of a cset
754 $ hg log -r 'origin(13) or destination(origin(13))'
755 changeset: 2:5c095ad7e90f
756 user: test
757 date: Thu Jan 01 00:00:00 1970 +0000
758 summary: 2
759
760 changeset: 7:ef0ef43d49e7
761 parent: 0:68795b066622
762 user: foo
763 date: Thu Jan 01 00:00:00 1970 +0000
764 summary: 2
765
766 changeset: 13:7a4785234d87
767 user: foo
768 date: Thu Jan 01 00:00:00 1970 +0000
769 summary: 2
770
771 changeset: 19:9627f653b421
772 user: test
773 date: Thu Jan 01 00:00:00 1970 +0000
774 summary: 2
775
776 changeset: 21:7e61b508e709
777 branch: dev
778 tag: tip
779 user: foo
780 date: Thu Jan 01 00:00:00 1970 +0000
781 summary: 2
782
783
784 graft skips ancestors
785
786 $ hg graft 21 3
787 skipping ancestor revision 21:7e61b508e709
788 grafting 3:4c60f11aa304 "3"
789 merging b and c to c
790
791 graft with --force (still doesn't graft merges)
792
793 $ hg graft 19 0 6
794 skipping ungraftable merge revision 6
795 skipping ancestor revision 0:68795b066622
796 grafting 19:9627f653b421 "2"
797 merging b
798 note: graft of 19:9627f653b421 created no changes to commit
799 $ hg graft 19 0 6 --force
800 skipping ungraftable merge revision 6
801 grafting 19:9627f653b421 "2"
802 merging b
803 note: graft of 19:9627f653b421 created no changes to commit
804 grafting 0:68795b066622 "0"
805
806 graft --force after backout. Do the backout with graft too, to make
807 sure we support issue6248.
808
809 $ echo abc > a
810 $ hg ci -m 24
811 $ hg graft --base . -r ".^" --no-commit
812 grafting 23:b1cac6de36a9 "0"
813 $ hg commit -m 'Backed out changeset 2e7ea477be26'
814 $ hg graft 24
815 skipping ancestor revision 24:2e7ea477be26
816 [255]
817 $ hg graft 24 --force
818 grafting 24:2e7ea477be26 "24"
819 merging a
820 $ cat a
821 abc
822
823 graft --continue after --force
824
825 $ echo def > a
826 $ hg ci -m 27
827 $ hg graft 24 --force --tool internal:fail
828 grafting 24:2e7ea477be26 "24"
829 abort: unresolved conflicts, can't continue
830 (use 'hg resolve' and 'hg graft --continue')
831 [1]
832 $ hg resolve --all
833 merging a
834 warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
835 [1]
836 $ echo abc > a
837 $ hg resolve -m a
838 (no more unresolved files)
839 continue: hg graft --continue
840 $ hg graft -c
841 grafting 24:2e7ea477be26 "24"
842 $ cat a
843 abc
844
845 graft --continue after --base with conflits
846
847 $ echo base > d
848 $ hg ci -m _
849 $ hg graft -r 6
850 skipping ungraftable merge revision 6
851 [255]
852 $ hg graft -r 6 --base 5
853 grafting 6:25a2b029d3ae "6"
854 merging d
855 warning: conflicts while merging d! (edit, then use 'hg resolve --mark')
856 merging e
857 abort: unresolved conflicts, can't continue
858 (use 'hg resolve' and 'hg graft --continue')
859 [1]
860 $ echo a > d && hg resolve -qm
861 continue: hg graft --continue
862 $ hg graft --continue
863 grafting 6:25a2b029d3ae "6"
864
865 Continue testing same origin policy, using revision numbers from test above
866 but do some destructive editing of the repo:
867
868 $ hg up -qC 7
869 $ hg tag -l -r 13 tmp
870 $ hg --config extensions.strip= strip 2
871 saved backup bundle to $TESTTMP/a/.hg/strip-backup/5c095ad7e90f-d323a1e4-backup.hg
872 $ hg graft tmp
873 skipping already grafted revision 8:7a4785234d87 (2:ef0ef43d49e7 also has unknown origin 5c095ad7e90f)
874 [255]
875
876 Empty graft
877
878 $ hg up -qr 22
879 $ hg tag -f something
880 $ hg graft -qr 23
881 $ hg graft -f 23
882 grafting 23:72d9c7c75bcc "24"
883 note: graft of 23:72d9c7c75bcc created no changes to commit
884
885 $ pwd
886 $TESTTMP/a
887 $ cd ..
888
889 Graft to duplicate a commit
890
891 $ hg init graftsibling
892 $ cd graftsibling
893 $ touch a
894 $ hg commit -qAm a
895 $ touch b
896 $ hg commit -qAm b
897 $ hg log -G -T '{rev}\n'
898 @ 1
899 |
900 o 0
901
902 $ hg up -q 0
903 $ hg graft -r 1
904 grafting 1:0e067c57feba "b" (tip)
905 $ hg log -G -T '{rev}\n'
906 @ 2
907 |
908 | o 1
909 |/
910 o 0
911
912 Graft to duplicate a commit twice
913
914 $ hg up -q 0
915 $ hg graft -r 2
916 grafting 2:044ec77f6389 "b" (tip)
917 $ hg log -G -T '{rev}\n'
918 @ 3
919 |
920 | o 2
921 |/
922 | o 1
923 |/
924 o 0
925
926 $ cd ../
927
928 In memory graft with --to
929 =========================
930
931
932 setup a repository
933
934 $ hg init base-to
935 $ cd base-to
936 $ hg debugbuilddag -m ".:base..:dst*base.:src*base..:wc"
937 $ hg up "wc"
938 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
939 $ hg log -G -T '{rev}:{desc} {tags}\n'
940 @ 7:r7 tip wc
941 |
942 o 6:r6
943 |
944 o 5:r5
945 |
946 | o 4:r4 src
947 | |
948 | o 3:r3
949 |/
950 | o 2:r2 dst
951 | |
952 | o 1:r1
953 |/
954 o 0:r0 base
955
956
957 $ cd ..
958
959 Simple test
960 -----------
961
962 As few special case as possible
963
964 $ cp -R base-to test-to-simple
965 $ cd test-to-simple
966 $ hg graft --rev src --to dst
967 grafting 4:4178b3134f52 "r4" (src)
968 merging mf
969 $ hg log -G -T '{rev}:{desc} {tags}\n'
970 o 8:r4 tip
971 |
972 | @ 7:r7 wc
973 | |
974 | o 6:r6
975 | |
976 | o 5:r5
977 | |
978 | | o 4:r4 src
979 | | |
980 | | o 3:r3
981 | |/
982 o | 2:r2 dst
983 | |
984 o | 1:r1
985 |/
986 o 0:r0 base
987
988 $ cd ..
989
990 Single changeset, local changes
991 -------------------------------
992
993 Run "graft --to" with local changes
994
995 $ cp -R base-to test-to-local-change
996 $ cd test-to-local-change
997 $ hg st --all
998 C mf
999 $ echo foo >> mf
1000 $ hg status
1001 M mf
1002 $ hg graft --rev src --to dst
1003 grafting 4:4178b3134f52 "r4" (src)
1004 merging mf
1005
1006 local file should not have been touched.
1007
1008 $ hg status
1009 M mf
1010 $ hg log -G -T '{rev}:{desc} {tags}\n'
1011 o 8:r4 tip
1012 |
1013 | @ 7:r7 wc
1014 | |
1015 | o 6:r6
1016 | |
1017 | o 5:r5
1018 | |
1019 | | o 4:r4 src
1020 | | |
1021 | | o 3:r3
1022 | |/
1023 o | 2:r2 dst
1024 | |
1025 o | 1:r1
1026 |/
1027 o 0:r0 base
1028
1029 $ cd ..
1030
1031 Multiple linear changesets
1032 --------------------------
1033
1034 grafting multiple linear changesets
1035
1036 $ cp -R base-to test-to-multiple-linear
1037 $ cd test-to-multiple-linear
1038 $ hg graft --rev 'src~1::src' --to dst
1039 grafting 3:181578a106da "r3"
1040 merging mf
1041 grafting 4:4178b3134f52 "r4" (src)
1042 merging mf
1043 $ hg log -G -T '{rev}:{desc} {tags}\n'
1044 o 9:r4 tip
1045 |
1046 o 8:r3
1047 |
1048 | @ 7:r7 wc
1049 | |
1050 | o 6:r6
1051 | |
1052 | o 5:r5
1053 | |
1054 | | o 4:r4 src
1055 | | |
1056 | | o 3:r3
1057 | |/
1058 o | 2:r2 dst
1059 | |
1060 o | 1:r1
1061 |/
1062 o 0:r0 base
1063
1064 $ cd ..
1065
1066 Multiple unrelated changesets
1067 --------------------------
1068
1069 Grafting multiple changesets on different branch
1070
1071 The order specified on the command line should be preserved.
1072 The result should be linear.
1073
1074 $ cp -R base-to test-to-multiple-unrelated
1075 $ cd test-to-multiple-unrelated
1076 $ hg graft 'src' 'wc~1' 'src~1' --to dst
1077 grafting 4:4178b3134f52 "r4" (src)
1078 merging mf
1079 grafting 6:735f0f7a080b "r6"
1080 merging mf
1081 grafting 3:181578a106da "r3"
1082 merging mf
1083 $ hg log -G -T '{rev}:{desc} {tags}\n'
1084 o 10:r3 tip
1085 |
1086 o 9:r6
1087 |
1088 o 8:r4
1089 |
1090 | @ 7:r7 wc
1091 | |
1092 | o 6:r6
1093 | |
1094 | o 5:r5
1095 | |
1096 | | o 4:r4 src
1097 | | |
1098 | | o 3:r3
1099 | |/
1100 o | 2:r2 dst
1101 | |
1102 o | 1:r1
1103 |/
1104 o 0:r0 base
1105
1106 $ cd ..
1107
1108 with base
1109 ---------
1110
1111 $ cp -R base-to test-to-base
1112 $ cd test-to-base
1113 $ hg graft --base base src --to dst
1114 grafting 4:4178b3134f52 "r4" (src)
1115 merging mf
1116 $ hg log -G -T '{rev}:{desc} {tags}\n'
1117 o 8:r4 tip
1118 |
1119 | @ 7:r7 wc
1120 | |
1121 | o 6:r6
1122 | |
1123 | o 5:r5
1124 | |
1125 | | o 4:r4 src
1126 | | |
1127 | | o 3:r3
1128 | |/
1129 o | 2:r2 dst
1130 | |
1131 o | 1:r1
1132 |/
1133 o 0:r0 base
1134
1135 $ hg diff --from base --to src
1136 diff -r 93cbaf5e6529 -r 4178b3134f52 mf
1137 --- a/mf Thu Jan 01 00:00:00 1970 +0000
1138 +++ b/mf Thu Jan 01 00:00:04 1970 +0000
1139 @@ -4,9 +4,9 @@
1140 3
1141 4
1142 5
1143 -6
1144 +6 r3
1145 7
1146 -8
1147 +8 r4
1148 9
1149 10
1150 11
1151 $ hg export src
1152 # HG changeset patch
1153 # User debugbuilddag
1154 # Date 4 0
1155 # Thu Jan 01 00:00:04 1970 +0000
1156 # Node ID 4178b3134f5224d297d3b9e0e98b983f42e53d55
1157 # Parent 181578a106daabea66d4465f4883f7f8552bbc9d
1158 r4
1159
1160 diff -r 181578a106da -r 4178b3134f52 mf
1161 --- a/mf Thu Jan 01 00:00:03 1970 +0000
1162 +++ b/mf Thu Jan 01 00:00:04 1970 +0000
1163 @@ -6,7 +6,7 @@
1164 5
1165 6 r3
1166 7
1167 -8
1168 +8 r4
1169 9
1170 10
1171 11
1172 $ hg export tip
1173 # HG changeset patch
1174 # User debugbuilddag
1175 # Date 4 0
1176 # Thu Jan 01 00:00:04 1970 +0000
1177 # Node ID 40112ab60ecb01882916c1a4439c798746e34165
1178 # Parent 37d4c1cec295ddfa401f4a365e15a82a1974b056
1179 r4
1180
1181 diff -r 37d4c1cec295 -r 40112ab60ecb mf
1182 --- a/mf Thu Jan 01 00:00:02 1970 +0000
1183 +++ b/mf Thu Jan 01 00:00:04 1970 +0000
1184 @@ -4,9 +4,9 @@
1185 3
1186 4 r2
1187 5
1188 -6
1189 +6 r3
1190 7
1191 -8
1192 +8 r4
1193 9
1194 10
1195 11
1196 $ cd ..
1197
1198 with conflict
1199 -------------
1200
1201 We should abort in case of conflict and rollback any grafted procress
1202
1203 $ cp -R base-to test-to-conflict
1204 $ cd test-to-conflict
1205 $ hg up src
1206 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1207 $ echo this-will-conflict >> mf
1208 $ hg ci -m 'this-will-conflict'
1209 $ hg up dst
1210 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1211 $ echo conflict-this-will-conflict >> mf
1212 $ hg ci -m 'conflict-this-will'
1213 $ hg up wc
1214 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1215 $ hg graft --to 'max(dst::)' src:: --dry-run
1216 grafting 4:4178b3134f52 "r4" (src)
1217 grafting 8:9fa2d3fe2323 "this-will-conflict"
1218 $ hg graft --to 'max(dst::)' src::
1219 grafting 4:4178b3134f52 "r4" (src)
1220 merging mf
1221 grafting 8:9fa2d3fe2323 "this-will-conflict"
1222 merging mf
1223 transaction abort!
1224 rollback completed
1225 abort: cannot graft in memory: merge conflicts
1226 (in-memory merge does not support merge conflicts)
1227 [255]
1228 $ hg log -G -T '{rev}:{desc} {tags}\n'
1229 o 9:conflict-this-will tip
1230 |
1231 | o 8:this-will-conflict
1232 | |
1233 | | @ 7:r7 wc
1234 | | |
1235 | | o 6:r6
1236 | | |
1237 | | o 5:r5
1238 | | |
1239 | o | 4:r4 src
1240 | | |
1241 | o | 3:r3
1242 | |/
1243 o | 2:r2 dst
1244 | |
1245 o | 1:r1
1246 |/
1247 o 0:r0 base
1248
1249 $ cd ..
1250
1251