setdiscovery: don't use dagutil for rev -> node conversions
authorGregory Szorc <gregory.szorc@gmail.com>
Thu, 16 Aug 2018 19:39:47 +0000
changeset 39159 5b32b3c618b2
parent 39158 b0c73866c9fb
child 39160 0e46b92b37b1
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
mercurial/debugcommands.py
mercurial/setdiscovery.py
--- a/mercurial/debugcommands.py	Thu Aug 16 19:23:24 2018 +0000
+++ b/mercurial/debugcommands.py	Thu Aug 16 19:39:47 2018 +0000
@@ -791,9 +791,11 @@
             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:
--- a/mercurial/setdiscovery.py	Thu Aug 16 19:23:24 2018 +0000
+++ b/mercurial/setdiscovery.py	Thu Aug 16 19:39:47 2018 +0000
@@ -142,7 +142,9 @@
 
     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 @@
     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 @@
     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 @@
 
         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 @@
         return ({nullid}, True, srvheadhashes,)
 
     anyincoming = (srvheadhashes != [nullid])
-    return dag.externalizeall(result), anyincoming, srvheadhashes
+    result = {clnode(r) for r in result}
+    return result, anyincoming, srvheadhashes