mercurial/testing/__init__.py
branchstable
changeset 50214 8e0d823ef182
parent 48875 6000f5b25c9b
--- a/mercurial/testing/__init__.py	Tue Feb 28 00:04:32 2023 +0100
+++ b/mercurial/testing/__init__.py	Tue Feb 28 00:01:41 2023 +0100
@@ -9,6 +9,21 @@
 environ = getattr(os, 'environ')
 
 
+def wait_on_cfg(ui, cfg, timeout=10):
+    """synchronize on the `cfg` config path
+
+    Use this to synchronize commands during race tests.
+    """
+    full_config = b'sync.' + cfg
+    wait_config = full_config + b'-timeout'
+    sync_path = ui.config(b'devel', full_config)
+    if sync_path is not None:
+        timeout = ui.config(b'devel', wait_config)
+        ready_path = sync_path + b'.waiting'
+        write_file(ready_path)
+        wait_file(sync_path, timeout=timeout)
+
+
 def _timeout_factor():
     """return the current modification to timeout"""
     default = int(environ.get('HGTEST_TIMEOUT_DEFAULT', 360))