[PATCH 2 of 3] changegroup: refactor outgoing logic into a function

Durham Goode durham at fb.com
Thu May 8 01:44:17 UTC 2014


# HG changeset patch
# User Durham Goode <durham at fb.com>
# Date 1399508554 25200
#      Wed May 07 17:22:34 2014 -0700
# Node ID d2f14d289ef0b11f96262f0b226c6c360fa8467e
# Parent  c727b16938123025ab733c7c996bec556e45860a
changegroup: refactor outgoing logic into a function

Extensions that add to bundle2 will want to know which commits are outgoing so
they can bundle data that is appropriate to those commits. This moves the logic
for figuring that out to a separate function so extensions can do the same
computation.

diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -493,6 +493,17 @@
     bundler = bundle10(repo, bundlecaps)
     return getsubset(repo, outgoing, bundler, source)
 
+def getoutgoing(repo, heads, common):
+    cl = repo.changelog
+    if common:
+        hasnode = cl.hasnode
+        common = [n for n in common if hasnode(n)]
+    else:
+        common = [nullid]
+    if not heads:
+        heads = cl.heads()
+    return discovery.outgoing(cl, common, heads)
+
 def getbundle(repo, source, heads=None, common=None, bundlecaps=None):
     """Like changegroupsubset, but returns the set difference between the
     ancestors of heads and the ancestors common.
@@ -502,15 +513,7 @@
     The nodes in common might not all be known locally due to the way the
     current discovery protocol works.
     """
-    cl = repo.changelog
-    if common:
-        hasnode = cl.hasnode
-        common = [n for n in common if hasnode(n)]
-    else:
-        common = [nullid]
-    if not heads:
-        heads = cl.heads()
-    outgoing = discovery.outgoing(cl, common, heads)
+    outgoing = getoutgoing(repo, heads, common)
     return getlocalbundle(repo, source, outgoing, bundlecaps=bundlecaps)
 
 def changegroup(repo, basenodes, source):



More information about the Mercurial-devel mailing list