bundle2: provide number of changesets information to 'addchangegroup'
authorPierre-Yves David <pierre-yves.david@fb.com>
Sun, 07 Jun 2015 15:57:54 -0700
changeset 25518 ca656f3dffd7
parent 25517 513c31d8652f
child 25519 09e2cb2a00d7
bundle2: provide number of changesets information to 'addchangegroup' We can now link the two efforts and provided more useful information when pulling changesets.
mercurial/bundle2.py
--- a/mercurial/bundle2.py	Sun Jun 07 15:57:40 2015 -0700
+++ b/mercurial/bundle2.py	Sun Jun 07 15:57:54 2015 -0700
@@ -1146,7 +1146,7 @@
     obscaps = caps.get('obsmarkers', ())
     return [int(c[1:]) for c in obscaps if c.startswith('V')]
 
-@parthandler('changegroup', ('version',))
+@parthandler('changegroup', ('version', 'nbchanges'))
 def handlechangegroup(op, inpart):
     """apply a changegroup part on the repo
 
@@ -1165,7 +1165,11 @@
     cg = unpacker(inpart, 'UN')
     # the source and url passed here are overwritten by the one contained in
     # the transaction.hookargs argument. So 'bundle2' is a placeholder
-    ret = changegroup.addchangegroup(op.repo, cg, 'bundle2', 'bundle2')
+    nbchangesets = None
+    if 'nbchanges' in inpart.params:
+        nbchangesets = int(inpart.params.get('nbchanges'))
+    ret = changegroup.addchangegroup(op.repo, cg, 'bundle2', 'bundle2',
+                                     expectedtotal=nbchangesets)
     op.records.add('changegroup', {'return': ret})
     if op.reply is not None:
         # This is definitely not the final form of this