Yesterday evening in was in a bit of a fix at work, I was working on a new feature-name mercurial branch and and committed a few things into the branch and posted the changes onto a review system we have at work. after the team reviewed my changes it was time to push them over and merge it with the main "DEFAULT" branch.
So I started and did as follows:
hg stShould show no modified files.
Make sure your working copy is based on the branch:
hg branchIt should report the name of the feature branch.
hg update feature-nameClose out the branch if it's a Feature Branch
hg commit --close-branch -m "closed branch feature-name"Update working copy to be based off of the default branch instead of the branch:
hg update defaultMerge from the branch to default (assuming feature-name is the name of the branch you are merging to default):
hg merge feature-nameWhen everything looks good, commit the merge hg commit -m "merged feature-name branch to default"and at last push the merge onto default.I did the above step by step but then at last the "hg push" aborted with an error, So now what to do.I looked back and realize that I didnt push the changes into the feature barnch (though committed them), but now have so many change sets and I am on Default branch now.
I update back to my feture branch and want to be at the same change set where I started so here comes "hg strip" to my rescue, though there can other solution too, I used hg strip to strip off all the change set and start over merging into default again.
Okay so now What is that hg strip command do...here is brief explanation below:
hg strip rev removes the rev revision and all its descendants from a repository. To remove an unwanted branch, you would specify the first revision specific to that branch. By default, hg strip will place a backup in the .hg/strip-backup/ directory. If strip turned out to be a bad idea, you can restore with hg unbundle .hg/strip-backup/filename.
If others revision in the repository have higher number than the stripped one, those one are renumbered in order to keep a sequential numbering scheme. The hash remains the same.