comparison mercurial/debugcommands.py @ 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 22279b604a88
children 5b1495c37b0c
comparison
equal deleted inserted replaced
49196:1c233af99316 49197:883be4c74d54
2199 try: 2199 try:
2200 locks.append(repo.lock(False)) 2200 locks.append(repo.lock(False))
2201 except error.LockHeld: 2201 except error.LockHeld:
2202 raise error.Abort(_(b'lock is already held')) 2202 raise error.Abort(_(b'lock is already held'))
2203 if len(locks): 2203 if len(locks):
2204 ui.promptchoice(_(b"ready to release the lock (y)? $$ &Yes")) 2204 try:
2205 if ui.interactive():
2206 prompt = _(b"ready to release the lock (y)? $$ &Yes")
2207 ui.promptchoice(prompt)
2208 else:
2209 msg = b"%d locks held, waiting for signal\n"
2210 msg %= len(locks)
2211 ui.status(msg)
2212 while True: # XXX wait for a signal
2213 time.sleep(0.1)
2214 except KeyboardInterrupt:
2215 msg = b"signal-received releasing locks\n"
2216 ui.status(msg)
2205 return 0 2217 return 0
2206 finally: 2218 finally:
2207 release(*locks) 2219 release(*locks)
2208 2220
2209 now = time.time() 2221 now = time.time()