--- a/mercurial/bundle2.py Tue Oct 02 17:09:56 2018 +0300
+++ b/mercurial/bundle2.py Fri Oct 05 20:24:07 2018 +0300
@@ -2266,3 +2266,37 @@
repo.ui.debug('applying stream bundle\n')
streamclone.applybundlev2(repo, part, filecount, bytecount,
requirements)
+
+def widen_bundle(repo, diffmatcher, common, known, cgversion, ellipses):
+ """generates bundle2 for widening a narrow clone
+
+ repo is the localrepository instance
+ diffmatcher is a differencemacther of '(newincludes, newexcludes) -
+ (oldincludes, oldexcludes)'
+ common is set of common heads between server and client
+ known is a set of revs known on the client side (used in ellipses)
+ cgversion is the changegroup version to send
+ ellipses is boolean value telling whether to send ellipses data or not
+
+ returns bundle2 of the data required for extending
+ """
+ bundler = bundle20(repo.ui)
+ commonnodes = set()
+ cl = repo.changelog
+ for r in repo.revs("::%ln", common):
+ commonnodes.add(cl.node(r))
+ if commonnodes:
+ # XXX: we should only send the filelogs (and treemanifest). user
+ # already has the changelog and manifest
+ packer = changegroup.getbundler(cgversion, repo,
+ filematcher=diffmatcher,
+ fullnodes=commonnodes)
+ cgdata = packer.generate(set([nodemod.nullid]), list(commonnodes),
+ False, 'narrow_widen', changelog=False)
+
+ part = bundler.newpart('changegroup', data=cgdata)
+ part.addparam('version', cgversion)
+ if 'treemanifest' in repo.requirements:
+ part.addparam('treemanifest', '1')
+
+ return bundler