Mercurial > hg
diff mercurial/setdiscovery.py @ 35849:5cfdf6137af8
setdiscovery: don't call "heads" wire command when heads specified
Our custom server has too many heads to announce (one per code review,
plus a public head), but it still lets the user request one of them by
doing
hg pull -r <some expression>
After the client has resolved the expression to a set of nodeids by
calling the "lookup" wire command, it will start the discovery
phase. Before this patch, that doesn't take the requested heads into
account and unconditionally calls the server's "heads" command to find
all its heads. One consequence of that the "all remote heads known
locally" case triggers if the client already had the public head and
the user will see a "no changes found" message that's unrelated to the
head they requested. That message confused me for a while. More
imporantly, it also means that pullop.cgresult incorrectly (given our
arguably misbehaving server) gets set to 0 (no changesets added),
which confused some of our extensions.
This patch makes it so the client skips the "heads" command if the
user requested specific revisions.
Since the "heads" command is normally batched with the first "known"
command and calculating the list of heads is probably cheap, I don't
expect much improvement in speed from this.
Differential Revision: https://phab.mercurial-scm.org/D1962
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Thu, 01 Feb 2018 10:29:24 -0800 |
parents | f77121b6bf1b |
children | 613954a17a25 |
line wrap: on
line diff
--- a/mercurial/setdiscovery.py Thu Feb 01 08:17:11 2018 -0800 +++ b/mercurial/setdiscovery.py Thu Feb 01 10:29:24 2018 -0800 @@ -130,7 +130,7 @@ sample = set(random.sample(sample, desiredlen)) return sample -def findcommonheads(ui, local, remote, +def findcommonheads(ui, local, remote, heads=None, initialsamplesize=100, fullsamplesize=200, abortwhenunrelated=True, @@ -155,11 +155,15 @@ sample = _limitsample(ownheads, initialsamplesize) # indices between sample and externalized version must match sample = list(sample) - batch = remote.iterbatch() - batch.heads() - batch.known(dag.externalizeall(sample)) - batch.submit() - srvheadhashes, yesno = batch.results() + if heads: + srvheadhashes = heads + yesno = remote.known(dag.externalizeall(sample)) + else: + batch = remote.iterbatch() + batch.heads() + batch.known(dag.externalizeall(sample)) + batch.submit() + srvheadhashes, yesno = batch.results() if cl.tip() == nullid: if srvheadhashes != [nullid]: