This is the second part of a series of posts about the new phases feature we implemented for mercurial 2.1. The first part talks about how phases will help mercurial users, this second part explains how to control them.

Controlling automatic phase movement

Sometimes it may be desirable to push and pull changesets in the draft phase to share unfinished work. Below are some cases:

pushing to continuous integration,

pushing changesets for review,

user has multiple machines,

branch clone.

You can disable publishing behavior in a repository configuration file :

[phases] publish = False

When a repository is set to non-publishing, people push changesets without altering their phase. draft changesets are pushed as draft and public changesets are pushed as public:

celeste@Chessy ~/palace $ hg showconfig phases phases.publish=False

babar@Chessy ~/palace $ hg log --graph @ [draft] add a carpet (2afbcfd2af83) | o [public] Add a table in the kichen (139ead8a540f) | o [public] Add wall color (0d1feb1bca54) | … babar@Chessy ~/palace $ hg outgoing ~celeste/palace/ [public] Add wall color (0d1feb1bca54) [public] Add a table in the kichen (139ead8a540f) [draft] add a carpet (3c1b19d5d3f5) babar@Chessy ~/palace $ hg push ~celeste/palace/ pushing to ~celeste/palace/ searching for changes adding changesets adding manifests adding file changes added 3 changesets with 3 changes to 2 files babar@Chessy ~/palace $ hg log --graph @ [draft] add a carpet (2afbcfd2af83) | o [public] Add a table in the kichen (139ead8a540f) | o [public] Add wall color (0d1feb1bca54) | …

celeste@Chessy ~/palace $ hg log --graph o [draft] add a carpet (2afbcfd2af83) | o [public] Add a table in the kichen (139ead8a540f) | o [public] Add wall color (0d1feb1bca54) | …

And pulling gives the phase as in the remote repository:

celeste@Chessy ~/palace $ hg up 139ead8a540f celeste@Chessy ~/palace $ echo The wall will be decorated with portraits >> bedroom celeste@Chessy ~/palace $ hg ci -m 'Decorate the wall.' created new head celeste@Chessy ~/palace $ hg log --graph @ [draft] Decorate the wall. (3389164e92a1) | | o [draft] add a carpet (3c1b19d5d3f5) |/ o [public] Add a table in the kichen (139ead8a540f) | o [public] Add wall color (0d1feb1bca54) | … --- babar@Chessy ~/palace $ hg pull ~celeste/palace/ pulling from ~celeste/palace/ searching for changes adding changesets adding manifests adding file changes added 1 changesets with 1 changes to 1 files (+1 heads) babar@Chessy ~/palace $ hg log --graph @ [draft] Decorate the wall. (3389164e92a1) | | o [draft] add a carpet (3c1b19d5d3f5) |/ o [public] Add a table in the kichen (139ead8a540f) | o [public] Add wall color (0d1feb1bca54) | …

Phase information is exchanged during pull and push operations. When a changeset exists on both sides but within different phases, its phase is unified to the lowest phase. For instance, if a changeset is draft locally but public remotely, it is set public:

celeste@Chessy ~/palace $ hg push -r 3389164e92a1 pushing to http://hg.celesteville.com/palace searching for changes adding changesets adding manifests adding file changes added 1 changesets with 1 changes to 1 files celeste@Chessy ~/palace $ hg log --graph @ [public] Decorate the wall. (3389164e92a1) | | o [draft] add a carpet (3c1b19d5d3f5) |/ o [public] Add a table in the kichen (139ead8a540f) | o [public] Add wall color (0d1feb1bca54) | … --- babar@Chessy ~/palace $ hg pull ~celeste/palace/ pulling from ~celeste/palace/ searching for changes no changes found babar@Chessy ~/palace $ hg log --graph @ [public] Decorate the wall. (3389164e92a1) | | o [draft] add a carpet (3c1b19d5d3f5) |/ o [public] Add a table in the kichen (139ead8a540f) | o [public] Add wall color (0d1feb1bca54) | …

Note pull is read-only operation and does not alter phases in remote repositories.

You can also control the phase in which a new changeset is committed. If you don't want new changesets to be pushed without explicit consent, update your configuration with:

[phases] new-commit = secret

You will need to use manual phase movement before you can push them. See the next section for details: