Skip to content

Instantly share code, notes, and snippets.

@rustyio
Created January 24, 2010 18:54
Show Gist options
  • Save rustyio/285368 to your computer and use it in GitHub Desktop.
Save rustyio/285368 to your computer and use it in GitHub Desktop.
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