Mercurial > evolve
changeset 4643:77f3699e711e
obsdiscovery: drop `obshash` discovery protocol (issue6136)
The protocol has been superseeded by stablerange for a long time. It is untested
and more and more buggy. Since this is deprecated experimental code in an
experimental code, we drop it.
We keep the underlying computation and debug command around for now. They might
still be useful to looks at repositories
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Mon, 27 May 2019 01:53:36 +0200 |
parents | a7c4f163656b |
children | b228672b0ff9 |
files | CHANGELOG hgext3rd/evolve/obsdiscovery.py tests/test-discovery-obshashrange.t tests/test-evolve-serveronly-bundle2.t tests/test-extension-isolation.t |
diffstat | 5 files changed, 17 insertions(+), 202 deletions(-) [+] |
line wrap: on
line diff
--- a/CHANGELOG Thu May 09 09:42:51 2019 -0700 +++ b/CHANGELOG Mon May 27 01:53:36 2019 +0200 @@ -13,6 +13,9 @@ * evolve: use "unstable" instead of "troubled" * evolve: run multiple stabilisation in the same transaction * evolve: improve users merging during content-divergence + * obsdiscovery: drop support for deprecated discovery protocol `obshash` + (Make sure your servers are configured to use the obshashrange one. + It is available in evolve 7.2 and above.) * topic: drop the b# alias. It conflicted with normal hashes. 8.5.1 -- 2019-04-23
--- a/hgext3rd/evolve/obsdiscovery.py Thu May 09 09:42:51 2019 -0700 +++ b/hgext3rd/evolve/obsdiscovery.py Mon May 27 01:53:36 2019 +0200 @@ -17,7 +17,6 @@ import hashlib import heapq -import inspect import sqlite3 import struct import weakref @@ -30,7 +29,6 @@ node, obsolete, scmutil, - setdiscovery, util, ) from mercurial.i18n import _ @@ -53,12 +51,6 @@ wireprotov1server = wireprototypes from mercurial.wireproto import wirepeer, encodelist, decodelist -try: - from mercurial import dagutil - dagutil.revlogdag -except (ImportError, AttributeError): # <= hg-4.7 - from . import dagutil - _pack = struct.pack _unpack = struct.unpack _calcsize = struct.calcsize @@ -77,81 +69,6 @@ ### Code performing discovery ### ################################## -def findcommonobsmarkers(ui, local, remote, probeset, - initialsamplesize=100, - fullsamplesize=200): - # from discovery - roundtrips = 0 - cl = local.changelog - dag = dagutil.revlogdag(cl) - missing = set() - common = set() - undecided = set(probeset) - totalnb = len(undecided) - heads = [rev for rev in cl.headrevs() if rev != node.nullrev] - compat.progress(ui, _("comparing with other"), 0, total=totalnb, - unit=_("changesets")) - if util.safehasattr(setdiscovery, '_takefullsample'): - # hg compat <= hg-4.9 (e5ece0f46b40) - _takefullsample = setdiscovery._takefullsample - else: - obsdiscov = setdiscovery.partialdiscovery(local, heads) - _takefullsample = obsdiscov.takefullsample - if remote.capable('_evoext_obshash_1'): - getremotehash = remote.evoext_obshash1 - localhash = _obsrelsethashtreefm1(local) - else: - getremotehash = remote.evoext_obshash - localhash = _obsrelsethashtreefm0(local) - - while undecided: - - ui.note(_("sampling from both directions\n")) - if len(undecided) < fullsamplesize: - sample = set(undecided) - else: - if util.safehasattr(setdiscovery, '_takefullsample'): - # compat <= hg-4.9 (e5ece0f46b40) - if len(inspect.getargspec(_takefullsample)[0]) == 4: - # Mercurial 4.8 changed calling convention. - sample = _takefullsample(local, None, undecided, - size=fullsamplesize) - else: - # hg <= 4.7 version - sample = _takefullsample(dag, undecided, - size=fullsamplesize) - else: - sample = _takefullsample(None, size=fullsamplesize) - - roundtrips += 1 - compat.progress(ui, _("comparing with other"), totalnb - len(undecided), - total=totalnb, unit=_("changesets")) - ui.debug("query %i; still undecided: %i, sample size is: %i\n" - % (roundtrips, len(undecided), len(sample))) - # indices between sample and externalized version must match - sample = list(sample) - remotehash = getremotehash(dag.externalizeall(sample)) - - yesno = [localhash[ix][1] == remotehash[si] - for si, ix in enumerate(sample)] - - commoninsample = set(n for i, n in enumerate(sample) if yesno[i]) - common.update(dag.ancestorset(commoninsample, common)) - - missinginsample = [n for i, n in enumerate(sample) if not yesno[i]] - missing.update(dag.descendantset(missinginsample, missing)) - - undecided.difference_update(missing) - undecided.difference_update(common) - - compat.progress(ui, _("comparing with other"), None) - result = dag.headsetofconnecteds(common) - ui.debug("%d total queries\n" % roundtrips) - - if not result: - return set([node.nullid]) - return dag.externalizeall(result) - def findmissingrange(ui, local, remote, probeset, initialsamplesize=100, fullsamplesize=200): @@ -831,10 +748,6 @@ # Dash computed from a given changesets using all markers relevant to it and # the obshash of its parents. This is similar to what happend for changeset # node where the parent is used in the computation - -def _canobshashtree(repo, remote): - return remote.capable('_evoext_obshash_0') - @eh.command( 'debugobsrelsethashtree', [('', 'v0', None, 'hash on marker format "0"'), @@ -843,8 +756,12 @@ """display Obsolete markers, Relevant Set, Hash Tree changeset-node obsrelsethashtree-node - It computed form the "orsht" of its parent and markers - relevant to the changeset itself.""" + It computed form the "obs-hash-tree" value of its parent and markers + relevant to the changeset itself. + + The obs-hash-tree is no longer used for any user facing logic. However the + debug command stayed as an inspection tool. It does not seem supseful to + upstream the command with the rest of evolve. We can safely drop it.""" if v0 and v1: raise error.Abort('cannot only specify one format') elif v0: @@ -901,84 +818,6 @@ compat.progress(repo.ui, _("preparing locally"), None) return cache -def _obshash(repo, nodes, version=0): - if version == 0: - hashs = _obsrelsethashtreefm0(repo) - elif version == 1: - hashs = _obsrelsethashtreefm1(repo) - else: - assert False - nm = repo.changelog.nodemap - revs = [nm.get(n) for n in nodes] - return [r is None and node.nullid or hashs[r][1] for r in revs] - -@eh.addattr(localrepo.localpeer, 'evoext_obshash') -def local_obshash(peer, nodes): - return _obshash(peer._repo, nodes) - -@eh.addattr(localrepo.localpeer, 'evoext_obshash1') -def local_obshash1(peer, nodes): - return _obshash(peer._repo, nodes, version=1) - -@eh.addattr(wirepeer, 'evoext_obshash') -def peer_obshash(self, nodes): - d = self._call("evoext_obshash", nodes=encodelist(nodes)) - try: - return decodelist(d) - except ValueError: - self._abort(error.ResponseError(_("unexpected response:"), d)) - -@eh.addattr(wirepeer, 'evoext_obshash1') -def peer_obshash1(self, nodes): - d = self._call("evoext_obshash1", nodes=encodelist(nodes)) - try: - return decodelist(d) - except ValueError: - self._abort(error.ResponseError(_("unexpected response:"), d)) - -@compat.wireprotocommand(eh, 'evoext_obshash', 'nodes') -def srv_obshash(repo, proto, nodes): - return encodelist(_obshash(repo, decodelist(nodes))) - -@compat.wireprotocommand(eh, 'evoext_obshash1', 'nodes') -def srv_obshash1(repo, proto, nodes): - return encodelist(_obshash(repo, decodelist(nodes), - version=1)) - -def _obshash_capabilities(orig, repo, proto): - """wrapper to advertise new capability""" - caps = orig(repo, proto) - if (obsolete.isenabled(repo, obsolete.exchangeopt) - and repo.ui.configbool('experimental', 'evolution.obsdiscovery')): - - # Compat hg 4.6+ (2f7290555c96) - bytesresponse = False - if util.safehasattr(caps, 'data'): - bytesresponse = True - caps = caps.data - - caps = caps.split() - caps.append(b'_evoext_obshash_0') - caps.append(b'_evoext_obshash_1') - caps.sort() - caps = b' '.join(caps) - - # Compat hg 4.6+ (2f7290555c96) - if bytesresponse: - caps = wireprototypes.bytesresponse(caps) - return caps - -@eh.extsetup -def obshash_extsetup(ui): - extensions.wrapfunction(wireprotov1server, 'capabilities', - _obshash_capabilities) - # wrap command content - oldcap, args = wireprotov1server.commands['capabilities'] - - def newcap(repo, proto): - return _obshash_capabilities(oldcap, repo, proto) - wireprotov1server.commands['capabilities'] = (newcap, args) - ########################################## ### trigger discovery during exchange ### ########################################## @@ -998,19 +837,10 @@ missing += pushop.outgoing.missing return missing -def _pushobshashtree(pushop, commonrevs): - repo = pushop.repo.unfiltered() - remote = pushop.remote - node = repo.changelog.node - common = findcommonobsmarkers(pushop.ui, repo, remote, commonrevs) - revs = list(repo.revs('only(%ln, %ln)', pushop.futureheads, common)) - return [node(r) for r in revs] - # available discovery method, first valid is used # tuple (canuse, perform discovery)) obsdiscoveries = [ (_canobshashrange, _pushobshashrange), - (_canobshashtree, _pushobshashtree), ] obsdiscovery_skip_message = """\ @@ -1094,10 +924,6 @@ % len(revs)) boundaries['missing'] = findmissingrange(repo.ui, unfi, pullop.remote, revs) - elif remote.capable('_evoext_obshash_0'): - obsexcmsg(repo.ui, "looking for common markers in %i nodes\n" - % len(revs)) - boundaries['common'] = findcommonobsmarkers(repo.ui, unfi, remote, revs) else: boundaries['common'] = [node.nullid] return boundaries
--- a/tests/test-discovery-obshashrange.t Thu May 09 09:42:51 2019 -0700 +++ b/tests/test-discovery-obshashrange.t Mon May 27 01:53:36 2019 +0200 @@ -191,7 +191,7 @@ sending hello command sending between command remote: * (glob) - remote: capabilities: _evoext_getbundle_obscommon _evoext_obshash_0 _evoext_obshash_1 _evoext_obshashrange_v1 batch * (glob) + remote: capabilities: _evoext_getbundle_obscommon _evoext_obshashrange_v1 batch * (glob) remote: 1 sending protocaps command query 1; heads @@ -320,7 +320,7 @@ * @45f8b879de922f6a6e620ba04205730335b6fc7e (*)> sending hello command (glob) * @45f8b879de922f6a6e620ba04205730335b6fc7e (*)> sending between command (glob) * @45f8b879de922f6a6e620ba04205730335b6fc7e (*)> remote: * (glob) - * @45f8b879de922f6a6e620ba04205730335b6fc7e (*)> remote: capabilities: _evoext_getbundle_obscommon _evoext_obshash_0 _evoext_obshash_1 _evoext_obshashrange_v1 batch branchmap bundle2=HG20%0Abookmarks%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Aobsmarkers%3DV0%2CV1%0Aphases%3Dheads%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps%0Arev-branch-cache%0Astream%3Dv2 changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash (glob) + * @45f8b879de922f6a6e620ba04205730335b6fc7e (*)> remote: capabilities: _evoext_getbundle_obscommon _evoext_obshashrange_v1 batch branchmap bundle2=HG20%0Abookmarks%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Aobsmarkers%3DV0%2CV1%0Aphases%3Dheads%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps%0Arev-branch-cache%0Astream%3Dv2 changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash (glob) * @45f8b879de922f6a6e620ba04205730335b6fc7e (*)> remote: 1 (glob) * @45f8b879de922f6a6e620ba04205730335b6fc7e (*)> sending protocaps command (glob) * @45f8b879de922f6a6e620ba04205730335b6fc7e (*)> query 1; heads (glob) @@ -1176,8 +1176,6 @@ $ hg debugcapabilities ssh://user@dummy/with-evolve | grep _evoext _evoext_getbundle_obscommon - _evoext_obshash_0 - _evoext_obshash_1 _evoext_obshashrange_v1 $ hg debugcapabilities ssh://user@dummy/without-evolve | grep _evoext [1] @@ -1196,8 +1194,6 @@ $ hg debugcapabilities http://localhost:$HGPORT/with-evolve| grep _evoext _evoext_getbundle_obscommon - _evoext_obshash_0 - _evoext_obshash_1 _evoext_obshashrange_v1 $ hg debugcapabilities http://localhost:$HGPORT/without-evolve| grep _evoext [1] @@ -1214,8 +1210,6 @@ [1] $ hg debugcapabilities http://localhost:$HGPORT/with-evolve| grep _evoext _evoext_getbundle_obscommon - _evoext_obshash_0 - _evoext_obshash_1 _evoext_obshashrange_v1 $ killdaemons.py
--- a/tests/test-evolve-serveronly-bundle2.t Thu May 09 09:42:51 2019 -0700 +++ b/tests/test-evolve-serveronly-bundle2.t Mon May 27 01:53:36 2019 +0200 @@ -86,9 +86,9 @@ =================== $ curl -s http://localhost:$HGPORT/?cmd=hello - capabilities: _evoext_getbundle_obscommon _evoext_obshash_0 _evoext_obshash_1 _evoext_obshashrange_v1 batch * (glob) + capabilities: _evoext_getbundle_obscommon _evoext_obshashrange_v1 batch * (glob) $ curl -s http://localhost:$HGPORT/?cmd=capabilities - _evoext_getbundle_obscommon _evoext_obshash_0 _evoext_obshash_1 _evoext_obshashrange_v1 batch * (no-eol) (glob) + _evoext_getbundle_obscommon _evoext_obshashrange_v1 batch * (no-eol) (glob) $ curl -s "http://localhost:$HGPORT/?cmd=listkeys&namespace=namespaces" | sort bookmarks @@ -151,9 +151,9 @@ obsolete phases $ curl -s http://localhost:$HGPORT/?cmd=hello - capabilities: _evoext_getbundle_obscommon _evoext_obshash_0 _evoext_obshash_1 _evoext_obshashrange_v1 batch * (glob) + capabilities: _evoext_getbundle_obscommon _evoext_obshashrange_v1 batch * (glob) $ curl -s http://localhost:$HGPORT/?cmd=capabilities - _evoext_getbundle_obscommon _evoext_obshash_0 _evoext_obshash_1 _evoext_obshashrange_v1 batch * (no-eol) (glob) + _evoext_getbundle_obscommon _evoext_obshashrange_v1 batch * (no-eol) (glob) $ echo '[experimental]' >> server/.hg/hgrc $ echo 'evolution=!' >> server/.hg/hgrc @@ -178,9 +178,9 @@ phases $ curl -s http://localhost:$HGPORT/?cmd=hello - capabilities: _evoext_getbundle_obscommon _evoext_obshash_0 _evoext_obshash_1 _evoext_obshashrange_v1 batch * (glob) + capabilities: _evoext_getbundle_obscommon _evoext_obshashrange_v1 batch * (glob) $ curl -s http://localhost:$HGPORT/?cmd=capabilities - _evoext_getbundle_obscommon _evoext_obshash_0 _evoext_obshash_1 _evoext_obshashrange_v1 batch * (no-eol) (glob) + _evoext_getbundle_obscommon _evoext_obshashrange_v1 batch * (no-eol) (glob) Test obshashrange discover ===========================================
--- a/tests/test-extension-isolation.t Thu May 09 09:42:51 2019 -0700 +++ b/tests/test-extension-isolation.t Mon May 27 01:53:36 2019 +0200 @@ -121,8 +121,6 @@ [1] $ hg debugcapabilities http://$LOCALIP:$HGPORT/repo-evo | egrep 'topics|evoext' _evoext_getbundle_obscommon - _evoext_obshash_0 - _evoext_obshash_1 _evoext_obshashrange_v1 $ hg debugcapabilities http://$LOCALIP:$HGPORT/repo-no-ext | egrep 'topics|evoext' [1] @@ -144,21 +142,15 @@ [1] $ hg debugcapabilities http://$LOCALIP:$HGPORT/repo-both | egrep 'topics|evoext' _evoext_getbundle_obscommon - _evoext_obshash_0 - _evoext_obshash_1 _evoext_obshashrange_v1 topics $ hg debugcapabilities http://$LOCALIP:$HGPORT/repo-evo | egrep 'topics|evoext' _evoext_getbundle_obscommon - _evoext_obshash_0 - _evoext_obshash_1 _evoext_obshashrange_v1 $ hg debugcapabilities http://$LOCALIP:$HGPORT/repo-topic | egrep 'topics|evoext' topics $ hg debugcapabilities http://$LOCALIP:$HGPORT/repo-evo | egrep 'topics|evoext' _evoext_getbundle_obscommon - _evoext_obshash_0 - _evoext_obshash_1 _evoext_obshashrange_v1 $ hg debugcapabilities http://$LOCALIP:$HGPORT/repo-no-ext | egrep 'topics|evoext' [1]