[PATCH 5 of 6] push: add a way to allow concurrent pushes on unrelated heads
Yuya Nishihara
yuya at tcha.org
Wed Jun 7 10:25:54 EDT 2017
On Sun, 04 Jun 2017 15:49:33 +0100, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at octobus.net>
> # Date 1496030038 -7200
> # Mon May 29 05:53:58 2017 +0200
> # Node ID ae88951457de93c7f6286d449672b0b9d20c57f1
> # Parent 33062379c342992425c1ba8083bafb46420ba7d0
> # EXP-Topic pushrace
> # Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
> # hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r ae88951457de
> push: add a way to allow concurrent pushes on unrelated heads
I don't fully understand the bundle2 caps and parts, but the change looks good.
Queued up to here, thanks.
> diff --git a/mercurial/exchange.py b/mercurial/exchange.py
> --- a/mercurial/exchange.py
> +++ b/mercurial/exchange.py
> @@ -323,8 +323,21 @@ class pushoperation(object):
> self.bkresult = None
> # discover.outgoing object (contains common and outgoing data)
> self.outgoing = None
> - # all remote heads before the push
> + # all remote topological heads before the push
> self.remoteheads = None
> + # Details of the remote branch pre and post push
> + #
> + # mapping: {'branch': ([remoteheads],
> + # [newheads],
> + # [unsyncedheads],
> + # [discardedheads])}
> + # - branch: the branch name
> + # - remoteheads: the list of remote heads known locally
> + # None if the branch is new
> + # - newheads: the new remote heads (known locally) with outgoing pushed
> + # - unsyncedheads: the list of remote heads unknown locally.
> + # - discardedheads: the list of remote heads made obsolete by the push
> + self.pushbranchmap = None
> # testable as a boolean indicating if any nodes are missing locally.
> self.incoming = None
> # phases changes that must be pushed along side the changesets
> @@ -712,8 +725,23 @@ def _pushb2ctxcheckheads(pushop, bundler
>
> Exists as an independent function to aid extensions
> """
> - if not pushop.force:
> - bundler.newpart('check:heads', data=iter(pushop.remoteheads))
> + # * 'force' do not check for push race,
> + # * if we don't push anything, there are nothing to check.
> + if not pushop.force and pushop.outgoing.missingheads:
> + allowunrelated = 'related' in bundler.capabilities.get('checkheads', ())
> + if not allowunrelated:
> + bundler.newpart('check:heads', data=iter(pushop.remoteheads))
> + else:
> + affected = set()
> + for branch, heads in pushop.pushbranchmap.iteritems():
> + remoteheads, newheads, unsyncedheads, discardedheads = heads
> + if remoteheads is not None:
> + remote = set(remoteheads)
> + affected |= set(discardedheads) & remote
> + affected |= remote - set(newheads)
I'm a little confused with the name "newheads" even with the comment above,
but I don't have any better name.
More information about the Mercurial-devel
mailing list