Skip to content

Instantly share code, notes, and snippets.

@mikedeboer
Last active December 15, 2015 05:19
Show Gist options
  • Save mikedeboer/5208233 to your computer and use it in GitHub Desktop.
Save mikedeboer/5208233 to your computer and use it in GitHub Desktop.
This script takes your Hg queue, unwinds it and applies each and every queue separately. It then generates a patch to a local directory of the qtip, applies the next queue item until it's back to where it started (all queue items applied).
#!/bin/bash
# Author: Mike de Boer <mdeboer AT mozilla.com>
# This script takes your Hg queue, unwinds it if needed and applies each and
# every queue separately. It then generates a patch to a local directory of the
# qtip, applies the next queue item until it's back to where it started.
_gen_patches() {
local i len
local patches=($(hg qapplied 2>/dev/null))
len=${#patches[@]}
if (( len>1 )) ; then
hg qpop -a > /dev/null
fi
# go through the array in reverse order
for (( i=0 ; i<len ; i++ )) ; do
patch=${patches[i]}
echo "Generating patch for queue item ${patch}"
if (( len>1 )) ; then
hg qpush ${patch} > /dev/null
fi
# I save patches to my homedir, but feel free to change the patch output path
# to whatever you want.
hg export qtip > ~/Patches/${patch}.patch
done
}
_gen_patches "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment