scm-prompt: add locked state

Summary:
If you're working n multiple terminals on the same repository, it is
often useful to know if a command you're about to run might block due to an
already-held lock on the repository. This upgrade to scm-prompt gives the
user this information.

Test Plan: updated the test

Reviewers: #fbhgext, stash

Reviewed By: #fbhgext, stash

Subscribers: stash

Differential Revision: https://phab.mercurial-scm.org/D790
This commit is contained in:
Ryan McElroy 2017-09-22 08:31:06 -07:00
parent 8b7529b24d
commit 68ea4e433c
2 changed files with 14 additions and 0 deletions

View File

@ -108,6 +108,10 @@ _scm_prompt()
extra="|REBASE"
elif [[ -d "$hg/.hg/merge" ]]; then
extra="|MERGE"
elif [[ -L "$hg/.hg/store/lock" ]]; then
extra="|STORE-LOCKED"
elif [[ -L "$hg/.hg/wlock" ]]; then
extra="|WDIR-LOCKED"
fi
local dirstate=$( \
(test -f "$hg/.hg/dirstate" && \

View File

@ -231,6 +231,16 @@ Test formatting options
$ _scm_prompt ':%s:'
:97af35b: (no-eol)
Test locked repo states (generally due to concurrency so tests are kinda fake)
$ cmd ln -s "${HOSTNAME}:12345" .hg/wlock
(97af35b|WDIR-LOCKED)
$ cmd ln -s "${HOSTNAME}:12345" .hg/store/lock
(97af35b|STORE-LOCKED)
$ cmd rm .hg/wlock
(97af35b|STORE-LOCKED)
$ cmd rm .hg/store/lock
(97af35b)
Test many remotenames
$ hg log -r . -T '{node}\n'
97af35b3648c0098cbd8114ae1b1bafab997ac20