mirror of
https://github.com/facebook/sapling.git
synced 2025-01-07 14:10:42 +03:00
pull: grab wlock during pull
because pull might move bookmarks and bookmark are protected by wlock, we have to grab wlock for pull :-( This required a small upgrade of the 'lockdelay' extension used by 'test-clone.t' because the delay must apply to a single lock only.
This commit is contained in:
parent
452cc705b7
commit
8b00f799de
@ -1201,8 +1201,10 @@ def pull(repo, remote, heads=None, force=False, bookmarks=(), opargs=None,
|
||||
" %s") % (', '.join(sorted(missing)))
|
||||
raise error.Abort(msg)
|
||||
|
||||
lock = pullop.repo.lock()
|
||||
wlock = lock = None
|
||||
try:
|
||||
wlock = pullop.repo.wlock()
|
||||
lock = pullop.repo.lock()
|
||||
pullop.trmanager = transactionmanager(repo, 'pull', remote.url())
|
||||
streamclone.maybeperformlegacystreamclone(pullop)
|
||||
# This should ideally be in _pullbundle2(). However, it needs to run
|
||||
@ -1217,8 +1219,7 @@ def pull(repo, remote, heads=None, force=False, bookmarks=(), opargs=None,
|
||||
_pullobsolete(pullop)
|
||||
pullop.trmanager.close()
|
||||
finally:
|
||||
pullop.trmanager.release()
|
||||
lock.release()
|
||||
lockmod.release(pullop.trmanager, lock, wlock)
|
||||
|
||||
return pullop
|
||||
|
||||
|
@ -7,20 +7,16 @@ from __future__ import absolute_import
|
||||
import os
|
||||
import time
|
||||
|
||||
from mercurial import (
|
||||
lock as lockmod,
|
||||
)
|
||||
def reposetup(ui, repo):
|
||||
|
||||
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
|
||||
class delayedlockrepo(repo.__class__):
|
||||
def lock(self):
|
||||
delay = float(os.environ.get('HGPRELOCKDELAY', '0.0'))
|
||||
if delay:
|
||||
time.sleep(delay)
|
||||
res = super(delayedlockrepo, self).lock()
|
||||
delay = float(os.environ.get('HGPOSTLOCKDELAY', '0.0'))
|
||||
if delay:
|
||||
time.sleep(delay)
|
||||
return res
|
||||
repo.__class__ = delayedlockrepo
|
||||
|
Loading…
Reference in New Issue
Block a user