| 1 |
# Dummy extension that adds a delay after acquiring a lock. |
| 2 |
# |
| 3 |
# This extension can be used to test race conditions between lock acquisition. |
| 4 |
|
| 5 |
|
| 6 |
import os |
| 7 |
import time |
| 8 |
|
| 9 |
|
| 10 |
def reposetup(ui, repo): |
| 11 |
class delayedlockrepo(repo.__class__): |
| 12 |
def lock(self, wait=True): |
| 13 |
delay = float(os.environ.get('HGPRELOCKDELAY', '0.0')) |
| 14 |
if delay: |
| 15 |
time.sleep(delay) |
| 16 |
res = super().lock(wait=wait) |
| 17 |
delay = float(os.environ.get('HGPOSTLOCKDELAY', '0.0')) |
| 18 |
if delay: |
| 19 |
time.sleep(delay) |
| 20 |
return res |
| 21 |
|
| 22 |
repo.__class__ = delayedlockrepo |