Skip to content

Instantly share code, notes, and snippets.

@ScottG489
Created November 13, 2015 21:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ScottG489/5a7d7eac431159521845 to your computer and use it in GitHub Desktop.
Save ScottG489/5a7d7eac431159521845 to your computer and use it in GitHub Desktop.
backouter () {
if [ $# -ne 1 ]
then
echo Backout a merge by closing branch of undesired merge then updating to parent of undesired merge and continuing branch from there.
echo usage: backouter BAD_MERGE_PARENT
return
fi
hg pull -u && _REV_PARENT=$1
_BRANCH=$(hg log -r $_REV_PARENT --template '{branch}')
_TEMP_FILE=tempfile
hg update $_BRANCH && hg commit --close-branch -m "Close head of undesired merge." && hg update $_REV_PARENT && touch $_TEMP_FILE
hg add $_TEMP_FILE
hg commit -m "Continue branch from parent of bad merge ($_REV_PARENT)."
hg rm $_TEMP_FILE
hg commit -m "Remove temp file created for merge 'backout'."
echo
echo 'WILL NEED TO PUSH WITH --force'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment