tests/lockdelay.py
author Mads Kiilerich <madski@unity3d.com>
Sun, 27 Mar 2016 13:00:28 -0700
changeset 28878 a75c9665ef06
parent 28289 d493d64757eb
child 30068 a76d5ba7ac43
permissions -rw-r--r--
largefiles: introduce push --lfrev to control which revisions are pushed The default of pushing all largefiles referenced in outgoing revisions is safe, but also expensive and sometimes not what is needed. We thus introduce a --lfrev option, similar to what pull already has. By specifying an empty set of revisions (or null), it is possible to get lazy (and insecure!) pushes of revisions without referenced largefiles, similar to how pull works.

# 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