D4306: setdiscovery: don't use dagutil for node -> rev conversion

indygreg (Gregory Szorc) phabricator at mercurial-scm.org
Thu Aug 16 20:44:22 UTC 2018


indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  The node -> rev conversion is possible using standard storage APIs
  and doesn't need to involve the dagutil module.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D4306

AFFECTED FILES
  mercurial/debugcommands.py
  mercurial/setdiscovery.py

CHANGE DETAILS

diff --git a/mercurial/setdiscovery.py b/mercurial/setdiscovery.py
--- a/mercurial/setdiscovery.py
+++ b/mercurial/setdiscovery.py
@@ -143,11 +143,11 @@
     roundtrips = 0
     cl = local.changelog
     clnode = cl.node
+    clrev = cl.rev
     localsubset = None
 
     if ancestorsof is not None:
-        rev = local.changelog.rev
-        localsubset = [rev(n) for n in ancestorsof]
+        localsubset = [clrev(n) for n in ancestorsof]
     dag = dagutil.revlogdag(cl, localsubset=localsubset)
 
     # early exit if we know all the specified remote heads already
@@ -175,7 +175,17 @@
     # compatibility reasons)
     ui.status(_("searching for changes\n"))
 
-    srvheads = dag.internalizeall(srvheadhashes, filterunknown=True)
+    srvheads = []
+    for node in srvheadhashes:
+        if node == nullid:
+            continue
+
+        try:
+            srvheads.append(clrev(node))
+        # Catches unknown and filtered nodes.
+        except error.LookupError:
+            continue
+
     if len(srvheads) == len(srvheadhashes):
         ui.debug("all remote heads known locally\n")
         return srvheadhashes, False, srvheadhashes
diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -794,7 +794,7 @@
                 cl = repo.changelog
                 clnode = cl.node
                 dag = dagutil.revlogdag(cl)
-                all = dag.ancestorset(dag.internalizeall(common))
+                all = dag.ancestorset(cl.rev(n) for n in common)
                 common = {clnode(r) for r in dag.headsetofconnecteds(all)}
         else:
             nodes = None



To: indygreg, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list