Skip to content

Instantly share code, notes, and snippets.

@breyten
Last active February 22, 2019 11:17
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save breyten/5143040 to your computer and use it in GitHub Desktop.
Save breyten/5143040 to your computer and use it in GitHub Desktop.
Automatically close inactive mercurial branches (use with care!)
for i in `hg branches |grep -v 'default' |grep -v 'production' |grep inactive |awk '{print $1}'`; do hg update $i && hg commit -m "close branch" --close-branch; done
@girishmuraly
Copy link

Very useful, thanks! Would be nice to parametrize the branches to exclude (default, production etc.). Also an output of hg out at the end for confirmation & doing a hg push thereafter would be icing on the cake :)

@ynechaev
Copy link

Unfortunately this script doesn't work when branches named with spaces, {print $1} takes first string, wich is just the first part of branch name.

@ynechaev
Copy link

I have added several changes to make this script possible close branches named with white spaces https://gist.github.com/RebornSoul/6c0a618466eade87df26#file-hg-close-inactive-branches-sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment