changeset 21062:e7c0a65a5c9c

bundle2: use headerless HG10UN stream in changegroup Using `readbundle` in the part handlers creates a circular import hell. We are now using a simple `HG10UN` stream with no header. Some parameters may later be introduced on the part to change parameter. Producers are updated as well.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Mon, 14 Apr 2014 14:46:32 -0400
parents 62d35f251c60
children 7ca4f2049d3b
files mercurial/bundle2.py mercurial/exchange.py tests/test-bundle2.t
diffstat 3 files changed, 6 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/bundle2.py	Thu Apr 10 10:53:43 2014 -0700
+++ b/mercurial/bundle2.py	Mon Apr 14 14:46:32 2014 -0400
@@ -639,7 +639,7 @@
     # we need to make sure we trigger the creation of a transaction object used
     # for the whole processing scope.
     op.gettransaction()
-    cg = changegroup.readbundle(inpart, 'bundle2part')
+    cg = changegroup.unbundle10(inpart, 'UN')
     ret = changegroup.addchangegroup(op.repo, cg, 'bundle2', 'bundle2')
     op.records.add('changegroup', {'return': ret})
     if op.reply is not None:
--- a/mercurial/exchange.py	Thu Apr 10 10:53:43 2014 -0700
+++ b/mercurial/exchange.py	Mon Apr 14 14:46:32 2014 -0400
@@ -109,6 +109,7 @@
                 if pushop.remote.capable('bundle2'):
                     _pushbundle2(pushop)
                 else:
+                    _pushchangeset(pushop)
             _pushcomputecommonheads(pushop)
             _pushsyncphase(pushop)
             _pushobsolete(pushop)
@@ -186,11 +187,7 @@
         bundler.addpart(part)
     # add the changegroup bundle
     cg = changegroup.getlocalbundle(pushop.repo, 'push', pushop.outgoing)
-    def cgchunks(cg=cg):
-        yield 'HG10UN'
-        for c in cg.getchunks():
-            yield c
-    cgpart = bundle2.bundlepart('CHANGEGROUP', data=cgchunks())
+    cgpart = bundle2.bundlepart('CHANGEGROUP', data=cg.getchunks())
     bundler.addpart(cgpart)
     stream = util.chunkbuffer(bundler.getchunks())
     sent = bundle2.unbundle20(pushop.repo.ui, stream)
@@ -634,11 +631,7 @@
     # very crude first implementation,
     # the bundle API will change and the generation will be done lazily.
     bundler = bundle2.bundle20(repo.ui)
-    def cgchunks(cg=cg):
-        yield 'HG10UN'
-        for c in cg.getchunks():
-            yield c
-    part = bundle2.bundlepart('changegroup', data=cgchunks())
+    part = bundle2.bundlepart('changegroup', data=cg.getchunks())
     bundler.addpart(part)
     return bundle2.unbundle20(repo.ui, util.chunkbuffer(bundler.getchunks()))
 
--- a/tests/test-bundle2.t	Thu Apr 10 10:53:43 2014 -0700
+++ b/tests/test-bundle2.t	Mon Apr 14 14:46:32 2014 -0400
@@ -67,11 +67,7 @@
   >             headcommon  = [c.node() for c in repo.set('parents(%ld) - %ld', revs, revs)]
   >             outgoing = discovery.outgoing(repo.changelog, headcommon, headmissing)
   >             cg = changegroup.getlocalbundle(repo, 'test:bundle2', outgoing, None)
-  >             def cgchunks(cg=cg):
-  >                 yield 'HG10UN'
-  >                 for c in cg.getchunks():
-  >                    yield c
-  >             part = bundle2.bundlepart('changegroup', data=cgchunks())
+  >             part = bundle2.bundlepart('changegroup', data=cg.getchunks())
   >             bundler.addpart(part)
   > 
   >     if opts['parts']:
@@ -605,7 +601,7 @@
   end of bundle
 
   $ cat ../rev.hg2
-  HG20\x00\x00\x00\x12\x0bchangegroup\x00\x00\x00\x00\x00\x00\x00\x00\x06\x19HG10UN\x00\x00\x00\xa42\xafv\x86\xd4\x03\xcfE\xb5\xd9_-p\xce\xbe\xa5\x87\xac\x80j_\xdd\xd9\x89W\xc8\xa5JMCm\xfe\x1d\xa9\xd8\x7f!\xa1\xb9{\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x002\xafv\x86\xd4\x03\xcfE\xb5\xd9_-p\xce\xbe\xa5\x87\xac\x80j\x00\x00\x00\x00\x00\x00\x00)\x00\x00\x00)6e1f4c47ecb533ffd0c8e52cdc88afb6cd39e20c (esc)
+  HG20\x00\x00\x00\x12\x0bchangegroup\x00\x00\x00\x00\x00\x00\x00\x00\x06\x13\x00\x00\x00\xa42\xafv\x86\xd4\x03\xcfE\xb5\xd9_-p\xce\xbe\xa5\x87\xac\x80j_\xdd\xd9\x89W\xc8\xa5JMCm\xfe\x1d\xa9\xd8\x7f!\xa1\xb9{\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x002\xafv\x86\xd4\x03\xcfE\xb5\xd9_-p\xce\xbe\xa5\x87\xac\x80j\x00\x00\x00\x00\x00\x00\x00)\x00\x00\x00)6e1f4c47ecb533ffd0c8e52cdc88afb6cd39e20c (esc)
   \x00\x00\x00f\x00\x00\x00h\x00\x00\x00\x02D (esc)
   \x00\x00\x00i\x00\x00\x00j\x00\x00\x00\x01D\x00\x00\x00\xa4\x95 \xee\xa7\x81\xbc\xca\x16\xc1\xe1Z\xcc\x0b\xa1C5\xa0\xe8\xe5\xba\xcd\x01\x0b\x8c\xd9\x98\xf3\x98\x1aZ\x81\x15\xf9O\x8d\xa4\xabP`\x89\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x95 \xee\xa7\x81\xbc\xca\x16\xc1\xe1Z\xcc\x0b\xa1C5\xa0\xe8\xe5\xba\x00\x00\x00\x00\x00\x00\x00)\x00\x00\x00)4dece9c826f69490507b98c6383a3009b295837d (esc)
   \x00\x00\x00f\x00\x00\x00h\x00\x00\x00\x02E (esc)