From 6f126b80e45f94b51087fd92fffd41f256535942 Mon Sep 17 00:00:00 2001 From: Kovica Date: Fri, 12 Dec 2014 15:19:28 +0100 Subject: [PATCH] Added comments --- themes/base.theme.bash | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/themes/base.theme.bash b/themes/base.theme.bash index b9f18960..5d09d778 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -127,6 +127,13 @@ function svn_prompt_vars { 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 { local CURRENT_DIR=$(pwd) @@ -154,7 +161,10 @@ function hg_prompt_vars { SCM_SUFFIX=${HG_THEME_PROMPT_SUFFIX:-$SCM_THEME_PROMPT_SUFFIX} HG_ROOT=$(get_hg_root) + + # Mercurial holds it's current branch in .hg/branch file 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) }