Patchwork [7,of,8,V2] push: send highest changegroup format supported by both side

login
register
mail settings
Submitter Pierre-Yves David
Date Oct. 17, 2014, 7:56 p.m.
Message ID <cb2b0a3f6b61f4f826ec.1413575791@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/6392/
State Superseded
Commit 116b80d63815807b5ba4db03e501dec3992c2b10
Headers show

Comments

Pierre-Yves David - Oct. 17, 2014, 7:56 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1413573564 25200
#      Fri Oct 17 12:19:24 2014 -0700
# Node ID cb2b0a3f6b61f4f826ec79543348718b1763c889
# Parent  6a9148c4306d43f56d2b607b7ff62f08637ca44e
push: send highest changegroup format supported by both side

When using bundle2, we find the common subset of supported changegroup-packers
and we pick the max of them. This allow to use generaldelta aware changegroups through
bundle2.

Patch

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -439,13 +439,21 @@  def _pushb2ctx(pushop, bundler):
     pushop.repo.prepushoutgoinghooks(pushop.repo,
                                      pushop.remote,
                                      pushop.outgoing)
     if not pushop.force:
         bundler.newpart('B2X:CHECK:HEADS', data=iter(pushop.remoteheads))
+    b2caps = bundle2.bundle2caps(pushop.remote)
+    cgversions = b2caps.get('b2x:changegroup', ('1',))
+    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.getlocalchangegroupraw(pushop.repo, 'push',
-                                            pushop.outgoing)
+                                            pushop.outgoing,
+                                            version=version)
     cgpart = bundler.newpart('B2X:CHANGEGROUP', data=cg)
+    cgpart.addparam('version', version)
     def handlereply(op):
         """extract addchangroup returns from server reply"""
         cgreplies = op.records.getreplies(cgpart.id)
         assert len(cgreplies['changegroup']) == 1
         pushop.cgresult = cgreplies['changegroup'][0]['return']