comparison docs/tutorials/tutorial.t @ 764:4a74288c671c stable

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