--- 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