summarylogtreecommitdiffstats
path: root/subhg
blob: 0fc376eb17d7e3139c79a3df15501c020bafda4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/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://blog.rusty.io/2010/01/24/submodules-and-subrepos-done-right/ 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