Patchwork D12616: debuglock: make the command more useful in non-interactive mode

login
register
mail settings
Submitter phabricator
Date May 6, 2022, 8:38 a.m.
Message ID <differential-rev-PHID-DREV-6brfkvyau35kngu27xgo-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/50970/
State New
Headers show

Comments

phabricator - May 6, 2022, 8:38 a.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The existing prompt mode simply release the lock immediately in non-interactive.
  That is quite useless in the test so now the non-interactive mode simply wait
  for a signal.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12616

AFFECTED FILES
  mercurial/debugcommands.py

CHANGE DETAILS




To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -2185,7 +2185,19 @@ 
             except error.LockHeld:
                 raise error.Abort(_(b'lock is already held'))
         if len(locks):
-            ui.promptchoice(_(b"ready to release the lock (y)? $$ &Yes"))
+            try:
+                if ui.interactive():
+                    prompt = _(b"ready to release the lock (y)? $$ &Yes")
+                    ui.promptchoice(prompt)
+                else:
+                    msg = b"%d locks held, waiting for signal\n"
+                    msg %= len(locks)
+                    ui.status(msg)
+                    while True:  # XXX wait for a signal
+                        time.sleep(0.1)
+            except KeyboardInterrupt:
+                msg = b"signal-received releasing locks\n"
+                ui.status(msg)
             return 0
     finally:
         release(*locks)