Skip to content

Commit 292d086

Browse files
committed
lib/theme: local hg_root in hg_prompt_vars()
1 parent a656f09 commit 292d086

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

themes/base.theme.bash

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ function svn_prompt_vars() {
360360
}
361361

362362
function hg_prompt_vars() {
363+
local hg_root bookmark
363364
if [[ -n $(hg status 2> /dev/null) ]]; then
364365
SCM_DIRTY=1
365366
SCM_STATE="${HG_THEME_PROMPT_DIRTY:-${SCM_THEME_PROMPT_DIRTY?}}"
@@ -370,20 +371,20 @@ function hg_prompt_vars() {
370371
SCM_PREFIX="${HG_THEME_PROMPT_PREFIX:-${SCM_THEME_PROMPT_PREFIX-}}"
371372
SCM_SUFFIX="${HG_THEME_PROMPT_SUFFIX:-${SCM_THEME_PROMPT_SUFFIX-}}"
372373

373-
HG_ROOT="$(_bash-it-find-in-ancestor ".hg")/.hg"
374+
hg_root="$(_bash-it-find-in-ancestor ".hg")/.hg"
374375

375-
if [[ -f "$HG_ROOT/branch" ]]; then
376+
if [[ -f "$hg_root/branch" ]]; then
376377
# Mercurial holds it's current branch in .hg/branch file
377-
SCM_BRANCH=$(< "${HG_ROOT}/branch")
378-
local bookmark="${HG_ROOT}/bookmarks.current"
378+
SCM_BRANCH=$(< "${hg_root}/branch")
379+
bookmark="${hg_root}/bookmarks.current"
379380
[[ -f "${bookmark}" ]] && SCM_BRANCH+=:$(< "${bookmark}")
380381
else
381382
SCM_BRANCH=$(hg summary 2> /dev/null | grep branch: | awk '{print $2}')
382383
fi
383384

384-
if [[ -f "$HG_ROOT/dirstate" ]]; then
385+
if [[ -f "$hg_root/dirstate" ]]; then
385386
# Mercurial holds various information about the working directory in .hg/dirstate file. More on http://mercurial.selenic.com/wiki/DirState
386-
SCM_CHANGE=$(hexdump -vn 10 -e '1/1 "%02x"' "$HG_ROOT/dirstate" | cut -c-12)
387+
SCM_CHANGE=$(hexdump -vn 10 -e '1/1 "%02x"' "$hg_root/dirstate" | cut -c-12)
387388
else
388389
SCM_CHANGE=$(hg summary 2> /dev/null | grep parent: | awk '{print $2}')
389390
fi

0 commit comments

Comments
 (0)