[PATCH 3 of 7] share: add support "full share" suport
Yuya Nishihara
yuya at tcha.org
Sun Nov 29 08:42:38 CST 2015
On Tue, 24 Nov 2015 18:22:27 -0600, Angel Ezquerra wrote:
> # HG changeset patch
> # User Angel Ezquerra <angel.ezquerra at gmail.com>
> # Date 1419360788 -3600
> # Tue Dec 23 19:53:08 2014 +0100
> # Node ID fd4449f9e1239bc269e7a842168ace286ee4dd9e
> # Parent d7b08e9f7782fdc21663dff41149c054862276f5
> share: add support "full share" suport
> --- a/mercurial/localrepo.py
> +++ b/mercurial/localrepo.py
> @@ -190,6 +190,27 @@
> def changegroupsubset(self, bases, heads, source):
> return changegroup.changegroupsubset(self._repo, bases, heads, source)
>
> +# List of files that belong to the "local repository" rather than to the shared
> +# repository source when using shared repositories
> +# This list includes the files that belong to the "working directory state" plus
> +# some config files (i.e. the hgrc and the share config files)
> +# This list is used by to create "full repository shares"
> +# It is placed here so that it can be easily extended by external users (e.g.
> +# TortoiseHg, etc)
> +# Note that this list does not include some cache files that could be placed on
> +# the local repository to improve performance when using shared repos
> +LOCALREPOFILES = (
We generally use lowercase name.
> + 'hgrc', 'sharedpath', 'shared',
> + 'dirstate', 'branch', 'undo.dirstate', 'undo.branch',
> + 'dirstate.pending',
> + 'bookmarks.current',
> + 'last-message.txt',
> + 'updatestate', 'rebasestate', 'graftstate',
> + 'shelvedstate', 'unshelverebasestate',
> + 'histedit-state',
> + 'patches/status',
> +)
I guess this list is incomplete (e.g. missing bisect.state?) and the number
of items would burst.
> @@ -278,13 +300,36 @@
>
> self.sharedpath = self.path
> try:
> - vfs = scmutil.vfs(self.vfs.read("sharedpath").rstrip('\n'),
> - realpath=True)
> + localpath = self.path
> + def localjoinfn(p):
> + return os.path.join(localpath, p)
> + def joinfn(p):
> + if not p:
> + return p
> + # We don't share the journal
> + if p in LOCALREPOFILES:
> + return localjoinfn(p)
> + base = os.path.dirname(p)
> + if base.endswith('/merge'):
> + return localjoinfn(p)
I didn't read it carefully, but base.endswith('/merge') never be true.
> - l = self._lock(self.vfs, "wlock", wait, unlock,
> + if self.fullshare:
> + sourcelock = self._lock(self.vfs, "wlock", wait, None,
> + self.invalidatedirstate, _('share source of %s (%s)') %
> + (self.origroot, self.sharedpath),
> + inheritchecker=self._wlockchecktransaction,
> + parentenvvar='HG_WLOCK_LOCKER')
> + locallock = self._lock(self.localvfs, "wlock", wait, unlock,
> + self.invalidatedirstate, _('working directory of %s') %
> + self.origroot,
> + inheritchecker=self._wlockchecktransaction,
> + parentenvvar='HG_WLOCK_LOCKER')
If sourcelock can be taken but locallock fail, sourcelock won't be released
explicitly.
> + l = lockmod.multilock(locallock, sourcelock)
Wrong order? I think you've designed the multilock to take locks in order,
and release them in reverse order.
> + else:
> + l = self._lock(self.vfs, "wlock", wait, unlock,
> self.invalidatedirstate, _('working directory of %s') %
> self.origroot,
> inheritchecker=self._wlockchecktransaction,
More information about the Mercurial-devel
mailing list