X-Git-Url: http://gitweb.pimeys.fr/?a=blobdiff_plain;f=.zsh%2Frc%2Fextra%2F02_mercurial;fp=.zsh%2Frc%2Fextra%2F02_mercurial;h=7a7e500968ca44d2a60435842fa0cfb07acb437d;hb=3d71eab53c5b63556363ece880859b0af7f162da;hp=0000000000000000000000000000000000000000;hpb=1f8b08895681d46802368eec0764ca70d08898ca;p=config-20-100.git diff --git a/.zsh/rc/extra/02_mercurial b/.zsh/rc/extra/02_mercurial new file mode 100644 index 0000000..7a7e500 --- /dev/null +++ b/.zsh/rc/extra/02_mercurial @@ -0,0 +1,79 @@ +#!/bin/zsh + +# mercurial related stuff {{{ +if check_com -c hg ; then + # gnu like diff for mercurial + # http://www.selenic.com/mercurial/wiki/index.cgi/TipsAndTricks + #f5# GNU like diff for mercurial + hgdi() { + emulate -L zsh + for i in $(hg status -marn "$@") ; diff -ubwd <(hg cat "$i") "$i" + } + + # build debian package + #a2# Alias for \kbd{hg-buildpackage} + alias hbp='hg-buildpackage' + + # execute commands on the versioned patch-queue from the current repos + alias mq='hg -R $(readlink -f $(hg root)/.hg/patches)' + + # 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 + #f5# Diffstat for specific version of a mercurial repos + hgstat() { + emulate -L zsh + [[ -n "$1" ]] && hg diff -r $1 -r tip | diffstat || hg export tip | diffstat + } + + #f5# Get current mercurial tip via hg itself + gethgclone() { + emulate -L zsh + 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 +#f5# Get current mercurial snapshot +gethgsnap() { + emulate -L zsh + 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." +}