[PATCH 1 of 6] changegroup: expose outgoing instance from getchangegroupraw

Gregory Szorc gregory.szorc at gmail.com
Sun May 31 19:28:26 CDT 2015


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1432592438 25200
#      Mon May 25 15:20:38 2015 -0700
# Node ID c86d558a097b3bb6a5d6a3423518984d9dd70898
# Parent  4cc3fb23881d9abc7745501ef0d777e5976ddb52
changegroup: expose outgoing instance from getchangegroupraw

Currently, consumers to getchangegroupraw have no way of knowing what
changesets are included without reading the output stream. This is
extra work and inefficient.

Change the API of getchangegroupraw to return the computed
discovery.outgoing instance, which contains a "missing" property that
holds the list of changesets in the changegroup.

diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -643,13 +643,17 @@ def getchangegroupraw(repo, source, head
 
     If version is None, use a version '1' changegroup.
 
     The nodes in common might not all be known locally due to the way the
-    current discovery protocol works. Returns a raw changegroup generator.
+    current discovery protocol works.
+
+    Returns a discovery.outgoing instance and an iterator over raw
+    changegroup data.
     """
     outgoing = _computeoutgoing(repo, heads, common)
-    return getlocalchangegroupraw(repo, source, outgoing, bundlecaps=bundlecaps,
-                                  version=version)
+    return outgoing, getlocalchangegroupraw(repo, source, outgoing,
+                                            bundlecaps=bundlecaps,
+                                            version=version)
 
 def getchangegroup(repo, source, heads=None, common=None, bundlecaps=None):
     """Like changegroupsubset, but returns the set difference between the
     ancestors of heads and the ancestors common.
diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -1236,18 +1236,18 @@ def _getbundlechangegrouppart(bundler, r
         cgversions = b2caps.get('changegroup')
         if not cgversions:  # 3.1 and 3.2 ship with an empty value
             cg = changegroup.getchangegroupraw(repo, source, heads=heads,
                                                common=common,
-                                               bundlecaps=bundlecaps)
+                                               bundlecaps=bundlecaps)[1]
         else:
             cgversions = [v for v in cgversions if v in changegroup.packermap]
             if not cgversions:
                 raise ValueError(_('no common changegroup version'))
             version = max(cgversions)
             cg = changegroup.getchangegroupraw(repo, source, heads=heads,
                                                common=common,
                                                bundlecaps=bundlecaps,
-                                               version=version)
+                                               version=version)[1]
 
     if cg:
         part = bundler.newpart('changegroup', data=cg)
         if version is not None:


More information about the Mercurial-devel mailing list