1. Yuya Nishihara
  2. dotfiles

Commits

Yuya Nishihara  committed 46c4e97

thg: rewrite to switch HGPATH by default/stable branch

  • Participants
  • Parent commits d5d60fe
  • Branches default

Comments (0)

Files changed (1)

File bin/thg

View file
  • Ignore whitespace
 #!/bin/sh -e
-HG_ROOT="$HOME/work/hghacks/mercurial"
-THG_ROOT="$HOME/work/hghacks/thg"
 
-if [ -f "$HG_ROOT/hg" ]; then
-    PYTHONPATH="$HG_ROOT:$PYTHONPATH"; export PYTHONPATH
+HGPATH_DEFAULT="$HOME/work/hghacks/mercurial"
+HGPATH_STABLE="$HOME/work/hghacks/mercurial-stable"
+THGPATH="$HOME/work/hghacks/thg"
+
+[ -f "$THGPATH/thg" ] || exec /usr/bin/thg "$@"
+
+if [ -f "$HGPATH_STABLE/hg" -a "$(cat "$THGPATH/.hg/branch")" = stable ]; then
+    HGPATH="$HGPATH_STABLE"
+    export HGPATH
+elif [ -f "$HGPATH_DEFAULT/hg" ]; then
+    HGPATH="$HGPATH_DEFAULT"
+    export HGPATH
 fi
 
-if [ -f "$THG_ROOT/thg" ]; then
-    PYTHONPATH="$THG_ROOT:$PYTHONPATH"; export PYTHONPATH
-    THG="$THG_ROOT/thg"
-else
-    THG='/usr/bin/thg'
-fi
-
-exec "$THG" "$@"
+exec "$THGPATH/thg" "$@"