computeoutgoing: move the function from 'changegroup' to 'exchange'
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>
Tue, 09 Aug 2016 17:06:35 +0200
changeset 29808 8d226db31f20
parent 29807 d4e026341e16
child 29809 7025693433b2
computeoutgoing: move the function from 'changegroup' to 'exchange' Now that all users are in exchange, we can safely move the code in the 'exchange' module. This function is really about processing the argument of a 'getbundle' call, so it even makes senses to do so.
mercurial/changegroup.py
mercurial/exchange.py
--- a/mercurial/changegroup.py	Tue Aug 09 17:00:38 2016 +0200
+++ b/mercurial/changegroup.py	Tue Aug 09 17:06:35 2016 +0200
@@ -15,7 +15,6 @@
 from .i18n import _
 from .node import (
     hex,
-    nullid,
     nullrev,
     short,
 )
@@ -968,25 +967,6 @@
     bundler = getbundler(version, repo, bundlecaps)
     return getsubset(repo, outgoing, bundler, source)
 
-def computeoutgoing(repo, heads, common):
-    """Computes which revs are outgoing given a set of common
-    and a set of heads.
-
-    This is a separate function so extensions can have access to
-    the logic.
-
-    Returns a discovery.outgoing object.
-    """
-    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(repo, common, heads)
-
 def getchangegroup(repo, source, outgoing, bundlecaps=None,
                    version='01'):
     """Like changegroupsubset, but returns the set difference between the
--- a/mercurial/exchange.py	Tue Aug 09 17:00:38 2016 +0200
+++ b/mercurial/exchange.py	Tue Aug 09 17:06:35 2016 +0200
@@ -257,6 +257,25 @@
         return bundler.newpart('obsmarkers', data=stream)
     return None
 
+def _computeoutgoing(repo, heads, common):
+    """Computes which revs are outgoing given a set of common
+    and a set of heads.
+
+    This is a separate function so extensions can have access to
+    the logic.
+
+    Returns a discovery.outgoing object.
+    """
+    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(repo, common, heads)
+
 def _forcebundle1(op):
     """return true if a pull/push must use bundle1
 
@@ -1536,7 +1555,7 @@
         if kwargs:
             raise ValueError(_('unsupported getbundle arguments: %s')
                              % ', '.join(sorted(kwargs.keys())))
-        outgoing = changegroup.computeoutgoing(repo, heads, common)
+        outgoing = _computeoutgoing(repo, heads, common)
         return changegroup.getchangegroup(repo, source, outgoing,
                                           bundlecaps=bundlecaps)
 
@@ -1573,7 +1592,7 @@
             if not cgversions:
                 raise ValueError(_('no common changegroup version'))
             version = max(cgversions)
-        outgoing = changegroup.computeoutgoing(repo, heads, common)
+        outgoing = _computeoutgoing(repo, heads, common)
         cg = changegroup.getlocalchangegroupraw(repo, source, outgoing,
                                                 bundlecaps=bundlecaps,
                                                 version=version)
@@ -1626,7 +1645,7 @@
     if not (kwargs.get('cg', True) and 'hgtagsfnodes' in b2caps):
         return
 
-    outgoing = changegroup.computeoutgoing(repo, heads, common)
+    outgoing = _computeoutgoing(repo, heads, common)
 
     if not outgoing.missingheads:
         return