mercurial phases

Hello again!

Now I’m working on adding dry-run for mercurial phases. If you use mercurial, you would probably know what phases are, but for those who don’t know, let me tell you a little bit about phases:

What are phases?

Please keep in mind that changeset/cset/commit are almost same things. In mercurial, this feature named phases keeps track of which cset should be shared. And it is decided on the basis of what is the phase of that cset.

Each  cset in a repository is in one of the following phase:

  • public – cset is visible on a public server
  • draft – cset is not yet published
  • secret – cset should not be pushed, pulled or cloned

And following is the order of phases and no cset can be in a lower phase than its ancestors:

public < draft < secret

If you want to know more about phases:

Implementation and Dry-run:

Coming to my work, I have to add dry-run functionality to phases. And first time when I saw implementation of phases and how internally phases works, it was interesting to know that mercurial don’t store phase value for each cset infact it only store phaseroots (roots of phases DAG in you history log) and use these phaseroots for every calculation related to phases. Before you go ahead you should know how to use phase command, if  you don’t, then first read about this.

The expected result from dry-run is to show that what would be the result of phase commands (I will show you) if we run the commands without dry-run, like:

hg phase –draft -r revs –dry-run


f7b1eb17ad24 : : 14b465a7e25b   secret -> draft

cannot move 2 changesets to a higher phase, use –force

Result showed the range of those revisions whose phases can be changed to draft (csets which are in secret phase) and message to tell user to use –force for rejected csets(which are in public phase).

Following is the link to my work, for now it’s just print all nodes and my remaining work is to show range instead of showing all the nodes.

phase: add dry-run functionality


Leave a Reply

Your email address will not be published. Required fields are marked *