changeset 49197:883be4c74d54

debuglock: make the command more useful in non-interactive mode The existing prompt mode simply release the lock immediately in non-interactive mode. That is quite useless in the test so now the non-interactive mode simply wait for a signal. Differential Revision: https://phab.mercurial-scm.org/D12616
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Tue, 05 Apr 2022 04:41:09 +0200
parents 1c233af99316
children a68b37524d50
files mercurial/debugcommands.py
diffstat 1 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/debugcommands.py	Tue Apr 05 03:36:31 2022 +0200
+++ b/mercurial/debugcommands.py	Tue Apr 05 04:41:09 2022 +0200
@@ -2201,7 +2201,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)