tests/lockdelay.py
author Kostia Balytskyi <ikostia@fb.com>
Fri, 01 Jul 2016 14:09:53 +0200
changeset 29473 e25da98052a4
parent 28289 d493d64757eb
child 30068 a76d5ba7ac43
permissions -rw-r--r--
rebase: move new rebase preparation to be a method of the RR class This commit moves logic that prepares the execution of a new rebase operation to be a method of the rebaseruntime class.

# Dummy extension that adds a delay after acquiring a lock.
#
# This extension can be used to test race conditions between lock acquisition.

from __future__ import absolute_import

import os
import time

from mercurial import (
    lock as lockmod,
)

class delaylock(lockmod.lock):
    def lock(self):
        delay = float(os.environ.get('HGPRELOCKDELAY', '0.0'))
        if delay:
            time.sleep(delay)
        res = super(delaylock, self).lock()
        delay = float(os.environ.get('HGPOSTLOCKDELAY', '0.0'))
        if delay:
            time.sleep(delay)
        return res

def extsetup(ui):
    lockmod.lock = delaylock