# HG changeset patch # User Gregory Szorc # Date 2018-08-16 19:39:47 # Node ID 5b32b3c618b212d7b3101fc6df9eee3c0db42f55 # Parent b0c73866c9fb2f1479abdf3b43ba54c0e2606887 setdiscovery: don't use dagutil for rev -> node conversions We don't need to use dagutil to perform a simple rev -> node conversion. I haven't measured, but the new code is likely faster, as we avoid extra function calls and avoid some attribute lookups. Differential Revision: https://phab.mercurial-scm.org/D4304 diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py --- a/mercurial/debugcommands.py +++ b/mercurial/debugcommands.py @@ -791,9 +791,11 @@ def debugdiscovery(ui, repo, remoteurl=" if not opts.get('nonheads'): ui.write(("unpruned common: %s\n") % " ".join(sorted(short(n) for n in common))) - dag = dagutil.revlogdag(repo.changelog) + cl = repo.changelog + clnode = cl.node + dag = dagutil.revlogdag(cl) all = dag.ancestorset(dag.internalizeall(common)) - common = dag.externalizeall(dag.headsetofconnecteds(all)) + common = {clnode(r) for r in dag.headsetofconnecteds(all)} else: nodes = None if pushedrevs: diff --git a/mercurial/setdiscovery.py b/mercurial/setdiscovery.py --- a/mercurial/setdiscovery.py +++ b/mercurial/setdiscovery.py @@ -142,7 +142,9 @@ def findcommonheads(ui, local, remote, roundtrips = 0 cl = local.changelog + clnode = cl.node localsubset = None + if ancestorsof is not None: rev = local.changelog.rev localsubset = [rev(n) for n in ancestorsof] @@ -159,7 +161,7 @@ def findcommonheads(ui, local, remote, with remote.commandexecutor() as e: fheads = e.callcommand('heads', {}) fknown = e.callcommand('known', { - 'nodes': dag.externalizeall(sample), + 'nodes': [clnode(r) for r in sample], }) srvheadhashes, yesno = fheads.result(), fknown.result() @@ -176,12 +178,12 @@ def findcommonheads(ui, local, remote, srvheads = dag.internalizeall(srvheadhashes, filterunknown=True) if len(srvheads) == len(srvheadhashes): ui.debug("all remote heads known locally\n") - return (srvheadhashes, False, srvheadhashes,) + return srvheadhashes, False, srvheadhashes if len(sample) == len(ownheads) and all(yesno): ui.note(_("all local heads known remotely\n")) - ownheadhashes = dag.externalizeall(ownheads) - return (ownheadhashes, True, srvheadhashes,) + ownheadhashes = [clnode(r) for r in ownheads] + return ownheadhashes, True, srvheadhashes # full blown discovery @@ -235,7 +237,7 @@ def findcommonheads(ui, local, remote, with remote.commandexecutor() as e: yesno = e.callcommand('known', { - 'nodes': dag.externalizeall(sample), + 'nodes': [clnode(r) for r in sample], }).result() full = True @@ -268,4 +270,5 @@ def findcommonheads(ui, local, remote, return ({nullid}, True, srvheadhashes,) anyincoming = (srvheadhashes != [nullid]) - return dag.externalizeall(result), anyincoming, srvheadhashes + result = {clnode(r) for r in result} + return result, anyincoming, srvheadhashes