Close current or passed branch with user verification, guards against closing default. I use this when I need to prune a lot of dead branches, but don't want to go full-auto.
@echo off if not -%1-==-- ( hg update %~1 ) for /f "delims=" %%i in ('hg id') do set _branch="%%i" for /f "delims=" %%i in ('hg id -i') do set _branch_id=%%i if /I %_branch%==default ( echo default branch selected. If you want to close the default branch do it manually. exit /b ) echo Are you sure that you want to close branch: %_branch% ? choice /C:Yn /D n /T:10 if ERRORLEVEL==2 ( echo No further operations will be done. exit /b ) else ( echo Closing branch: %_branch% echo Moving to branch: %_branch% hg update %_branch_id% echo: echo committing changes hg commit --close-branch -m "closing branch: %_branch_id%" echo pushing changes to repo hg push echo moving to default hg update default -C ) exit /b @echo on