From 4f58ce0e90343154f3dcfc20312af7b336dbb863 Mon Sep 17 00:00:00 2001 From: Kovica Date: Fri, 12 Dec 2014 20:32:04 +0100 Subject: [PATCH] On new repositories ./hg/branch and .hg/dirstate do not exist. In this case use "hg summary" --- themes/base.theme.bash | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/themes/base.theme.bash b/themes/base.theme.bash index 939532a4..06c7e3cc 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -160,10 +160,19 @@ function hg_prompt_vars { 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) + if [ -f $HG_ROOT/branch ]; then + # Mercurial holds it's current branch in .hg/branch file + SCM_BRANCH=$(cat $HG_ROOT/branch) + else + SCM_BRANCH=$(hg summary 2> /dev/null | grep branch: | awk '{print $2}') + fi + + if [ -f $HG_ROOT/dirstate ]; then + # 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) + else + SCM_CHANGE=$(hg summary 2> /dev/null | grep parent: | awk '{print $2}') + fi } function rvm_version_prompt {