docs/evolve-faq.rst
author Pierre-Yves David <pierre-yves.david@fb.com>
Thu, 09 Jan 2014 21:22:41 -0800
branchstable
changeset 768 b116de5dc70d
parent 662 40854e956315
child 777 1ff262281a1d
permissions -rw-r--r--
tutorial: fix some various typo

.. Copyright 2011 Pierre-Yves David <pierre-yves.david@ens-lyon.org>
..                Logilab SA        <contact@logilab.fr>

---------------------------------------------------------------------
Evolve How To
---------------------------------------------------------------------



Add a changeset: ``commit``
------------------------------------------------------------

Just use commit as usual. New changesets will be in the `draft` phase.

Rewrite a changeset: ``amend``
------------------------------------------------------------

A new command ``hg amend`` is added by the extension. It writes a new
changeset combining working-directory parent changes and parent. It
will work on any `draft` or `secret` changeset. It will not work on
`public` changesets.

To understand what the result of amend will be I use the two following
aliases   [#]_::

    # diff what amend will look like
    pdiff=diff --rev .^

    # status what amend will look like
    pstatus=status --rev .^

It takes various options to pick an author, a date, and the branch of the
result (see ``hg help amend`` for details).

This command can even be invoked on changesets with children, provided
none are public.

.. note:: As the amend command is very similar to mq's ``qrefresh``, a ``refresh``
          alias for amend is also available. But note that contrary to
          ``qrefresh``, ``amend`` does not exclude changes on file not specified
          on the command line.

          XXX add idank example


.. [#] (defined by the evolve extension for you)



Move a changeset: ``graft``
------------------------------------------------------------

The graft command introduced in 2.0 allows you to "copy changes from other
branches onto the current branch".

The graft command has been altered to allow the creation of an
obsolete marker indicating both the result cset and its source
(actually recording changeset movements).

This is achieved using a new flag `-O` (or `old-obsolete`) [#]_.


XXX example

.. warning:: when using graft --continue after conflict resolution you **MUST**
             pass `-O` or `-o` flag again because they are not saved for now


.. [#] add this `-O` to graft instead of a dedicated command is probably
       abusive. But this was very convenient for experimental purposes.
       This will likely change in non experimental release.

Delete a changeset: ``prune``
------------------------------------------------------------

A new ``prune`` command allows removing a changeset.

Just use ``hg prune <some-rev>``.

Moving within the history: ``up`` ``gdown`` and ``gup``
------------------------------------------------------------

While working on mutable part of the history you often need to move between
mutable commits.

You just need to use standard update to work with evolve. For convenience, you
can use ``hg gup`` to move to the child commit or ``hg gdown`` to move to the parent commit.

.. note:: Those commands only exist for the convenience of getting qpush and qpop
          feeling back.

Collapse changesets: ``fold``
------------------------------------------------------------

You can use ``hg fold`` to collapse multiple changesets in a single one.

Getting changes out of a commit
------------------------------------------------------------

The ``hg uncommit`` command lets you rewrite the parent commit without
selected changed files. Target files content is not altered and
appears again as "modified"::

  $ hg st
  M babar
  M celestine
  $ hg commit babar celestine
  $ hg st
  $ hg uncommit celestine
  $ hg status
  M celestine

Split a changeset
-----------------------

To split on file boundaries, just use ``uncommit`` command.

If you need a fine-grained split, there is no official command for that yet.
However, it is easily achieved by manual operation::

  ### you want to split changeset A: 42
  # update to A parent
  $ hg up 42^
  # restore content from A
  $ hg revert -r 42 --all
  # partially commit the first part
  $ hg record
  # commit the second part
  $ hg commit
  # informs mercurial of what appened
  # current changeset (.) and previous one (.^) replace A (42)
  $ hg prune --new . --new .^ 42

For more complexe scenario we recommend the use of the histedit_ extension.

.. _histedit: http://mercurial.selenic.com/wiki/HisteditExtension


Update my current work in progress after a pull
----------------------------------------------

Whenever you are working on some changesets, it is more likely that a pull
will, eventually, import new changesets in your tree.

And it is likely that you will want your work in progress changesets to be
rebased on the top of this newly imported subtree.

Doing so is only a matter of rebasing.



Move multiple changesets: ``rebase``
------------------------------------------------------------

You can still use rebase to move a whole segment of the changeset graph together.

.. warning:: Beware that rebasing obsolete changesets will result in
             conflicting versions of the changesets.

Resolve history troubles: ``evolve``
------------------------------------------------------------

When you rewrite (amend) a changeset with children without rewriting
those children you create *unstable* changesets and *suspended
obsolete* changesets.

When you are finished amending a given changeset, you will want to
declare it stable, in other words rebase its former descendants on its
newest version. This is not done automatically to avoid the
proliferation of useless hidden changesets.


Fix my history afterward: ``prune -n``
------------------------------------------------------------

Sometimes you need to create an obsolete marker by hand. This may happen when
upstream has applied some of your patches for example.

you can use ``hg prune --new <new-changeset> <old-changeset>`` to add obsolete
marker.

Export to mq: ``synchronize``
------------------------------------------------------------

Another extension allows to export your changes to mq.

View diff from the last amend
------------------------------------------------------------

An ``odiff`` alias have been added by ``enable.sh``

:: 
    [alias]
    odiff = diff --rev 'limit(precursors(.),1)' --rev .

View obsolete markers
------------------------------------------------------------

hgview_ is the only viewer that currently supports this feature. You
need version 1.6.2

.. _hgview: http://www.logilab.org/project/hgview/

.. image:: figures/hgview-example.png
    :scale: 50%


You can also use a debug command

    $ hg debugobsolete
      5eb72dbe0cb4 e8db4aa611f6
      c4cbebac3751 4f1c269eab68



Important Note
=====================================================================

View change to your file
------------------------------------------------------------

Extinct changesets are hidden using the *hidden* feature of mercurial.

Only ``hg log``, ``hg glog`` and ``hgview`` support it, other
graphical viewer do not.