Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Close multiple branches in TortoiseHg

I use TortoiseHg 1.1 and in our team we tend to create named branches for each case we work on then merge with default when we're done. Unfortunately most of the named branches don't get closed. This isn't a huge problem but it's annoying when you try and filter by the branch you are currently working on and there is a massive list of old branches to search through.

So is there an easy way in TortoiseHg or from the command line to close multiple branches quickly without having to manually commit and close on each branch?

like image 398
Phil Hale Avatar asked Dec 08 '10 10:12

Phil Hale


1 Answers

Unfortunately no.

You need to close each branch separately with its own commit on that branch.

The best way to do that is to use the command line, you could even create a simple batch file to close a bunch of them:

for %%f in (branch1 branch2 branch4) do (
    hg up "%%f"
    if exitcode 1 goto quit
    hg commit --close-branch -m "closing branch %%f"
    if exitcode 1 goto quit
)
:quit

The workflow I use is to use the bookmarks extension to keep only local bookmarks for my lines of development, this way I use normal unnamed branches in Mercurial, but can still easily tell them apart locally. The commit messages are used to separate them later.

This way I don't have a bunch of named branches cluttering up my history, I don't have to remember to close them, and I only have to keep track of the branches I use locally.

like image 172
Lasse V. Karlsen Avatar answered Sep 30 '22 06:09

Lasse V. Karlsen