[PATCH 3 of 6] exchange: store outgoing instance bundle20 instances

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


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1432593644 25200
#      Mon May 25 15:40:44 2015 -0700
# Node ID a9a943bfb732069110dd2d211f842bad22547535
# Parent  123f42f6cc182ad6bc6105a4add222b9467834e7
exchange: store outgoing instance bundle20 instances

bundle2 provides a container to hold generic data. Currently, all
in-core users of this mechanism transfer data relevant to the state
of the entire repository as opposed to data specific to changesets.

Built on top of work to have changegroup functions expose a
discovery.outgoing that says what is in a changegroup, we now capture
the outgoing instance explicitly in bundle20 instances. This enables
future bundle2 part generators to examine the changesets sent and add
data for just that subset.

diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -469,8 +469,11 @@ class bundle20(object):
         self.ui = ui
         self._params = []
         self._parts = []
         self.capabilities = dict(capabilities)
+        # discovery.outgoing instance describing state of changegroup data.
+        # .missing will be the list of changesets being sent.
+        self.outgoing = None
 
     @property
     def nbparts(self):
         """total number of parts added to the bundler"""
diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -480,8 +480,9 @@ def _pushb2ctx(pushop, bundler):
     pushop.stepsdone.add('changesets')
     # Send known heads to the server for race detection.
     if not _pushcheckoutgoing(pushop):
         return
+    bundler.outgoing = pushop.outgoing
     pushop.repo.prepushoutgoinghooks(pushop.repo,
                                      pushop.remote,
                                      pushop.outgoing)
     if not pushop.force:
@@ -1235,25 +1236,28 @@ def _getbundlechangegrouppart(bundler, r
         # build changegroup bundle here.
         version = None
         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)[1]
+            outgoing, cg = changegroup.getchangegroupraw(repo, source,
+                                                         heads=heads,
+                                                         common=common,
+                                                         bundlecaps=bundlecaps)
         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)[1]
+            outgoing, cg = changegroup.getchangegroupraw(repo, source,
+                                                         heads=heads,
+                                                         common=common,
+                                                         bundlecaps=bundlecaps,
+                                                         version=version)
 
     if cg:
         part = bundler.newpart('changegroup', data=cg)
         if version is not None:
             part.addparam('version', version)
+        bundler.outgoing = outgoing
 
 @getbundle2partsgenerator('listkeys')
 def _getbundlelistkeysparts(bundler, repo, source, bundlecaps=None,
                             b2caps=None, **kwargs):


More information about the Mercurial-devel mailing list