comparison tests/test-tutorial.t @ 441:d702f0d26c6a

obsolete: remove debugsuccessors This was kinda duplicate of core "debugobsolete"
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Tue, 07 Aug 2012 16:02:50 +0200
parents 92b073d13f2d
children b98490b689a5
comparison
equal deleted inserted replaced
440:5fa287e5087e 441:d702f0d26c6a
1 ../docs/tutorials/tutorial.t 1
2 Initial setup
3 -------------
4
5 This Mercurial configuration example is used for testing.
6 .. Various setup
7
8 $ cat >> $HGRCPATH << EOF
9 > [ui]
10 > logtemplate ="{node|short} ({phase}): {desc}\n"
11 > [diff]
12 > git = 1
13 > [alias]
14 > # "-d '0 0'" means that the new commit will be at January 1st 1970.
15 > # This is used for stable hash during test
16 > amend = amend -d '0 0'
17 > [extensions]
18 > hgext.graphlog=
19 > EOF
20
21 $ hg init local
22 $ cat >> local/.hg/hgrc << EOF
23 > [paths]
24 > remote = ../remote
25 > other = ../other
26 > [ui]
27 > user = Babar the King
28 > EOF
29
30 $ hg init remote
31 $ cat >> remote/.hg/hgrc << EOF
32 > [paths]
33 > local = ../local
34 > [ui]
35 > user = Celestine the Queen
36 > EOF
37
38 $ hg init other
39 $ cat >> other/.hg/hgrc << EOF
40 > [ui]
41 > user = Princess Flore
42 > EOF
43
44
45 This tutorial use the following configuration for Mercurial:
46
47 A compact log template with phase data:
48
49 $ hg showconfig ui
50 ui.slash=True
51 ui.logtemplate="{node|short} ({phase}): {desc}\n"
52
53 Improved git format diff:
54
55 $ hg showconfig diff
56 diff.git=1
57
58 And the graphlog extension
59 $ hg showconfig extensions
60 extensions.hgext.graphlog=
61
62 And of course, we anabled the experimental extensions for mutable history:
63
64 $ $(dirname $TESTDIR)/enable.sh >> $HGRCPATH 2> /dev/null
65
66
67 -----------------------
68 Single Developer Usage
69 -----------------------
70
71 This tutorial shows how to use evolution to rewrite history locally.
72
73
74 Fixing mistake with `hg amend`
75 --------------------------------
76
77 We are versionning a shopping list
78
79 $ cd local
80 $ cat >> shopping << EOF
81 > Spam
82 > Whizzo butter
83 > Albatross
84 > Rat (rather a lot)
85 > Jugged fish
86 > Blancmange
87 > Salmon mousse
88 > EOF
89 $ hg commit -A -m "Monthy Python Shopping list"
90 adding shopping
91
92 Its first version is shared with the outside.
93
94 $ hg push remote
95 pushing to $TESTTMP/remote
96 searching for changes
97 adding changesets
98 adding manifests
99 adding file changes
100 added 1 changesets with 1 changes to 1 files
101
102 Later I add additional item to my list
103
104 $ cat >> shopping << EOF
105 > Egg
106 > Suggar
107 > Vinegar
108 > Oil
109 > EOF
110 $ hg commit -m "adding condiment"
111 $ cat >> shopping << EOF
112 > Bananos
113 > Pear
114 > Apple
115 > EOF
116 $ hg commit -m "adding fruit"
117
118 This history is very linear
119
120 $ hg glog
121 @ d85de4546133 (draft): adding fruit
122 |
123 o 4d5dc8187023 (draft): adding condiment
124 |
125 o 7e82d3f3c2cb (public): Monthy Python Shopping list
126
127
128 But a typo was made in Babanas!
129
130 $ hg export tip
131 # HG changeset patch
132 # User test
133 # Date 0 0
134 # Node ID d85de4546133030c82d257bbcdd9b1b416d0c31c
135 # Parent 4d5dc81870237d492284826e21840b2ca00e26d1
136 adding fruit
137
138 diff --git a/shopping b/shopping
139 --- a/shopping
140 +++ b/shopping
141 @@ -9,3 +9,6 @@
142 Suggar
143 Vinegar
144 Oil
145 +Bananos
146 +Pear
147 +Apple
148
149 The faulty changeset is in the "draft" phase because he was not exchanged with
150 the outside. The first one have been exchanged and is an immutable public
151 changeset.
152
153 $ hg glog
154 @ d85de4546133 (draft): adding fruit
155 |
156 o 4d5dc8187023 (draft): adding condiment
157 |
158 o 7e82d3f3c2cb (public): Monthy Python Shopping list
159
160
161 hopefully. I can use hg amend to rewrite my faulty changeset!
162
163 $ sed -i'' -e s/Bananos/Banana/ shopping
164 $ hg diff
165 diff --git a/shopping b/shopping
166 --- a/shopping
167 +++ b/shopping
168 @@ -9,6 +9,6 @@
169 Suggar
170 Vinegar
171 Oil
172 -Bananos
173 +Banana
174 Pear
175 Apple
176 $ hg amend
177
178 A new changeset with the right diff replace the wrong one.
179
180 $ hg glog
181 @ 0cacb48f4482 (draft): adding fruit
182 |
183 o 4d5dc8187023 (draft): adding condiment
184 |
185 o 7e82d3f3c2cb (public): Monthy Python Shopping list
186
187 $ hg export tip
188 # HG changeset patch
189 # User test
190 # Date 0 0
191 # Node ID 0cacb48f44828d2fd31c4e45e18fde32a5b2f07b
192 # Parent 4d5dc81870237d492284826e21840b2ca00e26d1
193 adding fruit
194
195 diff --git a/shopping b/shopping
196 --- a/shopping
197 +++ b/shopping
198 @@ -9,3 +9,6 @@
199 Suggar
200 Vinegar
201 Oil
202 +Banana
203 +Pear
204 +Apple
205
206 Getting Ride of branchy history
207 ----------------------------------
208
209 While I was working on my list. someone help made a change remotly.
210
211 $ cd ../remote
212 $ hg up -q
213 $ sed -i'' -e 's/Spam/Spam Spam Spam/' shopping
214 $ hg ci -m 'SPAM'
215 $ cd ../local
216
217 I'll get this remote changeset when pulling
218
219 $ hg pull remote
220 pulling from $TESTTMP/remote
221 searching for changes
222 adding changesets
223 adding manifests
224 adding file changes
225 added 1 changesets with 1 changes to 1 files (+1 heads)
226 (run 'hg heads .' to see heads, 'hg merge' to merge)
227
228 I now have a new heads. Note that this remote head is immutable
229
230 $ hg log -G
231 o 9ca060c80d74 (public): SPAM
232 |
233 | @ 0cacb48f4482 (draft): adding fruit
234 | |
235 | o 4d5dc8187023 (draft): adding condiment
236 |/
237 o 7e82d3f3c2cb (public): Monthy Python Shopping list
238
239
240 instead of merging my head with the new one. I'm going to rebase my work
241
242 $ hg diff
243 $ hg rebase -d 9ca060c80d74 -s 4d5dc8187023
244 merging shopping
245 merging shopping
246
247
248 My local work is now rebased on the remote one.
249
250 $ hg log -G
251 @ 387187ad9bd9 (draft): adding fruit
252 |
253 o dfd3a2d7691e (draft): adding condiment
254 |
255 o 9ca060c80d74 (public): SPAM
256 |
257 o 7e82d3f3c2cb (public): Monthy Python Shopping list
258
259
260 Removing changeset
261 ------------------------
262
263 I add new item to my list
264
265 $ cat >> shopping << EOF
266 > car
267 > bus
268 > plane
269 > boat
270 > EOF
271 $ hg ci -m 'transport'
272 $ hg log -G
273 @ d58c77aa15d7 (draft): transport
274 |
275 o 387187ad9bd9 (draft): adding fruit
276 |
277 o dfd3a2d7691e (draft): adding condiment
278 |
279 o 9ca060c80d74 (public): SPAM
280 |
281 o 7e82d3f3c2cb (public): Monthy Python Shopping list
282
283
284 I have a new commit but I realize that don't want it. (transport shop list does
285 not fit well in my standard shopping list)
286
287 $ hg prune . # . is for working directory parent
288 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
289 working directory now at 387187ad9bd9
290
291 The silly changeset is gone.
292
293 $ hg log -G
294 @ 387187ad9bd9 (draft): adding fruit
295 |
296 o dfd3a2d7691e (draft): adding condiment
297 |
298 o 9ca060c80d74 (public): SPAM
299 |
300 o 7e82d3f3c2cb (public): Monthy Python Shopping list
301
302
303 Reordering changeset
304 ------------------------
305
306
307 We create two changesets.
308
309
310 $ cat >> shopping << EOF
311 > Shampoo
312 > Toothbrush
313 > ... More bathroom stuff to come
314 > Towel
315 > Soap
316 > EOF
317 $ hg ci -m 'bathroom stuff' -q # XXX remove the -q
318
319 $ sed -i'' -e 's/Spam/Spam Spam Spam/g' shopping
320 $ hg ci -m 'SPAM SPAM'
321 $ hg log -G
322 @ c48f32fb1787 (draft): SPAM SPAM
323 |
324 o 8d39a843582d (draft): bathroom stuff
325 |
326 o 387187ad9bd9 (draft): adding fruit
327 |
328 o dfd3a2d7691e (draft): adding condiment
329 |
330 o 9ca060c80d74 (public): SPAM
331 |
332 o 7e82d3f3c2cb (public): Monthy Python Shopping list
333
334
335 .. note: don't amend changeset 7e82d3f3c2cb or 9ca060c80d74 as they are immutable.
336
337 I now want to push to remote all my change but the bathroom one that i'm not
338 totally happy with yet. To be able to push "SPAM SPAM" I need a version of "SPAM SPAM" not children of
339 "bathroom stuff"
340
341 You can use 'rebase -r' or 'graft -O' for that:
342
343 $ hg up 'p1(8d39a843582d)' # going on "bathroom stuff" parent
344 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
345 $ hg graft -O c48f32fb1787 # moving "SPAM SPAM" to the working directory parent
346 grafting revision 10
347 merging shopping
348 $ hg log -G
349 @ a2fccc2e7b08 (draft): SPAM SPAM
350 |
351 | o 8d39a843582d (draft): bathroom stuff
352 |/
353 o 387187ad9bd9 (draft): adding fruit
354 |
355 o dfd3a2d7691e (draft): adding condiment
356 |
357 o 9ca060c80d74 (public): SPAM
358 |
359 o 7e82d3f3c2cb (public): Monthy Python Shopping list
360
361
362 We have a new SPAM SPAM version without the bathroom stuff
363
364 $ grep Spam shopping # enouth spam
365 Spam Spam Spam Spam Spam Spam Spam Spam Spam
366 $ grep Toothbrush shopping # no Toothbrush
367 [1]
368 $ hg export .
369 # HG changeset patch
370 # User test
371 # Date 0 0
372 # Node ID a2fccc2e7b08bbce6af7255b989453f7089e4cf0
373 # Parent 387187ad9bd9d8f9a00a9fa804a26231db547429
374 SPAM SPAM
375
376 diff --git a/shopping b/shopping
377 --- a/shopping
378 +++ b/shopping
379 @@ -1,4 +1,4 @@
380 -Spam Spam Spam
381 +Spam Spam Spam Spam Spam Spam Spam Spam Spam
382 Whizzo butter
383 Albatross
384 Rat (rather a lot)
385
386 To make sure I do not push unready changeset by mistake I set the "bathroom
387 stuff" changeset in the secret phase.
388
389 $ hg phase --force --secret 8d39a843582d
390
391 we can now push our change:
392
393 $ hg push remote
394 pushing to $TESTTMP/remote
395 searching for changes
396 adding changesets
397 adding manifests
398 adding file changes
399 added 3 changesets with 3 changes to 1 files
400
401 for simplicity shake we get the bathroom change in line again
402
403 $ hg rebase -Dr 8d39a843582d -d a2fccc2e7b08
404 merging shopping
405 $ hg phase --draft .
406 $ hg log -G
407 @ 8a79ae8b029e (draft): bathroom stuff
408 |
409 o a2fccc2e7b08 (public): SPAM SPAM
410 |
411 o 387187ad9bd9 (public): adding fruit
412 |
413 o dfd3a2d7691e (public): adding condiment
414 |
415 o 9ca060c80d74 (public): SPAM
416 |
417 o 7e82d3f3c2cb (public): Monthy Python Shopping list
418
419
420
421
422 Splitting change
423 ------------------
424
425 To be done (currently achieve with "two commit + debugobsolete")
426
427 Collapsing change
428 ------------------
429
430 To be done (currently achieve with "revert + debugobsolete" or "rebase --collapse")
431
432
433
434
435
436
437 -----------------------
438 Collaboration
439 -----------------------
440
441
442 sharing mutable changeset
443 ----------------------------
444
445 To share mutable changeset with other just check that the repo you interact
446 with is "not publishing". Otherwise you will get the previously observe
447 behavior where exchanged changeset are automatically published.
448
449 $ cd ../remote
450 $ hg -R ../local/ showconfig phases
451
452 the localrepo does not have any specific configuration for `phases.publish`. It
453 is ``true`` by default.
454
455 $ hg pull local
456 pulling from $TESTTMP/local
457 searching for changes
458 adding changesets
459 adding manifests
460 adding file changes
461 added 1 changesets with 1 changes to 1 files
462 (run 'hg update' to get a working copy)
463 $ hg log -G
464 o 8a79ae8b029e (public): bathroom stuff
465 |
466 o a2fccc2e7b08 (public): SPAM SPAM
467 |
468 o 387187ad9bd9 (public): adding fruit
469 |
470 o dfd3a2d7691e (public): adding condiment
471 |
472 @ 9ca060c80d74 (public): SPAM
473 |
474 o 7e82d3f3c2cb (public): Monthy Python Shopping list
475
476
477
478
479 We do not want to publish the "bathroom changeset". Let's rollback the last transaction
480
481 $ hg rollback
482 repository tip rolled back to revision 4 (undo pull)
483 $ hg log -G
484 o a2fccc2e7b08 (public): SPAM SPAM
485 |
486 o 387187ad9bd9 (public): adding fruit
487 |
488 o dfd3a2d7691e (public): adding condiment
489 |
490 @ 9ca060c80d74 (public): SPAM
491 |
492 o 7e82d3f3c2cb (public): Monthy Python Shopping list
493
494
495 Let's make the local repo "non publishing"
496
497 $ echo '[phases]' >> ../local/.hg/hgrc
498 $ echo 'publish=false' >> ../local/.hg/hgrc
499 $ echo '[phases]' >> .hg/hgrc
500 $ echo 'publish=false' >> .hg/hgrc
501 $ hg showconfig phases
502 phases.publish=false
503 $ hg -R ../local/ showconfig phases
504 phases.publish=false
505
506
507 I can now exchange mutable changeset between "remote" and "local" repository.
508
509 $ hg pull local
510 pulling from $TESTTMP/local
511 searching for changes
512 adding changesets
513 adding manifests
514 adding file changes
515 added 1 changesets with 1 changes to 1 files
516 (run 'hg update' to get a working copy)
517 $ hg log -G
518 o 8a79ae8b029e (draft): bathroom stuff
519 |
520 o a2fccc2e7b08 (public): SPAM SPAM
521 |
522 o 387187ad9bd9 (public): adding fruit
523 |
524 o dfd3a2d7691e (public): adding condiment
525 |
526 @ 9ca060c80d74 (public): SPAM
527 |
528 o 7e82d3f3c2cb (public): Monthy Python Shopping list
529
530
531 Rebasing unstable change after pull
532 ----------------------------------------------
533
534 Remotely someone add a new changeset on top of the mutable "bathroom" on.
535
536 $ hg up 8a79ae8b029e -q
537 $ cat >> shopping << EOF
538 > Giraffe
539 > Rhino
540 > Lion
541 > Bear
542 > EOF
543 $ hg ci -m 'animals'
544
545 But at the same time, locally, this same "bathroom changeset" was updated.
546
547 $ cd ../local
548 $ hg up 8a79ae8b029e -q
549 $ sed -i'' -e 's/... More bathroom stuff to come/Bath Robe/' shopping
550 $ hg amend
551 $ hg log -G
552 @ ffa278c50818 (draft): bathroom stuff
553 |
554 o a2fccc2e7b08 (public): SPAM SPAM
555 |
556 o 387187ad9bd9 (public): adding fruit
557 |
558 o dfd3a2d7691e (public): adding condiment
559 |
560 o 9ca060c80d74 (public): SPAM
561 |
562 o 7e82d3f3c2cb (public): Monthy Python Shopping list
563
564
565
566 When we pull from remote again we get an unstable state!
567
568
569 $ hg pull remote
570 pulling from $TESTTMP/remote
571 searching for changes
572 adding changesets
573 adding manifests
574 adding file changes
575 added 1 changesets with 1 changes to 1 files (+1 heads)
576 (run 'hg heads .' to see heads, 'hg merge' to merge)
577 1 new unstables changesets
578
579
580 The new changeset "animal" is based one an old changeset of "bathroom". You can
581 see both version showing up in the log.
582
583 $ hg log -G
584 o 9ac5d0e790a2 (draft): animals
585 |
586 | @ ffa278c50818 (draft): bathroom stuff
587 | |
588 x | 8a79ae8b029e (draft): bathroom stuff
589 |/
590 o a2fccc2e7b08 (public): SPAM SPAM
591 |
592 o 387187ad9bd9 (public): adding fruit
593 |
594 o dfd3a2d7691e (public): adding condiment
595 |
596 o 9ca060c80d74 (public): SPAM
597 |
598 o 7e82d3f3c2cb (public): Monthy Python Shopping list
599
600
601 The older version 8a79ae8b029e never ceased to exist in the local repo. It was
602 jsut hidden and excluded from pull and push.
603
604 .. note:: In hgview there is a nice doted relation highlighting ffa278c50818 as a new version of 8a79ae8b029e. this is not yet ported to graphlog.
605
606 Their is **unstable** changeset in this history now. Mercurial will refuse to
607 share it with the outside:
608
609 $ hg push other
610 pushing to $TESTTMP/other
611 searching for changes
612 abort: push includes an unstable changeset: 9ac5d0e790a2!
613 (use 'hg stabilize' to get a stable history or --force to ignore warnings)
614 [255]
615
616
617
618
619 To resolve this unstable state, you need to rebase 9ac5d0e790a2 onto
620 ffa278c50818 the "hg stabilize" command will make this for you.
621
622 It has a --dry-run option to only suggest the next move.
623
624 $ hg stabilize --dry-run
625 move:[15] animals
626 atop:[14] bathroom stuff
627 hg rebase -Dr 9ac5d0e790a2 -d ffa278c50818
628
629 Let's do it
630
631 $ hg rebase -Dr 9ac5d0e790a2 -d ffa278c50818
632 merging shopping
633
634 The old version of bathroom is hidden again.
635
636 $ hg log -G
637 @ 437efbcaf700 (draft): animals
638 |
639 o ffa278c50818 (draft): bathroom stuff
640 |
641 o a2fccc2e7b08 (public): SPAM SPAM
642 |
643 o 387187ad9bd9 (public): adding fruit
644 |
645 o dfd3a2d7691e (public): adding condiment
646 |
647 o 9ca060c80d74 (public): SPAM
648 |
649 o 7e82d3f3c2cb (public): Monthy Python Shopping list
650
651
652
653 We can push this evolution to remote
654
655 $ hg push remote
656 pushing to $TESTTMP/remote
657 searching for changes
658 adding changesets
659 adding manifests
660 adding file changes
661 added 2 changesets with 2 changes to 1 files (+1 heads)
662
663 remote get a warning that current working directory is based on an obsolete changeset
664
665 $ cd ../remote
666 $ hg pull local # we up again to trigger the warning. it was displayed during the push
667 pulling from $TESTTMP/local
668 searching for changes
669 no changes found
670 Working directory parent is obsolete
671
672 $ hg up 437efbcaf700
673 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
674
675 Relocating unstable change after prune
676 ----------------------------------------------
677
678 The remote guy keep working
679
680 $ sed -i'' -e 's/Spam/Spam Spam Spam Spam/g' shopping
681 $ hg commit -m "SPAM SPAM SPAM"
682
683 I'm pulling its work locally.
684
685 $ cd ../local
686 $ hg pull remote
687 pulling from $TESTTMP/remote
688 searching for changes
689 adding changesets
690 adding manifests
691 adding file changes
692 added 1 changesets with 1 changes to 1 files
693 (run 'hg update' to get a working copy)
694 $ hg log -G
695 o ae45c0c3092a (draft): SPAM SPAM SPAM
696 |
697 @ 437efbcaf700 (draft): animals
698 |
699 o ffa278c50818 (draft): bathroom stuff
700 |
701 o a2fccc2e7b08 (public): SPAM SPAM
702 |
703 o 387187ad9bd9 (public): adding fruit
704 |
705 o dfd3a2d7691e (public): adding condiment
706 |
707 o 9ca060c80d74 (public): SPAM
708 |
709 o 7e82d3f3c2cb (public): Monthy Python Shopping list
710
711
712 In the mean time I noticed you can't buy animals in a super market and I prune the animal changeset:
713
714 $ hg prune 437efbcaf700
715 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
716 working directory now at ffa278c50818
717 1 new unstables changesets
718
719
720 The animals changeset is still displayed because the "SPAM SPAM SPAM" changeset
721 is neither dead or obsolete. My repository is in an unstable state again.
722
723 $ hg log -G
724 o ae45c0c3092a (draft): SPAM SPAM SPAM
725 |
726 x 437efbcaf700 (draft): animals
727 |
728 @ ffa278c50818 (draft): bathroom stuff
729 |
730 o a2fccc2e7b08 (public): SPAM SPAM
731 |
732 o 387187ad9bd9 (public): adding fruit
733 |
734 o dfd3a2d7691e (public): adding condiment
735 |
736 o 9ca060c80d74 (public): SPAM
737 |
738 o 7e82d3f3c2cb (public): Monthy Python Shopping list
739
740
741 $ hg log -r 'unstable()'
742 ae45c0c3092a (draft): SPAM SPAM SPAM
743
744 # XXX make prune stabilization works
745 # $ hg stabilize --any
746 # merging shopping
747
748 $ hg graft -O ae45c0c3092a
749 grafting revision 17
750 merging shopping
751
752 $ hg log -G
753 @ 20de1fb1cec5 (draft): SPAM SPAM SPAM
754 |
755 o ffa278c50818 (draft): bathroom stuff
756 |
757 o a2fccc2e7b08 (public): SPAM SPAM
758 |
759 o 387187ad9bd9 (public): adding fruit
760 |
761 o dfd3a2d7691e (public): adding condiment
762 |
763 o 9ca060c80d74 (public): SPAM
764 |
765 o 7e82d3f3c2cb (public): Monthy Python Shopping list
766
767
768
769 Handling Conflicting amend
770 ----------------------------------------------
771
772 We can detect that multiple diverging//conflicting amend have been made. There
773 will be a "evol-merge" command to merge conflicting amend
774
775 This command is not ready yet.