diff mercurial/bundle2.py @ 20950:c7ceae0faf69

bundle2: first crude version of bundling changeset with bundle2 The current changegroup format is put in a "changegroup" part and processed by an appropriate handlers. This is not production ready code, but let us start smoke testing.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Mon, 24 Mar 2014 19:37:59 -0700
parents 571f2903ff1e
children b24ee5076b94
line wrap: on
line diff
--- a/mercurial/bundle2.py	Wed Apr 02 22:37:50 2014 -0700
+++ b/mercurial/bundle2.py	Mon Mar 24 19:37:59 2014 -0700
@@ -141,6 +141,7 @@
 import struct
 import urllib
 import string
+import StringIO
 
 import changegroup
 from i18n import _
@@ -524,3 +525,17 @@
         # end of payload
         yield _pack(_fpayloadsize, 0)
 
+@parthandler('changegroup')
+def handlechangegroup(op, part):
+    """apply a changegroup part on the repo
+
+    This is a very early implementation that will massive rework before being
+    inflicted to any end-user.
+    """
+    data = StringIO.StringIO(part.data)
+    data.seek(0)
+    cg = changegroup.readbundle(data, 'bundle2part')
+    ret = changegroup.addchangegroup(op.repo, cg, 'bundle2', 'bundle2')
+    op.records.add('changegroup', {'return': ret})
+
+