docs/user-guide.rst
changeset 4618 803d32f4e498
parent 4616 a78310b900e3
child 4620 a05bfdf372fb
equal deleted inserted replaced
4617:2cab06f5c4d4 4618:803d32f4e498
   334 ======================
   334 ======================
   335 
   335 
   336 So far, every obsolete changeset we have seen is also hidden. However,
   336 So far, every obsolete changeset we have seen is also hidden. However,
   337 these are *not* the same thing—that's why they have different names.
   337 these are *not* the same thing—that's why they have different names.
   338 It's entirely possible to have obsolete changesets that are not
   338 It's entirely possible to have obsolete changesets that are not
   339 hidden. We'll see examples of that soon, when we create *unstable*
   339 hidden. We'll see examples of that soon, when we create *orphan*
   340 changesets.
   340 changesets.
   341 
   341 
   342 Note that all hidden changesets are obsolete: hidden is a subset of
   342 Note that all hidden changesets are obsolete: hidden is a subset of
   343 obsolete. This is explained in more depth in the `concepts`_ section.
   343 obsolete. This is explained in more depth in the `concepts`_ section.
   344 
   344 
   347 Life with ``evolve`` (advanced usage)
   347 Life with ``evolve`` (advanced usage)
   348 -------------------------------------
   348 -------------------------------------
   349 
   349 
   350 Now that you've got a solid understanding of how ``evolve`` works in
   350 Now that you've got a solid understanding of how ``evolve`` works in
   351 concert with changeset obsolescence, let's explore some more advanced
   351 concert with changeset obsolescence, let's explore some more advanced
   352 scenarios. All of these scenarios will involve *unstable* changesets,
   352 scenarios. All of these scenarios will involve *orphan* changesets,
   353 which is an unavoidable consequence of obsolescence. What really sets
   353 which is an unavoidable consequence of obsolescence. What really sets
   354 ``evolve`` apart from other history modification mechanisms is the
   354 ``evolve`` apart from other history modification mechanisms is the
   355 fact that it recognizes instability like unstable changesets and provides
   355 fact that it recognizes instability like orphan changesets and provides
   356 a consistent way for you to get back to a stable repository.
   356 a consistent way for you to get back to a stable repository.
   357 
   357 
   358 (Incidentally, there are two other types of instability that changesets
   358 (Incidentally, there are two other types of instability that changesets
   359 can get into with ``evolve``: they may be *divergent* or
   359 can get into with ``evolve``: they may be *divergent* or
   360 *bumped*. Both of those states are more likely to occur when
   360 *bumped*. Both of those states are more likely to occur when
   391   $ hg update 11
   391   $ hg update 11
   392   [...fix mistake...]
   392   [...fix mistake...]
   393   $ hg amend
   393   $ hg amend
   394 
   394 
   395 At this point, revision 11 is *obsolete* and revisions 12 and 13—the
   395 At this point, revision 11 is *obsolete* and revisions 12 and 13—the
   396 descendants of 11—are in a funny state: they are *unstable*.
   396 descendants of 11—are in a funny state: they are *orphan*.
   397 
   397 
   398 .. figure:: figures/figure-ug06.svg
   398 .. figure:: figures/figure-ug06.svg
   399 
   399 
   400    Figure 6: amending a changeset with descendants means the amended
   400    Figure 6: amending a changeset with descendants means the amended
   401    changeset is obsolete but remains visible; its non-obsolete
   401    changeset is obsolete but remains visible; its non-obsolete
   402    descendants are *unstable*. The temporary amend commit, revision
   402    descendants are *orphan*. The temporary amend commit, revision
   403    14, is hidden because it has no non-obsolete descendants.
   403    14, is hidden because it has no non-obsolete descendants.
   404 
   404 
   405 All non-obsolete descendants of an obsolete changeset are considered
   405 All non-obsolete descendants of an obsolete changeset are considered
   406 unstable. An interesting consequence of this is that revision 11 is
   406 orphans. An interesting consequence of this is that revision 11 is
   407 still visible, even though it is obsolete. Obsolete changesets with
   407 still visible, even though it is obsolete. Obsolete changesets with
   408 non-obsolete descendants are not hidden.
   408 non-obsolete descendants are not hidden.
   409 
   409 
   410 The fix is to *evolve* history::
   410 The fix is to *evolve* history::
   411 
   411 
   423 (15-17) replace them.
   423 (15-17) replace them.
   424 
   424 
   425 .. figure:: figures/figure-ug07.svg
   425 .. figure:: figures/figure-ug07.svg
   426 
   426 
   427    Figure 7: evolve your repository (``hg evolve --all``) to take care
   427    Figure 7: evolve your repository (``hg evolve --all``) to take care
   428    of instability. Unstable changesets become obsolete, and are
   428    of instability. Orphan changesets become obsolete, and are
   429    replaced by successors just like the amended changeset was.
   429    replaced by successors just like the amended changeset was.
   430 
   430 
   431 Example 8: Prune an older changeset
   431 Example 8: Prune an older changeset
   432 ===================================
   432 ===================================
   433 
   433 
   439 
   439 
   440 You want to drop revision 19, but keep 18 and 20. No problem::
   440 You want to drop revision 19, but keep 18 and 20. No problem::
   441 
   441 
   442   $ hg prune 19
   442   $ hg prune 19
   443   1 changesets pruned
   443   1 changesets pruned
   444   1 new unstable changesets
   444   1 new orphan changesets
   445 
   445 
   446 As above, this leaves your repository in a funny intermediate state:
   446 As above, this leaves your repository in a funny intermediate state:
   447 revision 20 is the non-obsolete descendant of obsolete revision 19.
   447 revision 20 is the non-obsolete descendant of obsolete revision 19.
   448 That is, revision 20 is unstable.
   448 That is, revision 20 is an orphan.
   449 
   449 
   450 .. figure:: figures/figure-ug08.svg
   450 .. figure:: figures/figure-ug08.svg
   451 
   451 
   452    Figure 8: ``hg prune`` marks a changeset obsolete without creating
   452    Figure 8: ``hg prune`` marks a changeset obsolete without creating
   453    a successor. Just like with ``hg amend``, non-obsolete descendants
   453    a successor. Just like with ``hg amend``, non-obsolete descendants
   454    of the pruned changeset are now unstable.
   454    of the pruned changeset are now orphans.
   455 
   455 
   456 As before, the solution to unstable changesets is to evolve your
   456 As before, the solution to orphan changesets is to evolve your
   457 repository::
   457 repository::
   458 
   458 
   459   $ hg evolve --all
   459   $ hg evolve --all
   460 
   460 
   461 This rebases revision 20 on top of 18 as the new revision 21, leaving
   461 This rebases revision 20 on top of 18 as the new revision 21, leaving
   483 directory::
   483 directory::
   484 
   484 
   485   $ hg update 22
   485   $ hg update 22
   486   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   486   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   487   $ hg uncommit file2.c
   487   $ hg uncommit file2.c
   488   1 new unstable changesets
   488   1 new orphan changesets
   489   $ hg status
   489   $ hg status
   490   M file2.c
   490   M file2.c
   491 
   491 
   492 Now your repository has unstable changesets, so you need to evolve it.
   492 Now your repository has orphan changesets, so you need to evolve it.
   493 However, ``hg evolve`` requires a clean working directory to resolve merge
   493 However, ``hg evolve`` requires a clean working directory to resolve merge
   494 conflicts, so you need to decide what to do with ``file2.c``.
   494 conflicts, so you need to decide what to do with ``file2.c``.
   495 
   495 
   496 In this case, the change to ``file2.c`` was a temporary debugging
   496 In this case, the change to ``file2.c`` was a temporary debugging
   497 hack, so we can discard it and immediately evolve the instability away::
   497 hack, so we can discard it and immediately evolve the instability away::
   528 ``file2.c`` in the working dir::
   528 ``file2.c`` in the working dir::
   529 
   529 
   530   $ hg update -q 26
   530   $ hg update -q 26
   531   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   531   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   532   $ hg uncommit -q file2.c  # obsoletes rev 26, creates rev 28
   532   $ hg uncommit -q file2.c  # obsoletes rev 26, creates rev 28
   533   1 new unstable changesets
   533   1 new orphan changesets
   534   $ hg status
   534   $ hg status
   535   M file2.c
   535   M file2.c
   536 
   536 
   537 This time, let's save that useful change before evolving::
   537 This time, let's save that useful change before evolving::
   538 
   538 
   539   $ hg commit -m 'useful tweak'                   # rev 29
   539   $ hg commit -m 'useful tweak'                   # rev 29
   540 
   540 
   541 Figure 11 shows the story so far: ``uncommit`` obsoleted revision 26
   541 Figure 11 shows the story so far: ``uncommit`` obsoleted revision 26
   542 and created revision 28, the successor of 26. Then we committed
   542 and created revision 28, the successor of 26. Then we committed
   543 revision 29, a child of 28. We still have to deal with the revision 27,
   543 revision 29, a child of 28. We still have to deal with the revision 27,
   544 which is an unstable changeset.
   544 which is an orphan changeset.
   545 
   545 
   546 .. figure:: figures/figure-ug11.svg
   546 .. figure:: figures/figure-ug11.svg
   547 
   547 
   548    Figure 11: Uncommitting a file and then committing that change
   548    Figure 11: Uncommitting a file and then committing that change
   549    separately will soon result in a two-headed repository.
   549    separately will soon result in a two-headed repository.
   550 
   550 
   551 This is where things get tricky. As usual when a repository has
   551 This is where things get tricky. As usual when a repository has
   552 unstable changesets, we want to evolve it::
   552 orphan changesets, we want to evolve it::
   553 
   553 
   554   $ hg evolve --all
   554   $ hg evolve --all
   555 
   555 
   556 The problem is that ``hg evolve`` rebases revision 27 onto revision
   556 The problem is that ``hg evolve`` rebases revision 27 onto revision
   557 28, creating 30 (the successor of 27). This is entirely logical: 27
   557 28, creating 30 (the successor of 27). This is entirely logical: 27
   559 successor (30) should be the child of 26's successor (28).
   559 successor (30) should be the child of 26's successor (28).
   560 Unfortunately, that leaves us with a two-headed repository:
   560 Unfortunately, that leaves us with a two-headed repository:
   561 
   561 
   562 .. figure:: figures/figure-ug12.svg
   562 .. figure:: figures/figure-ug12.svg
   563 
   563 
   564    Figure 12: ``evolve`` takes care of unstable changesets; it does
   564    Figure 12: ``evolve`` takes care of orphan changesets; it does
   565    not solve all the world's problems.
   565    not solve all the world's problems.
   566 
   566 
   567 As usual when faced with a two-headed repository, you can either merge
   567 As usual when faced with a two-headed repository, you can either merge
   568 or rebase. It's up to you.
   568 or rebase. It's up to you.
   569 
   569 
   592 
   592 
   593 The current implementation of ``hg touch`` is not ideal, and is likely to
   593 The current implementation of ``hg touch`` is not ideal, and is likely to
   594 change in the future. Consider the history in Figure 12, where revision 27
   594 change in the future. Consider the history in Figure 12, where revision 27
   595 is obsolete and the child of 26, also obsolete. If we ``hg touch 27``, that
   595 is obsolete and the child of 26, also obsolete. If we ``hg touch 27``, that
   596 creates a new revision which is a non-obsolete child of 26—i.e., it is an
   596 creates a new revision which is a non-obsolete child of 26—i.e., it is an
   597 unstable. It's also *divergent*, another type of trouble that we'll learn
   597 orphan. It's also *divergent*, another type of trouble that we'll learn
   598 about in the `next section`_.
   598 about in the `next section`_.
   599 
   599 
   600 .. _`next section`: sharing.html
   600 .. _`next section`: sharing.html