fix scm-prompt.sh to find the remotenames file correctly

Summary:
When the share extension is in use the remotenames file lives in the shared
repository, not the current working direcotry's .hg directory.

Reviewed By: wez

Differential Revision: D7872628

fbshipit-source-id: f4faae3411e6cef14cef5d52151092ce3ecebd47
This commit is contained in:
Adam Simpkins 2018-05-03 19:52:50 -07:00 committed by Facebook Github Bot
parent e049b43113
commit 197605e8bd

View File

@ -106,14 +106,22 @@ _hg_prompt() {
command hexdump -s 8 -vn 20 -e '1/1 "%02x"' \
"$hg/../.eden/client/SNAPSHOT") || \
builtin echo "empty")"
local remote="$hg/remotenames"
local shared_hg="$hg"
if [[ -f "$hg/sharedpath" ]]; then
shared_hg="$(command cat $hg/sharedpath)"
remote="$shared_hg/remotenames"
fi
local active="$hg/bookmarks.current"
if [[ -f "$active" ]]; then
br="$(command cat "$active")"
# check to see if active bookmark needs update (eg, moved after pull)
local marks="$hg/bookmarks"
if [[ -f "$hg/sharedpath" && -f "$hg/shared" ]] &&
if [[ -f "$hg/sharedpath" && -f "$hg/shared" ]] &&
command grep -q '^bookmarks$' "$hg/shared"; then
marks="$(command cat $hg/sharedpath)/bookmarks"
marks="$shared_hg/bookmarks"
fi
if [[ -z "$extra" ]] && [[ -f "$marks" ]]; then
local markstate="$(command grep " $br$" "$marks" | \
@ -125,7 +133,6 @@ _hg_prompt() {
else
br="$(builtin echo "$dirstate" | command cut -c 1-7)"
fi
local remote="$hg/remotenames"
if [[ -f "$remote" ]]; then
local allremotemarks="$(command grep "^$dirstate bookmarks" "$remote" | \
command cut -f 3 -d ' ')"