tests/lockdelay.py
author Matt Harbison <matt_harbison@yahoo.com>
Fri, 24 Jan 2020 01:37:18 -0500
branchstable
changeset 44153 e4344e463c0c
parent 43076 2372284d9457
child 45444 f6c67bb4ca03
permissions -rw-r--r--
packaging: rename hgrc.d to defaultrc for Windows config files next to the exe The code and the help still says that it will read hgrc.d next to the executable. But this directory needs to exist to read the resource based config files. Otherwise even `hg version` errors out: $ /c/Program\ Files/Mercurial/hg.exe version Traceback (most recent call last): File "hg", line 43, in <module> File "mercurial\dispatch.pyc", line 110, in run File "mercurial\dispatch.pyc", line 226, in dispatch File "mercurial\ui.pyc", line 308, in load File "mercurial\rcutil.pyc", line 99, in rccomponents File "mercurial\rcutil.pyc", line 69, in default_rc_resources File "mercurial\utils\resourceutil.pyc", line 84, in contents WindowsError: [Error 3] The system cannot find the path specified: 'c:\\Program Files\\mercurial\\defaultrc\\*.*' Differential Revision: https://phab.mercurial-scm.org/D7981
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
28289
d493d64757eb hg: obtain lock when creating share from pooled repo (issue5104)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     1
# Dummy extension that adds a delay after acquiring a lock.
d493d64757eb hg: obtain lock when creating share from pooled repo (issue5104)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     2
#
d493d64757eb hg: obtain lock when creating share from pooled repo (issue5104)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     3
# This extension can be used to test race conditions between lock acquisition.
d493d64757eb hg: obtain lock when creating share from pooled repo (issue5104)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     4
d493d64757eb hg: obtain lock when creating share from pooled repo (issue5104)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     5
from __future__ import absolute_import
d493d64757eb hg: obtain lock when creating share from pooled repo (issue5104)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     6
d493d64757eb hg: obtain lock when creating share from pooled repo (issue5104)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     7
import os
d493d64757eb hg: obtain lock when creating share from pooled repo (issue5104)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     8
import time
d493d64757eb hg: obtain lock when creating share from pooled repo (issue5104)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     9
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 30068
diff changeset
    10
30068
a76d5ba7ac43 pull: grab wlock during pull
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 28289
diff changeset
    11
def reposetup(ui, repo):
a76d5ba7ac43 pull: grab wlock during pull
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 28289
diff changeset
    12
    class delayedlockrepo(repo.__class__):
a76d5ba7ac43 pull: grab wlock during pull
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 28289
diff changeset
    13
        def lock(self):
a76d5ba7ac43 pull: grab wlock during pull
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 28289
diff changeset
    14
            delay = float(os.environ.get('HGPRELOCKDELAY', '0.0'))
a76d5ba7ac43 pull: grab wlock during pull
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 28289
diff changeset
    15
            if delay:
a76d5ba7ac43 pull: grab wlock during pull
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 28289
diff changeset
    16
                time.sleep(delay)
a76d5ba7ac43 pull: grab wlock during pull
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 28289
diff changeset
    17
            res = super(delayedlockrepo, self).lock()
a76d5ba7ac43 pull: grab wlock during pull
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 28289
diff changeset
    18
            delay = float(os.environ.get('HGPOSTLOCKDELAY', '0.0'))
a76d5ba7ac43 pull: grab wlock during pull
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 28289
diff changeset
    19
            if delay:
a76d5ba7ac43 pull: grab wlock during pull
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 28289
diff changeset
    20
                time.sleep(delay)
a76d5ba7ac43 pull: grab wlock during pull
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 28289
diff changeset
    21
            return res
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 30068
diff changeset
    22
30068
a76d5ba7ac43 pull: grab wlock during pull
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 28289
diff changeset
    23
    repo.__class__ = delayedlockrepo