Hg Drafts

Sometimes when I merge hg branches and push to bitbucket, the merges are labelled as “draft”. To convert those changes to public, I run:

hg phase --public "draft()"
hg log -r "not public()"
hg push

For more info, https://www.mercurial-scm.org/repo/hg/help/phases


Fixing Hg Mistakes

Removing Pushes from Other Branches

I often create a branch by cloning. I do more involved or experimental things in the clone. While the parent branch is available to make small minor updates. As code in the branch progresses, I do commits. And every once in a while, by accident, I do a commit and push. This puts the experimental code in the main branch before its ready. To remove the pushed change set, cd into main and do:

hg strip -r REV

Clone and Merge Using Mercurial

These are just simple notes for cloning an hg repo and merging them together after changes have been made in the clone or both repos.


Cd to the directory that contains the repo you want to clone. Type:


This clones the repo into the same directory as the original.

Or if you are using TortoiseHg, right click on the repo in the side panel that lists all repos and select clone.

Manual Merge

Make sure all changes are committed in each repo. Then cd into the first repo and type:

hg update
hg merge

Relative paths work. At this point if there are conflicts between the original and the clone, they will need to be resolved (more on that later). If there are no conflicts, type:

hg commit

It’s interesting to consider what a conflict is. If a file is altered in one repo and not another, then merge just takes the altered version and over-writes the original. In my case, I am often cloning a Django project. By cloning, I can make quick minor changes (bug fixes) to the original and do major changes in the clone. To do this, I usually need to alter the settings file in the clone to point to a cloned version of the database. Major changes often involve major changes to the db. When I merge, usually no changes will have been made to settings.py. Thus after merge, the db will be wrong.

Merge Using TortoiseHg

When it comes to resolving merge conflicts, I prefer a graphical interface. Here is how to merge using TortoiseHg (v2.2).

  2. Select the original repo
  3. Click on the Sync Button Screenshot from 2015-02-01 13:59:46
  4. Select the cloned repo.
  5. Click the pull button Screenshot from 2015-02-01 14:06:08 to start the merge.
  6. Right click on the clone branch and select “Merge with Local”
  7. Click on the Resolve link to pull up the resolve GUI.