diff mercurial/lock.py @ 51448:9da3fcc5f70f stable

test-lock: use synchronisation file instead of sleep This will prevent the test to be flaky on load.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 11 Mar 2024 16:05:28 +0100
parents 81224afd938d
children 460e80488cf0
line wrap: on
line diff
--- a/mercurial/lock.py	Mon Mar 11 13:36:25 2024 +0100
+++ b/mercurial/lock.py	Mon Mar 11 16:05:28 2024 +0100
@@ -115,6 +115,7 @@
 
     This function is responsible to issue warnings and or debug messages about
     the held lock while trying to acquires it."""
+    devel_wait_file = kwargs.pop("devel_wait_sync_file", None)
 
     def printwarning(printer, locker):
         """issue the usual "waiting on lock" message through any channel"""
@@ -150,6 +151,11 @@
             l._trylock()
             break
         except error.LockHeld as inst:
+            if devel_wait_file is not None:
+                # create the file to signal we are waiting
+                with open(devel_wait_file, 'w'):
+                    pass
+
             if delay == debugidx:
                 printwarning(ui.debug, inst.locker)
             if delay == warningidx: