debug: add --wait to debuglock

Summary:
We have automation that wants to use this to hold the lock while doing
some maintenance. They want the ability to wait for the lock so they don't have
to busy loop.

Reviewed By: snarkmaster

Differential Revision: D24604466

fbshipit-source-id: be02539908655e183f334865718b68b633b069a5
This commit is contained in:
Durham Goode 2020-10-28 19:34:18 -07:00 committed by Facebook GitHub Bot
parent e5e6f53b83
commit 2cf0157824
2 changed files with 6 additions and 3 deletions

View File

@ -1678,6 +1678,7 @@ def debuglabelcomplete(ui, repo, *args):
("U", "force-undolog-lock", None, _("free the undolog lock " "(DANGEROUS)")),
("s", "set-lock", None, _("set the store lock until stopped")),
("S", "set-wlock", None, _("set the working state lock until stopped")),
("", "wait", None, _("wait for the lock when setting it")),
],
_("[OPTION]..."),
)
@ -1726,16 +1727,18 @@ def debuglocks(ui, repo, **opts):
if done:
return 0
wait = opts.get(r"wait") or False
locks = []
try:
if opts.get(r"set_wlock"):
try:
locks.append(repo.wlock(False))
locks.append(repo.wlock(wait))
except error.LockHeld:
raise error.Abort(_("wlock is already held"))
if opts.get(r"set_lock"):
try:
locks.append(repo.lock(False))
locks.append(repo.lock(wait))
except error.LockHeld:
raise error.Abort(_("lock is already held"))
if len(locks):

View File

@ -417,7 +417,7 @@ Show all commands + options
debuginstall: template
debugknown:
debuglabelcomplete:
debuglocks: force-lock, force-wlock, force-undolog-lock, set-lock, set-wlock
debuglocks: force-lock, force-wlock, force-undolog-lock, set-lock, set-wlock, wait
debugmakepublic: rev, delete
debugmanifestdirs: rev
debugmergestate: