Trimming dead branches
Eric Siegerman
pub08-hg at davor.org
Fri Feb 13 15:03:35 UTC 2015
On 02/11/2015 04:41 PM, Becker, Mischa J wrote:
> There are three main options for removing those 'failed' commits.
>
> 1. Use evolve to mark the dead branches as obsolete. The commits
aren't physically removed from the repo but are hidden and invisible by
default.
>
> 2. Clone the existing repo to a new repo taking care to exclude the
dead branches from the clone. When done, replace the existing repo with
the clone.
>
> 3. Enable MQ and strip the 'failed' commits from the repo. Do this
on a copy of the repo to make sure you don't accidently break anything.
Once the copy is fixed, replace the original repo. (In TortoiseHg, once
MQ is enabled, you can right-click the bad commit and select Modify
History -> Strip...)
>
Another option is to close them. What that does is to commit a new
changeset that marks the branch as "closed", with these effects (among
others?):
- "hg heads" no longer lists it (unless you use the "-c/--closed" option)
- If all of a named branch's heads are closed, it no longer shows up
in Tortoise's list-of-branches dropdown (but you can change that by
choosing "Display closed branches" from the "Branch" dropdown)
- The "closing" changeset itself looks different in TortoiseHg
Like option (1) above, this doesn't remove the commit, but creates
another one to fix up the problem. (In this respect, I think it's what
you were aiming for with "hg backout", but that wouldn't have done what
you wanted.)
To close a branch:
- From the shell:
- hg checkout {one of the extra commits}
- hg commit --close-branch
- From TortoiseHg:
- Update to one of the extra commits
- Select the Working Directory (top line of the graph)
- Click on the bold-faced "Branch: {branch's name}"
- In the dialog, check "Close current branch", then "OK"
- That fills in a default log message, but edit it if you want
- Click "Commit"
Note that despite its name, "close branch" works just as well on
anonymous heads as it does on actual named branches.
- Eric
More information about the Mercurial
mailing list