Create a gist now

Instantly share code, notes, and snippets.

@rustyio /subhg
Created Jan 24, 2010

What would you like to do?
subhg
#!/usr/bin/env sh
# subhg
#
# A tiny wrapper around hg to help you manage
# Mercurial sub-projects easily, safely, and simply.
#
# Created by Rusty Klophaus (@rklophaus)
#
# See http://rklophaus.com/subhg for usage.
if [ "$1" == "setup" ]; then
if [ -d ".hg" ]; then
mv .hg .subhg
echo "Converted to a subhg repository."
exit 0
else
echo "Could not find .hg directory."
exit -1
fi
fi
DIR=`pwd`
while [ ! -d "$DIR/.subhg" ] && [ ! "$DIR" == "/" ]; do
DIR=`dirname $DIR`
done
if [ $DIR == "/" ]; then
echo "Not in a subhg repository!"
exit -1
fi
mv $DIR/.subhg $DIR/.hg
(hg "$@")
mv $DIR/.hg $DIR/.subhg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment