Skip to content

Instantly share code, notes, and snippets.

@breyten
Last active February 22, 2019 11:17
Show Gist options
  • Select an option

  • Save breyten/5143040 to your computer and use it in GitHub Desktop.

Select an option

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
Copy Markdown

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
Copy Markdown

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
Copy Markdown

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