Wednesday, May 21, 2014

Close old hg branches with powershell

Another silly post combining my two favorite tools: Mercurial and Powershell.

If you use named branches as part of your development workflow you may occasionally forget to close a branch after you merge it back in.  Or you might abandon a branch and never get back to it.  And if you use sub repositories, sometimes it can be impossible to update back to those old revisions...  And even if you don't get an error when you update back, it's still super slow to checkout all those old files just to mark the branch closed.

To address all those issues, I just used this little powershell script:
function closeoldbranch($branchname)
  hg debugsetparent $branchname
  hg branch $branchname
  hg ci --close-branch -m "closes old branch"
I don't recommend that you make a habit of using this technique, but I did just get a lot of use out of it! So enjoy it, but be careful!

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.