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()"
For more info, https://www.mercurial-scm.org/repo/hg/help/phases
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
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:
hg clone REPO_NAME CLONED_REPO_NAME
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.
Make sure all changes are committed in each repo. Then cd into the first repo and type:
hg pull PATH_TO_CLONE
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:
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).
- ***MAKE SURE BOTH REPOS ARE COMMITTED***
- Select the original repo
- Click on the Sync Button
- Select the cloned repo.
- Click the pull button to start the merge.
- Right click on the clone branch and select “Merge with Local”
- Click on the Resolve link to pull up the resolve GUI.