equal
deleted
inserted
replaced
|
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 from __future__ import absolute_import |
|
6 |
|
7 import os |
|
8 import time |
|
9 |
|
10 from mercurial import ( |
|
11 lock as lockmod, |
|
12 ) |
|
13 |
|
14 class delaylock(lockmod.lock): |
|
15 def lock(self): |
|
16 delay = float(os.environ.get('HGPRELOCKDELAY', '0.0')) |
|
17 if delay: |
|
18 time.sleep(delay) |
|
19 res = super(delaylock, self).lock() |
|
20 delay = float(os.environ.get('HGPOSTLOCKDELAY', '0.0')) |
|
21 if delay: |
|
22 time.sleep(delay) |
|
23 return res |
|
24 |
|
25 def extsetup(ui): |
|
26 lockmod.lock = delaylock |