[PATCH 1 of 6] changegroup: expose list of changesets from getsubsetraw

Gregory Szorc gregory.szorc at gmail.com
Tue May 26 00:42:34 UTC 2015


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1432589936 25200
#      Mon May 25 14:38:56 2015 -0700
# Node ID ea28b7239085bbc7d561ab6aa6f86bdc19f77a25
# Parent  605b1d32c1c011d56233f28923ee5354fce7e426
changegroup: expose list of changesets from getsubsetraw

Currently, when generating changegroups, it is possible for the caller
to not know exactly what data is inside without parsing the returned
data stream. This is inefficient and adds complexity.

Return the list of changesets from getsubsetraw to make this data
more widely available.

diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -549,8 +549,13 @@ def _changegroupinfo(repo, nodes, source
         for node in nodes:
             repo.ui.debug("%s\n" % hex(node))
 
 def getsubsetraw(repo, outgoing, bundler, source, fastpath=False):
+    """Obtain changegroup data.
+
+    Returns a list of binary changeset nodes and an iterator of raw
+    changegroup data.
+    """
     repo = repo.unfiltered()
     commonrevs = outgoing.common
     csets = outgoing.missing
     heads = outgoing.missingheads
@@ -562,12 +567,12 @@ def getsubsetraw(repo, outgoing, bundler
             repo.filtername is None and heads == sorted(repo.heads()))
 
     repo.hook('preoutgoing', throw=True, source=source)
     _changegroupinfo(repo, csets, source)
-    return bundler.generate(commonrevs, csets, fastpathlinkrev, source)
+    return csets, bundler.generate(commonrevs, csets, fastpathlinkrev, source)
 
 def getsubset(repo, outgoing, bundler, source, fastpath=False, version='01'):
-    gengroup = getsubsetraw(repo, outgoing, bundler, source, fastpath)
+    csets, gengroup = getsubsetraw(repo, outgoing, bundler, source, fastpath)
     return packermap[version][1](util.chunkbuffer(gengroup), 'UN')
 
 def changegroupsubset(repo, roots, heads, source, version='01'):
     """Compute a changegroup consisting of all the nodes that are
@@ -602,9 +607,9 @@ def getlocalchangegroupraw(repo, source,
     precomputed sets in outgoing. Returns a raw changegroup generator."""
     if not outgoing.missing:
         return None
     bundler = packermap[version][0](repo, bundlecaps)
-    return getsubsetraw(repo, outgoing, bundler, source)
+    return getsubsetraw(repo, outgoing, bundler, source)[1]
 
 def getlocalchangegroup(repo, source, outgoing, bundlecaps=None):
     """Like getbundle, but taking a discovery.outgoing as an argument.
 


More information about the Mercurial-devel mailing list