# HG changeset patch # User Pierre-Yves David # Date 2015-01-07 08:07:29 # Node ID c5456b64eb07c37a4e891d641617f42fb8182dc1 # Parent 71402bb8d8b274d82169cf26253e38ef793794f5 discovery: run discovery on filtered repository We have been running discovery on unfiltered repository for quite some time. This was aimed at two things: - save some bandwith by prevent the repushing of common but hidden changesets - allow phases changes on secret/hidden changeset on bare push. The cost of this unfiltered discovery combined with evolution is actually really high. Evolution likely create thousand of hidden heads, and the discovery is going to try to discovery if each of them are common or not. For example, pushing from my development mercurial repository implies 17 discovery round-trip. The benefit are rare corner cases while the drawback are massive. So we run the discovery on a filtered repository again. We add some hack to detect remote heads that are known locally and adds them to the common set anyway, so the good behavior of most of the corner case should remains. But this will not work in all cases. This bring my discovery phase back from 17 round-trips to 1 or 2. diff --git a/mercurial/exchange.py b/mercurial/exchange.py --- a/mercurial/exchange.py +++ b/mercurial/exchange.py @@ -271,12 +271,11 @@ def _pushdiscovery(pushop): @pushdiscovery('changeset') def _pushdiscoverychangeset(pushop): """discover the changeset that need to be pushed""" - unfi = pushop.repo.unfiltered() fci = discovery.findcommonincoming - commoninc = fci(unfi, pushop.remote, force=pushop.force) + commoninc = fci(pushop.repo, pushop.remote, force=pushop.force) common, inc, remoteheads = commoninc fco = discovery.findcommonoutgoing - outgoing = fco(unfi, pushop.remote, onlyheads=pushop.revs, + outgoing = fco(pushop.repo, pushop.remote, onlyheads=pushop.revs, commoninc=commoninc, force=pushop.force) pushop.outgoing = outgoing pushop.remoteheads = remoteheads @@ -927,11 +926,36 @@ def _pulldiscoverychangegroup(pullop): Current handle changeset discovery only, will change handle all discovery at some point.""" - tmp = discovery.findcommonincoming(pullop.repo.unfiltered(), + tmp = discovery.findcommonincoming(pullop.repo, pullop.remote, heads=pullop.heads, force=pullop.force) - pullop.common, pullop.fetch, pullop.rheads = tmp + common, fetch, rheads = tmp + nm = pullop.repo.unfiltered().changelog.nodemap + if fetch and rheads: + # If a remote heads in filtered locally, lets drop it from the unknown + # remote heads and put in back in common. + # + # This is a hackish solution to catch most of "common but locally + # hidden situation". We do not performs discovery on unfiltered + # repository because it end up doing a pathological amount of round + # trip for w huge amount of changeset we do not care about. + # + # If a set of such "common but filtered" changeset exist on the server + # but are not including a remote heads, we'll not be able to detect it, + scommon = set(common) + filteredrheads = [] + for n in rheads: + if n in nm and n not in scommon: + common.append(n) + else: + filteredrheads.append(n) + if not filteredrheads: + fetch = [] + rheads = filteredrheads + pullop.common = common + pullop.fetch = fetch + pullop.rheads = rheads def _pullbundle2(pullop): """pull data using bundle2 diff --git a/mercurial/wireproto.py b/mercurial/wireproto.py --- a/mercurial/wireproto.py +++ b/mercurial/wireproto.py @@ -172,7 +172,11 @@ def decodelist(l, sep=' '): return [] def encodelist(l, sep=' '): - return sep.join(map(hex, l)) + try: + return sep.join(map(hex, l)) + except TypeError: + print l + raise # batched call argument encoding