tests/lockdelay.py
author Pierre-Yves David <pierre-yves.david@octobus.net>
Thu, 28 Oct 2021 17:44:58 +0200
changeset 48291 500260410bb8
parent 45444 f6c67bb4ca03
child 48875 6000f5b25c9b
permissions -rw-r--r--
dirstate: make sure that status does not overlook the fallback flags Without this extra checks, file with fallback flags change as the only change would be overlooked. In the future we might store proper data in the dirstate and do less lookup. However, for now this will do to make sure that 6.0 is forward compatible with later version. Differential Revision: https://phab.mercurial-scm.org/D11729

# 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


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