Mercurial > public > mercurial-scm > hg-stable
view tests/lockdelay.py @ 49598:13c0e3b4fd35 stable
tests: use `test -f` instead of `ls` to see if a file is present (issue6662)
ls's exit code when file doesn't exist is 2 on Linux and 1 on NetBSD, so let's
use something that's supposedly more portable, since we only care whether the
file is there or not.
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Mon, 05 Dec 2022 19:37:12 +0400 |
parents | 6000f5b25c9b |
children | 5cc8deb96b48 |
line wrap: on
line source
# Dummy extension that adds a delay after acquiring a lock. # # This extension can be used to test race conditions between lock acquisition. import os import time def reposetup(ui, repo): class delayedlockrepo(repo.__class__): def lock(self, wait=True): delay = float(os.environ.get('HGPRELOCKDELAY', '0.0')) if delay: time.sleep(delay) res = super(delayedlockrepo, self).lock(wait=wait) delay = float(os.environ.get('HGPOSTLOCKDELAY', '0.0')) if delay: time.sleep(delay) return res repo.__class__ = delayedlockrepo