Added comments

pull/378/head
Kovica 2014-12-12 15:19:28 +01:00
parent 8914d452d8
commit 6f126b80e4
1 changed files with 10 additions and 0 deletions

View File

@ -127,6 +127,13 @@ function svn_prompt_vars {
SCM_CHANGE=$(svn info 2> /dev/null | sed -ne 's#^Revision: ##p' ) SCM_CHANGE=$(svn info 2> /dev/null | sed -ne 's#^Revision: ##p' )
} }
# this functions returns absolute location of .hg directory if one exists
# It starts in the current directory and moves its way up until it hits /.
# If we get to / then no Mercurial repository was found.
# Example:
# - lets say we cd into ~/Projects/Foo/Bar
# - .hg is located in ~/Projects/Foo/.hg
# - get_hg_root starts at ~/Projects/Foo/Bar and sees that there is no .hg directory, so then it goes into ~/Projects/Foo
function get_hg_root { function get_hg_root {
local CURRENT_DIR=$(pwd) local CURRENT_DIR=$(pwd)
@ -154,7 +161,10 @@ function hg_prompt_vars {
SCM_SUFFIX=${HG_THEME_PROMPT_SUFFIX:-$SCM_THEME_PROMPT_SUFFIX} SCM_SUFFIX=${HG_THEME_PROMPT_SUFFIX:-$SCM_THEME_PROMPT_SUFFIX}
HG_ROOT=$(get_hg_root) HG_ROOT=$(get_hg_root)
# Mercurial holds it's current branch in .hg/branch file
SCM_BRANCH=$(cat $HG_ROOT/branch) SCM_BRANCH=$(cat $HG_ROOT/branch)
# Mercurial holds various information about the working directory in .hg/dirstate file. More on http://mercurial.selenic.com/wiki/DirState
SCM_CHANGE=$(hexdump -n 10 -e '1/1 "%02x"' $HG_ROOT/dirstate | cut -c-12) SCM_CHANGE=$(hexdump -n 10 -e '1/1 "%02x"' $HG_ROOT/dirstate | cut -c-12)
} }