Is it possible to reopen a closed branch in Mercurial?

34,713

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.

Share:
34,713
Lóránt Pintér
Author by

Lóránt Pintér

Updated on July 29, 2020

Comments

  • Lóránt Pintér
    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
    Francis Upton IV about 13 years
    The 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
    Tim Delaney about 13 years
    Thanks 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
    Mathieu Le Tiec over 11 years
    A tag is sufficient to make it commitable.
  • Nate Cook
    Nate Cook over 9 years
    I 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
    Rafael Piccolo over 9 years
    This is adding a useless empty file to the repository, it's wrong.
  • DaveN59
    DaveN59 over 8 years
    This 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
    Mathieu Dierckx over 6 years
    Used it (command line via terminal in phpstorm) and works like a charm, thanks