##// END OF EJS Templates
narrow: move the code to generate a widening bundle2 to core...
Pulkit Goyal -
r40108:1ea80ac1 default
parent child Browse files
Show More
@@ -50,40 +50,6 b' def getrepocaps_narrow(orig, repo, **kwa'
50 50 caps[NARROWCAP] = ['v0']
51 51 return caps
52 52
53 def widen_bundle(repo, diffmatcher, common, known, cgversion, ellipses):
54 """generates bundle2 for widening a narrow clone
55
56 repo is the localrepository instance
57 diffmatcher is a differencemacther of '(newincludes, newexcludes) -
58 (oldincludes, oldexcludes)'
59 common is set of common heads between server and client
60 known is a set of revs known on the client side (used in ellipses)
61 cgversion is the changegroup version to send
62 ellipses is boolean value telling whether to send ellipses data or not
63
64 returns bundle2 of the data required for extending
65 """
66 bundler = bundle2.bundle20(repo.ui)
67 commonnodes = set()
68 cl = repo.changelog
69 for r in repo.revs("::%ln", common):
70 commonnodes.add(cl.node(r))
71 if commonnodes:
72 # XXX: we should only send the filelogs (and treemanifest). user
73 # already has the changelog and manifest
74 packer = changegroup.getbundler(cgversion, repo,
75 filematcher=diffmatcher,
76 fullnodes=commonnodes)
77 cgdata = packer.generate(set([nullid]), list(commonnodes), False,
78 'narrow_widen', changelog=False)
79
80 part = bundler.newpart('changegroup', data=cgdata)
81 part.addparam('version', cgversion)
82 if 'treemanifest' in repo.requirements:
83 part.addparam('treemanifest', '1')
84
85 return bundler
86
87 53 # Serve a changegroup for a client with a narrow clone.
88 54 def getbundlechangegrouppart_narrow(bundler, repo, source,
89 55 bundlecaps=None, b2caps=None, heads=None,
@@ -21,8 +21,6 b' from mercurial import ('
21 21 wireprotov1server,
22 22 )
23 23
24 from . import narrowbundle2
25
26 24 def uisetup():
27 25 extensions.wrapfunction(wireprotov1server, '_capabilities', addnarrowcap)
28 26 wireprotov1peer.wirepeer.narrow_widen = peernarrowwiden
@@ -95,7 +93,7 b' def narrow_widen(repo, proto, oldinclude'
95 93 exclude=oldexcludes)
96 94 diffmatch = matchmod.differencematcher(newmatch, oldmatch)
97 95
98 bundler = narrowbundle2.widen_bundle(repo, diffmatch, common, known,
96 bundler = bundle2.widen_bundle(repo, diffmatch, common, known,
99 97 cgversion, ellipses)
100 98 except error.Abort as exc:
101 99 bundler = bundle2.bundle20(repo.ui)
@@ -2266,3 +2266,37 b' def handlestreamv2bundle(op, part):'
2266 2266 repo.ui.debug('applying stream bundle\n')
2267 2267 streamclone.applybundlev2(repo, part, filecount, bytecount,
2268 2268 requirements)
2269
2270 def widen_bundle(repo, diffmatcher, common, known, cgversion, ellipses):
2271 """generates bundle2 for widening a narrow clone
2272
2273 repo is the localrepository instance
2274 diffmatcher is a differencemacther of '(newincludes, newexcludes) -
2275 (oldincludes, oldexcludes)'
2276 common is set of common heads between server and client
2277 known is a set of revs known on the client side (used in ellipses)
2278 cgversion is the changegroup version to send
2279 ellipses is boolean value telling whether to send ellipses data or not
2280
2281 returns bundle2 of the data required for extending
2282 """
2283 bundler = bundle20(repo.ui)
2284 commonnodes = set()
2285 cl = repo.changelog
2286 for r in repo.revs("::%ln", common):
2287 commonnodes.add(cl.node(r))
2288 if commonnodes:
2289 # XXX: we should only send the filelogs (and treemanifest). user
2290 # already has the changelog and manifest
2291 packer = changegroup.getbundler(cgversion, repo,
2292 filematcher=diffmatcher,
2293 fullnodes=commonnodes)
2294 cgdata = packer.generate(set([nodemod.nullid]), list(commonnodes),
2295 False, 'narrow_widen', changelog=False)
2296
2297 part = bundler.newpart('changegroup', data=cgdata)
2298 part.addparam('version', cgversion)
2299 if 'treemanifest' in repo.requirements:
2300 part.addparam('treemanifest', '1')
2301
2302 return bundler
General Comments 0
You need to be logged in to leave comments. Login now