Stash Mercurial uncommitted changes. Simple, safe, and branch-friendly.
hg shelve
can destroy your work, especially if you're working on multiple branches. mq
is too much when all you need is a simple shelve tool.
The simpler and safer solution is to shelve using patch files. This script is a thin wrapper around built-in Mercurial commands for importing and exporting patch files.
usage: jig [options] command [name]
Stash Mercurial working directory changes.
Simple, safe, and branch-friendly.
Commands:
stash export changes to a patch file
unstash import changes from a patch file
list list patch files
show show the contents of a patch file
Arguments:
name name of the patch file to use
(excluding file extension)
(defaults to the current branch name)
Options:
-h, --help print this text and exit
-f, --force overwrite an existing patch file
If you're worried that this script is going to destroy your repository and run rm -rf /
, I recommend looking over the script. At about 100 LOC it makes for a quick read. Here's the gist:
jig stash
essentially runs:
hg diff > $patchfile
hg revert --all
jig unstash
essentially runs:
hg import --no-commit $patchfile
First, ensure the jig
script is in your $PATH
; either mv
/cp
the script or add your repo clone to your $PATH
.
To use jig
like a Mercurial sub-command, add aliases to your hgrc
:
[alias]
stash = !jig stash $@
unstash = !jig unstash $@
jig-list = !jig list $@
jig-show = !jig show $@