Is it possible to reopen a closed branch in Mercurial?
Solution 1
You can just hg update
to the closed branch then do another hg commit
and it will automatically reopen.
The closed
flag is just used to filter out closed branches from hg branches
and hg heads
unless you use the --closed
option - it doesn't prevent you from using the branches.
Solution 2
You can reopen a branch by using the "-f" flag when 'creating' the branch.
No, this command will create a new branch with the same name.
Just forget that it's closed. Switch to the branch, make the changes and commit. It will be automatically reopened. When you're done you can close it again.
Solution 3
try with following:
hg pull && hg update branch_name
Now make a small change to one of the file and then commit it
hg commit -m "minor change"
then push it
hg push -b .
Now you should be able to work normally.
Lóránt Pintér
Updated on July 29, 2020Comments
-
Lóránt Pintér almost 4 years
I understand that it is possible to close a named branch in Mercurial, so that it will not appear in the
hg branches
list:hg commit --close-branch -m 'close badbranch, this approach never worked'
Is it possible to later re-open the branch if need be?
-
Francis Upton IV about 13 yearsThe commit won't do anything unless there is something to actually commit, so you may need to make a gratuitous change to make it happen.
-
Tim Delaney about 13 yearsThanks for pointing it out - I'd assumed that changes were implied by doing a commit, but of course if you simply want to remove the closed flag you can't without a change.
-
Mathieu Le Tiec over 11 yearsA tag is sufficient to make it commitable.
-
Nate Cook over 9 yearsI thought that, unlike Git, Mercurial named branches are permanent, and that branch names therefore can't be re-used. What am I confusing? Is it multiple heads for the same branch that we're talking about?
-
Rafael Piccolo over 9 yearsThis is adding a useless empty file to the repository, it's wrong.
-
DaveN59 over 8 yearsThis may work from the command line interface, I haven't tried it yet, but TortoiseHg won't let you update to a closed branch. If you try to do so, the Update button is disabled.To get this to work I had to update to the branch before the close changeset (effectively the parent) and then update to the close changeset. Odd thing is, when you update to the parent, TortoiseHg claims the close changeset (the descendant) is the parent. Whatever, it works just fine once you jump through the proper hoops.
-
Mathieu Dierckx over 6 yearsUsed it (command line via terminal in phpstorm) and works like a charm, thanks