annotate tests/lockdelay.py @ 29051:a56296f55a5e stable 3.8.1

convert: pass absolute paths to git (SEC) Fixes CVE-2016-3105 (1/1). Previously, it was possible for the repository path passed to git-ls-remote to be misinterpreted as a URL. Always passing an absolute path to git is a simple way to avoid this.
author Blake Burkhart <bburky@bburky.com>
date Wed, 06 Apr 2016 22:57:46 -0500
parents d493d64757eb
children a76d5ba7ac43
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
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
d493d64757eb hg: obtain lock when creating share from pooled repo (issue5104)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
10 from mercurial import (
d493d64757eb hg: obtain lock when creating share from pooled repo (issue5104)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
11 lock as lockmod,
d493d64757eb hg: obtain lock when creating share from pooled repo (issue5104)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
12 )
d493d64757eb hg: obtain lock when creating share from pooled repo (issue5104)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
13
d493d64757eb hg: obtain lock when creating share from pooled repo (issue5104)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
14 class delaylock(lockmod.lock):
d493d64757eb hg: obtain lock when creating share from pooled repo (issue5104)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
15 def lock(self):
d493d64757eb hg: obtain lock when creating share from pooled repo (issue5104)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
16 delay = float(os.environ.get('HGPRELOCKDELAY', '0.0'))
d493d64757eb hg: obtain lock when creating share from pooled repo (issue5104)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
17 if delay:
d493d64757eb hg: obtain lock when creating share from pooled repo (issue5104)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
18 time.sleep(delay)
d493d64757eb hg: obtain lock when creating share from pooled repo (issue5104)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
19 res = super(delaylock, self).lock()
d493d64757eb hg: obtain lock when creating share from pooled repo (issue5104)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
20 delay = float(os.environ.get('HGPOSTLOCKDELAY', '0.0'))
d493d64757eb hg: obtain lock when creating share from pooled repo (issue5104)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
21 if delay:
d493d64757eb hg: obtain lock when creating share from pooled repo (issue5104)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
22 time.sleep(delay)
d493d64757eb hg: obtain lock when creating share from pooled repo (issue5104)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
23 return res
d493d64757eb hg: obtain lock when creating share from pooled repo (issue5104)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
24
d493d64757eb hg: obtain lock when creating share from pooled repo (issue5104)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
25 def extsetup(ui):
d493d64757eb hg: obtain lock when creating share from pooled repo (issue5104)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
26 lockmod.lock = delaylock