+# mercurial related stuff {{{
+ if type -p hg &>/dev/null ; then
+ # gnu like diff for mercurial
+ # http://www.selenic.com/mercurial/wiki/index.cgi/TipsAndTricks
+ hgdi() {
+ for i in `hg status -marn "$@"` ; diff -ubwd <(hg cat "$i") "$i"
+ }
+
+ # build debian package
+ alias hbp='hg-buildpackage'
+
+ # diffstat for specific version of a mercurial repository
+ # hgstat => display diffstat between last revision and tip
+ # hgstat 1234 => display diffstat between revision 1234 and tip
+ hgstat() {
+ [ -n "$1" ] && hg diff -r $1 -r tip | diffstat || hg export tip | diffstat
+ }
+
+ # get current mercurial tip via hg itself
+ gethgclone() {
+ setopt local_options
+ setopt errreturn
+ if [ -f mercurial-tree/.hg ] ; then
+ cd mercurial-tree
+ echo "Running hg pull for retreiving latest version..."
+ hg pull
+ echo "Finished update. Building mercurial"
+ make local
+ echo "Setting \$PATH to $PWD:\$PATH..."
+ export PATH="$PWD:$PATH"
+ else
+ echo "Downloading mercurial via hg"
+ hg clone http://selenic.com/repo/hg mercurial-tree
+ cd mercurial-tree
+ echo "Building mercurial"
+ make local
+ echo "Setting \$PATH to $PWD:\$PATH..."
+ export PATH="$PWD:$PATH"
+ echo "make sure you set it permanent via ~/.zshrc if you plan to use it permanently."
+ # echo "Setting \$PYTHONPATH to PYTHONPATH=\${HOME}/lib/python,"
+ # export PYTHONPATH=${HOME}/lib/python
+ fi
+ }
+
+ fi # end of check whether we have the 'hg'-executable
+
+ # get current mercurial snapshot
+ gethgsnap() {
+ setopt local_options
+ setopt errreturn
+ if [ -f mercurial-snapshot.tar.gz ] ; then
+ echo "mercurial-snapshot.tar.gz exists already, skipping download."
+ else
+ echo "Downloading mercurial snapshot"
+ wget http://www.selenic.com/mercurial/mercurial-snapshot.tar.gz
+ fi
+ echo "Unpacking mercurial-snapshot.tar.gz"
+ tar zxf mercurial-snapshot.tar.gz
+ cd mercurial-snapshot/
+ echo "Installing required build-dependencies"
+ $SUDO apt-get update
+ $SUDO apt-get install python2.4-dev
+ echo "Building mercurial"
+ make local
+ echo "Setting \$PATH to $PWD:\$PATH..."
+ export PATH="$PWD:$PATH"
+ echo "make sure you set it permanent via ~/.zshrc if you plan to use it permanently."
+ }