##// END OF EJS Templates
changegroup: add v4 changegroup for revlog v2 exchange...
Raphaël Gomès -
r47445:a41565be default
parent child Browse files
Show More
@@ -306,6 +306,7 b' class remotefilelog(object):'
306 306 assumehaveparentrevisions=False,
307 307 deltaprevious=False,
308 308 deltamode=None,
309 sidedata_helpers=None,
309 310 ):
310 311 # we don't use any of these parameters here
311 312 del nodesorder, revisiondata, assumehaveparentrevisions, deltaprevious
@@ -333,6 +334,8 b' class remotefilelog(object):'
333 334 baserevisionsize=None,
334 335 revision=revision,
335 336 delta=delta,
337 # Sidedata is not supported yet
338 sidedata=None,
336 339 )
337 340
338 341 def revdiff(self, node1, node2):
@@ -67,7 +67,7 b' class shallowcg1packer(changegroup.cgpac'
67 67 shallowcg1packer, self, nodelist, rlog, lookup, units=units
68 68 )
69 69
70 def generatefiles(self, changedfiles, *args):
70 def generatefiles(self, changedfiles, *args, **kwargs):
71 71 try:
72 72 linknodes, commonrevs, source = args
73 73 except ValueError:
@@ -92,7 +92,9 b' class shallowcg1packer(changegroup.cgpac'
92 92 [f for f in changedfiles if not repo.shallowmatch(f)]
93 93 )
94 94
95 return super(shallowcg1packer, self).generatefiles(changedfiles, *args)
95 return super(shallowcg1packer, self).generatefiles(
96 changedfiles, *args, **kwargs
97 )
96 98
97 99 def shouldaddfilegroups(self, source):
98 100 repo = self._repo
@@ -176,9 +178,11 b' def makechangegroup(orig, repo, outgoing'
176 178 repo.shallowmatch = original
177 179
178 180
179 def addchangegroupfiles(orig, repo, source, revmap, trp, expectedfiles, *args):
181 def addchangegroupfiles(
182 orig, repo, source, revmap, trp, expectedfiles, *args, **kwargs
183 ):
180 184 if not shallowutil.isenabled(repo):
181 return orig(repo, source, revmap, trp, expectedfiles, *args)
185 return orig(repo, source, revmap, trp, expectedfiles, *args, **kwargs)
182 186
183 187 newfiles = 0
184 188 visited = set()
@@ -272,7 +276,7 b' def addchangegroupfiles(orig, repo, sour'
272 276
273 277 revisiondata = revisiondatas[(f, node)]
274 278 # revisiondata: (node, p1, p2, cs, deltabase, delta, flags)
275 node, p1, p2, linknode, deltabase, delta, flags = revisiondata
279 node, p1, p2, linknode, deltabase, delta, flags, sidedata = revisiondata
276 280
277 281 if not available(f, node, f, deltabase):
278 282 continue
@@ -681,7 +681,16 b' class sqlitefilestore(object):'
681 681 ):
682 682 empty = True
683 683
684 for node, p1, p2, linknode, deltabase, delta, wireflags in deltas:
684 for (
685 node,
686 p1,
687 p2,
688 linknode,
689 deltabase,
690 delta,
691 wireflags,
692 sidedata,
693 ) in deltas:
685 694 storeflags = 0
686 695
687 696 if wireflags & repository.REVISION_FLAG_CENSORED:
@@ -61,7 +61,7 b' class bundlerevlog(revlog.revlog):'
61 61 self.repotiprev = n - 1
62 62 self.bundlerevs = set() # used by 'bundle()' revset expression
63 63 for deltadata in cgunpacker.deltaiter():
64 node, p1, p2, cs, deltabase, delta, flags = deltadata
64 node, p1, p2, cs, deltabase, delta, flags, sidedata = deltadata
65 65
66 66 size = len(delta)
67 67 start = cgunpacker.tell() - size
@@ -32,6 +32,7 b' from . import ('
32 32 )
33 33
34 34 from .interfaces import repository
35 from .revlogutils import sidedata as sidedatamod
35 36
36 37 _CHANGEGROUPV1_DELTA_HEADER = struct.Struct(b"20s20s20s20s")
37 38 _CHANGEGROUPV2_DELTA_HEADER = struct.Struct(b"20s20s20s20s20s")
@@ -202,7 +203,9 b' class cg1unpacker(object):'
202 203 header = self.deltaheader.unpack(headerdata)
203 204 delta = readexactly(self._stream, l - self.deltaheadersize)
204 205 node, p1, p2, deltabase, cs, flags = self._deltaheader(header, prevnode)
205 return (node, p1, p2, cs, deltabase, delta, flags)
206 # cg4 forward-compat
207 sidedata = {}
208 return (node, p1, p2, cs, deltabase, delta, flags, sidedata)
206 209
207 210 def getchunks(self):
208 211 """returns all the chunks contains in the bundle
@@ -552,6 +555,29 b' class cg3unpacker(cg2unpacker):'
552 555 raise error.Abort(_(b"received dir revlog group is empty"))
553 556
554 557
558 class cg4unpacker(cg3unpacker):
559 """Unpacker for cg4 streams.
560
561 cg4 streams add support for exchanging sidedata.
562 """
563
564 version = b'04'
565
566 def deltachunk(self, prevnode):
567 res = super(cg4unpacker, self).deltachunk(prevnode)
568 if not res:
569 return res
570
571 (node, p1, p2, cs, deltabase, delta, flags, _sidedata) = res
572
573 sidedata_raw = getchunk(self._stream)
574 sidedata = {}
575 if len(sidedata_raw) > 0:
576 sidedata = sidedatamod.deserialize_sidedata(sidedata_raw)
577
578 return node, p1, p2, cs, deltabase, delta, flags, sidedata
579
580
555 581 class headerlessfixup(object):
556 582 def __init__(self, fh, h):
557 583 self._h = h
@@ -861,6 +887,7 b' class cgpacker(object):'
861 887 shallow=False,
862 888 ellipsisroots=None,
863 889 fullnodes=None,
890 remote_sidedata=None,
864 891 ):
865 892 """Given a source repo, construct a bundler.
866 893
@@ -893,6 +920,8 b' class cgpacker(object):'
893 920 nodes. We store this rather than the set of nodes that should be
894 921 ellipsis because for very large histories we expect this to be
895 922 significantly smaller.
923
924 remote_sidedata is the set of sidedata categories wanted by the remote.
896 925 """
897 926 assert oldmatcher
898 927 assert matcher
@@ -988,7 +1017,7 b' class cgpacker(object):'
988 1017
989 1018 for tree, deltas in it:
990 1019 if tree:
991 assert self.version == b'03'
1020 assert self.version in (b'03', b'04')
992 1021 chunk = _fileheader(tree)
993 1022 size += len(chunk)
994 1023 yield chunk
@@ -1394,6 +1423,7 b' def _makecg1packer('
1394 1423 shallow=False,
1395 1424 ellipsisroots=None,
1396 1425 fullnodes=None,
1426 remote_sidedata=None,
1397 1427 ):
1398 1428 builddeltaheader = lambda d: _CHANGEGROUPV1_DELTA_HEADER.pack(
1399 1429 d.node, d.p1node, d.p2node, d.linknode
@@ -1424,6 +1454,7 b' def _makecg2packer('
1424 1454 shallow=False,
1425 1455 ellipsisroots=None,
1426 1456 fullnodes=None,
1457 remote_sidedata=None,
1427 1458 ):
1428 1459 builddeltaheader = lambda d: _CHANGEGROUPV2_DELTA_HEADER.pack(
1429 1460 d.node, d.p1node, d.p2node, d.basenode, d.linknode
@@ -1453,6 +1484,7 b' def _makecg3packer('
1453 1484 shallow=False,
1454 1485 ellipsisroots=None,
1455 1486 fullnodes=None,
1487 remote_sidedata=None,
1456 1488 ):
1457 1489 builddeltaheader = lambda d: _CHANGEGROUPV3_DELTA_HEADER.pack(
1458 1490 d.node, d.p1node, d.p2node, d.basenode, d.linknode, d.flags
@@ -1473,12 +1505,47 b' def _makecg3packer('
1473 1505 )
1474 1506
1475 1507
1508 def _makecg4packer(
1509 repo,
1510 oldmatcher,
1511 matcher,
1512 bundlecaps,
1513 ellipses=False,
1514 shallow=False,
1515 ellipsisroots=None,
1516 fullnodes=None,
1517 remote_sidedata=None,
1518 ):
1519 # Same header func as cg3. Sidedata is in a separate chunk from the delta to
1520 # differenciate "raw delta" and sidedata.
1521 builddeltaheader = lambda d: _CHANGEGROUPV3_DELTA_HEADER.pack(
1522 d.node, d.p1node, d.p2node, d.basenode, d.linknode, d.flags
1523 )
1524
1525 return cgpacker(
1526 repo,
1527 oldmatcher,
1528 matcher,
1529 b'04',
1530 builddeltaheader=builddeltaheader,
1531 manifestsend=closechunk(),
1532 bundlecaps=bundlecaps,
1533 ellipses=ellipses,
1534 shallow=shallow,
1535 ellipsisroots=ellipsisroots,
1536 fullnodes=fullnodes,
1537 remote_sidedata=remote_sidedata,
1538 )
1539
1540
1476 1541 _packermap = {
1477 1542 b'01': (_makecg1packer, cg1unpacker),
1478 1543 # cg2 adds support for exchanging generaldelta
1479 1544 b'02': (_makecg2packer, cg2unpacker),
1480 1545 # cg3 adds support for exchanging revlog flags and treemanifests
1481 1546 b'03': (_makecg3packer, cg3unpacker),
1547 # ch4 adds support for exchanging sidedata
1548 b'04': (_makecg4packer, cg4unpacker),
1482 1549 }
1483 1550
1484 1551
@@ -1498,11 +1565,9 b' def allsupportedversions(repo):'
1498 1565 #
1499 1566 # (or even to push subset of history)
1500 1567 needv03 = True
1501 if b'exp-sidedata-flag' in repo.requirements:
1502 needv03 = True
1503 # don't attempt to use 01/02 until we do sidedata cleaning
1504 versions.discard(b'01')
1505 versions.discard(b'02')
1568 has_revlogv2 = requirements.REVLOGV2_REQUIREMENT in repo.requirements
1569 if not has_revlogv2:
1570 versions.discard(b'04')
1506 1571 if not needv03:
1507 1572 versions.discard(b'03')
1508 1573 return versions
@@ -1565,6 +1630,7 b' def getbundler('
1565 1630 shallow=False,
1566 1631 ellipsisroots=None,
1567 1632 fullnodes=None,
1633 remote_sidedata=None,
1568 1634 ):
1569 1635 assert version in supportedoutgoingversions(repo)
1570 1636
@@ -1601,6 +1667,7 b' def getbundler('
1601 1667 shallow=shallow,
1602 1668 ellipsisroots=ellipsisroots,
1603 1669 fullnodes=fullnodes,
1670 remote_sidedata=remote_sidedata,
1604 1671 )
1605 1672
1606 1673
@@ -1644,8 +1711,15 b' def makestream('
1644 1711 fastpath=False,
1645 1712 bundlecaps=None,
1646 1713 matcher=None,
1714 remote_sidedata=None,
1647 1715 ):
1648 bundler = getbundler(version, repo, bundlecaps=bundlecaps, matcher=matcher)
1716 bundler = getbundler(
1717 version,
1718 repo,
1719 bundlecaps=bundlecaps,
1720 matcher=matcher,
1721 remote_sidedata=remote_sidedata,
1722 )
1649 1723
1650 1724 repo = repo.unfiltered()
1651 1725 commonrevs = outgoing.common
@@ -346,7 +346,7 b' def _debugchangegroup(ui, gen, all=None,'
346 346 def showchunks(named):
347 347 ui.write(b"\n%s%s\n" % (indent_string, named))
348 348 for deltadata in gen.deltaiter():
349 node, p1, p2, cs, deltabase, delta, flags = deltadata
349 node, p1, p2, cs, deltabase, delta, flags, sidedata = deltadata
350 350 ui.write(
351 351 b"%s%s %s %s %s %s %d\n"
352 352 % (
@@ -372,7 +372,7 b' def _debugchangegroup(ui, gen, all=None,'
372 372 raise error.Abort(_(b'use debugbundle2 for this file'))
373 373 gen.changelogheader()
374 374 for deltadata in gen.deltaiter():
375 node, p1, p2, cs, deltabase, delta, flags = deltadata
375 node, p1, p2, cs, deltabase, delta, flags, sidedata = deltadata
376 376 ui.write(b"%s%s\n" % (indent_string, hex(node)))
377 377
378 378
@@ -2249,7 +2249,13 b' def bundle2requested(bundlecaps):'
2249 2249
2250 2250
2251 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 2260 """Return chunks constituting a bundle's raw data.
2255 2261
@@ -2279,7 +2285,12 b' def getbundlechunks('
2279 2285 return (
2280 2286 info,
2281 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
@@ -2303,6 +2314,7 b' def getbundlechunks('
2303 2314 source,
2304 2315 bundlecaps=bundlecaps,
2305 2316 b2caps=b2caps,
2317 remote_sidedata=remote_sidedata,
2306 2318 **pycompat.strkwargs(kwargs)
2307 2319 )
2308 2320
@@ -2325,6 +2337,7 b' def _getbundlechangegrouppart('
2325 2337 b2caps=None,
2326 2338 heads=None,
2327 2339 common=None,
2340 remote_sidedata=None,
2328 2341 **kwargs
2329 2342 ):
2330 2343 """add a changegroup part to the requested bundle"""
@@ -2355,7 +2368,13 b' def _getbundlechangegrouppart('
2355 2368 matcher = None
2356 2369
2357 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 2380 part = bundler.newpart(b'changegroup', data=cgstream)
@@ -417,6 +417,8 b' def _processchangesetdata(repo, tr, objs'
417 417 mdiff.trivialdiffheader(len(data)) + data,
418 418 # Flags not yet supported.
419 419 0,
420 # Sidedata not yet supported
421 {},
420 422 )
421 423
422 424 cl.addgroup(
@@ -496,6 +498,8 b' def _fetchmanifests(repo, tr, remote, ma'
496 498 delta,
497 499 # Flags not yet supported.
498 500 0,
501 # Sidedata not yet supported.
502 {},
499 503 )
500 504
501 505 progress.increment()
@@ -621,6 +625,8 b' def _fetchfiles(repo, tr, remote, fnodes'
621 625 delta,
622 626 # Flags not yet supported.
623 627 0,
628 # Sidedata not yet supported.
629 {},
624 630 )
625 631
626 632 progress.increment()
@@ -719,6 +725,8 b' def _fetchfilesfromcsets('
719 725 delta,
720 726 # Flags not yet supported.
721 727 0,
728 # Sidedata not yet supported.
729 {},
722 730 )
723 731
724 732 progress.increment()
@@ -316,7 +316,13 b' class localpeer(repository.peer):'
316 316 )
317 317
318 318 def getbundle(
319 self, source, heads=None, common=None, bundlecaps=None, **kwargs
319 self,
320 source,
321 heads=None,
322 common=None,
323 bundlecaps=None,
324 remote_sidedata=None,
325 **kwargs
320 326 ):
321 327 chunks = exchange.getbundlechunks(
322 328 self._repo,
@@ -324,6 +330,7 b' class localpeer(repository.peer):'
324 330 heads=heads,
325 331 common=common,
326 332 bundlecaps=bundlecaps,
333 remote_sidedata=remote_sidedata,
327 334 **kwargs
328 335 )[1]
329 336 cb = util.chunkbuffer(chunks)
@@ -2527,7 +2527,7 b' class revlog(object):'
2527 2527 deltacomputer = deltautil.deltacomputer(self)
2528 2528 # loop through our set of deltas
2529 2529 for data in deltas:
2530 node, p1, p2, linknode, deltabase, delta, flags = data
2530 node, p1, p2, linknode, deltabase, delta, flags, sidedata = data
2531 2531 link = linkmapper(linknode)
2532 2532 flags = flags or REVIDX_DEFAULT_FLAGS
2533 2533
@@ -276,6 +276,7 b' def main():'
276 276 flags=b'',
277 277 baserevisionsize=None,
278 278 revision=b'',
279 sidedata=b'',
279 280 delta=None,
280 281 )
281 282 checkzobject(rd)
@@ -147,6 +147,7 b" def addgroupcopy(rlog, tr, destname=b'_d"
147 147 b'flags': rlog.flags(r),
148 148 b'deltabase': rlog.node(deltaparent),
149 149 b'delta': rlog.revdiff(deltaparent, r),
150 b'sidedata': rlog.sidedata(r),
150 151 }
151 152
152 153 def deltaiter(self):
@@ -159,10 +160,11 b" def addgroupcopy(rlog, tr, destname=b'_d"
159 160 deltabase = chunkdata[b'deltabase']
160 161 delta = chunkdata[b'delta']
161 162 flags = chunkdata[b'flags']
163 sidedata = chunkdata[b'sidedata']
162 164
163 165 chain = node
164 166
165 yield (node, p1, p2, cs, deltabase, delta, flags)
167 yield (node, p1, p2, cs, deltabase, delta, flags, sidedata)
166 168
167 169 def linkmap(lnode):
168 170 return rlog.rev(lnode)
General Comments 0
You need to be logged in to leave comments. Login now