[PATCH 6 of 6 RFC] localrepo: properly lock full shared repositories
Angel Ezquerra
angel.ezquerra at gmail.com
Wed Dec 24 06:05:29 CST 2014
# HG changeset patch
# User Angel Ezquerra <angel.ezquerra at gmail.com>
# Date 1419377236 -3600
# Wed Dec 24 00:27:16 2014 +0100
# Node ID ea45b2250b04f37419972d9baff3d0568c92a25a
# Parent 64ef59f0bf80cb4270af791a482e6b450754f76c
localrepo: properly lock full shared repositories
Since the "non-store" parts of a full share repository is split between the
source repository (which contains most of the repository files) and the shared
repository itself (which contains the dirstate, bookmarks.current and a few
other minor files), we must lock both repositories when locking the shared
repository. This is done by using a multilock that holds two locks, the source
repository wlock and shared repository wlock.
# Notes:
- In the final version of this patch series this revision must be folded into the
revision that introduces the "full share" support, but I want to be able to
discuss this part individually.
- This is the last revision in the series. I ran the test suite and all tests
pass.
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -274,6 +274,7 @@
# the source repository
self.origpath = self.path
self.path = self.sharedpath
+ self.localvfs = self.vfs
self.vfs = vfs
self.opener = self.vfs
except IOError, inst:
@@ -1162,7 +1163,16 @@
self._filecache['dirstate'].refresh()
- l = self._lock(self.vfs, "wlock", wait, unlock,
+ if self.fullshare:
+ sourcelock = self._lock(self.vfs, "wlock", wait, None,
+ self.invalidatedirstate, _('share source %s') %
+ self.origroot)
+ locallock = self._lock(self.localvfs, "wlock", wait, unlock,
+ self.invalidatedirstate, _('working directory of %s') %
+ self.origroot)
+ l = lockmod.multilock(locallock, sourcelock)
+ else:
+ l = self._lock(self.vfs, "wlock", wait, unlock,
self.invalidatedirstate, _('working directory of %s') %
self.origroot)
self._wlockref = weakref.ref(l)
More information about the Mercurial-devel
mailing list