Mercurial > hg
comparison mercurial/exchange.py @ 46711:a41565bef69f
changegroup: add v4 changegroup for revlog v2 exchange
This change only adds the required infrastructure for the new changegroup format
and does not do any actual exchange. This will be done in the next patches.
Differential Revision: https://phab.mercurial-scm.org/D10026
author | Raphaël Gomès <rgomes@octobus.net> |
---|---|
date | Thu, 18 Feb 2021 17:36:52 +0100 |
parents | db9e33beb0fb |
children | bc2519513ae0 |
comparison
equal
deleted
inserted
replaced
46710:4cd214c9948d | 46711:a41565bef69f |
---|---|
2247 return any(cap.startswith(b'HG2') for cap in bundlecaps) | 2247 return any(cap.startswith(b'HG2') for cap in bundlecaps) |
2248 return False | 2248 return False |
2249 | 2249 |
2250 | 2250 |
2251 def getbundlechunks( | 2251 def getbundlechunks( |
2252 repo, source, heads=None, common=None, bundlecaps=None, **kwargs | 2252 repo, |
2253 source, | |
2254 heads=None, | |
2255 common=None, | |
2256 bundlecaps=None, | |
2257 remote_sidedata=None, | |
2258 **kwargs | |
2253 ): | 2259 ): |
2254 """Return chunks constituting a bundle's raw data. | 2260 """Return chunks constituting a bundle's raw data. |
2255 | 2261 |
2256 Could be a bundle HG10 or a bundle HG20 depending on bundlecaps | 2262 Could be a bundle HG10 or a bundle HG20 depending on bundlecaps |
2257 passed. | 2263 passed. |
2277 outgoing = _computeoutgoing(repo, heads, common) | 2283 outgoing = _computeoutgoing(repo, heads, common) |
2278 info[b'bundleversion'] = 1 | 2284 info[b'bundleversion'] = 1 |
2279 return ( | 2285 return ( |
2280 info, | 2286 info, |
2281 changegroup.makestream( | 2287 changegroup.makestream( |
2282 repo, outgoing, b'01', source, bundlecaps=bundlecaps | 2288 repo, |
2289 outgoing, | |
2290 b'01', | |
2291 source, | |
2292 bundlecaps=bundlecaps, | |
2293 remote_sidedata=remote_sidedata, | |
2283 ), | 2294 ), |
2284 ) | 2295 ) |
2285 | 2296 |
2286 # bundle20 case | 2297 # bundle20 case |
2287 info[b'bundleversion'] = 2 | 2298 info[b'bundleversion'] = 2 |
2301 bundler, | 2312 bundler, |
2302 repo, | 2313 repo, |
2303 source, | 2314 source, |
2304 bundlecaps=bundlecaps, | 2315 bundlecaps=bundlecaps, |
2305 b2caps=b2caps, | 2316 b2caps=b2caps, |
2317 remote_sidedata=remote_sidedata, | |
2306 **pycompat.strkwargs(kwargs) | 2318 **pycompat.strkwargs(kwargs) |
2307 ) | 2319 ) |
2308 | 2320 |
2309 info[b'prefercompressed'] = bundler.prefercompressed | 2321 info[b'prefercompressed'] = bundler.prefercompressed |
2310 | 2322 |
2323 source, | 2335 source, |
2324 bundlecaps=None, | 2336 bundlecaps=None, |
2325 b2caps=None, | 2337 b2caps=None, |
2326 heads=None, | 2338 heads=None, |
2327 common=None, | 2339 common=None, |
2340 remote_sidedata=None, | |
2328 **kwargs | 2341 **kwargs |
2329 ): | 2342 ): |
2330 """add a changegroup part to the requested bundle""" | 2343 """add a changegroup part to the requested bundle""" |
2331 if not kwargs.get('cg', True) or not b2caps: | 2344 if not kwargs.get('cg', True) or not b2caps: |
2332 return | 2345 return |
2353 matcher = narrowspec.match(repo.root, include=include, exclude=exclude) | 2366 matcher = narrowspec.match(repo.root, include=include, exclude=exclude) |
2354 else: | 2367 else: |
2355 matcher = None | 2368 matcher = None |
2356 | 2369 |
2357 cgstream = changegroup.makestream( | 2370 cgstream = changegroup.makestream( |
2358 repo, outgoing, version, source, bundlecaps=bundlecaps, matcher=matcher | 2371 repo, |
2372 outgoing, | |
2373 version, | |
2374 source, | |
2375 bundlecaps=bundlecaps, | |
2376 matcher=matcher, | |
2377 remote_sidedata=remote_sidedata, | |
2359 ) | 2378 ) |
2360 | 2379 |
2361 part = bundler.newpart(b'changegroup', data=cgstream) | 2380 part = bundler.newpart(b'changegroup', data=cgstream) |
2362 if cgversions: | 2381 if cgversions: |
2363 part.addparam(b'version', version) | 2382 part.addparam(b'version', version) |