##// 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 assumehaveparentrevisions=False,
306 assumehaveparentrevisions=False,
307 deltaprevious=False,
307 deltaprevious=False,
308 deltamode=None,
308 deltamode=None,
309 sidedata_helpers=None,
309 ):
310 ):
310 # we don't use any of these parameters here
311 # we don't use any of these parameters here
311 del nodesorder, revisiondata, assumehaveparentrevisions, deltaprevious
312 del nodesorder, revisiondata, assumehaveparentrevisions, deltaprevious
@@ -333,6 +334,8 b' class remotefilelog(object):'
333 baserevisionsize=None,
334 baserevisionsize=None,
334 revision=revision,
335 revision=revision,
335 delta=delta,
336 delta=delta,
337 # Sidedata is not supported yet
338 sidedata=None,
336 )
339 )
337
340
338 def revdiff(self, node1, node2):
341 def revdiff(self, node1, node2):
@@ -67,7 +67,7 b' class shallowcg1packer(changegroup.cgpac'
67 shallowcg1packer, self, nodelist, rlog, lookup, units=units
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 try:
71 try:
72 linknodes, commonrevs, source = args
72 linknodes, commonrevs, source = args
73 except ValueError:
73 except ValueError:
@@ -92,7 +92,9 b' class shallowcg1packer(changegroup.cgpac'
92 [f for f in changedfiles if not repo.shallowmatch(f)]
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 def shouldaddfilegroups(self, source):
99 def shouldaddfilegroups(self, source):
98 repo = self._repo
100 repo = self._repo
@@ -176,9 +178,11 b' def makechangegroup(orig, repo, outgoing'
176 repo.shallowmatch = original
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 if not shallowutil.isenabled(repo):
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 newfiles = 0
187 newfiles = 0
184 visited = set()
188 visited = set()
@@ -272,7 +276,7 b' def addchangegroupfiles(orig, repo, sour'
272
276
273 revisiondata = revisiondatas[(f, node)]
277 revisiondata = revisiondatas[(f, node)]
274 # revisiondata: (node, p1, p2, cs, deltabase, delta, flags)
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 if not available(f, node, f, deltabase):
281 if not available(f, node, f, deltabase):
278 continue
282 continue
@@ -681,7 +681,16 b' class sqlitefilestore(object):'
681 ):
681 ):
682 empty = True
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 storeflags = 0
694 storeflags = 0
686
695
687 if wireflags & repository.REVISION_FLAG_CENSORED:
696 if wireflags & repository.REVISION_FLAG_CENSORED:
@@ -61,7 +61,7 b' class bundlerevlog(revlog.revlog):'
61 self.repotiprev = n - 1
61 self.repotiprev = n - 1
62 self.bundlerevs = set() # used by 'bundle()' revset expression
62 self.bundlerevs = set() # used by 'bundle()' revset expression
63 for deltadata in cgunpacker.deltaiter():
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 size = len(delta)
66 size = len(delta)
67 start = cgunpacker.tell() - size
67 start = cgunpacker.tell() - size
@@ -32,6 +32,7 b' from . import ('
32 )
32 )
33
33
34 from .interfaces import repository
34 from .interfaces import repository
35 from .revlogutils import sidedata as sidedatamod
35
36
36 _CHANGEGROUPV1_DELTA_HEADER = struct.Struct(b"20s20s20s20s")
37 _CHANGEGROUPV1_DELTA_HEADER = struct.Struct(b"20s20s20s20s")
37 _CHANGEGROUPV2_DELTA_HEADER = struct.Struct(b"20s20s20s20s20s")
38 _CHANGEGROUPV2_DELTA_HEADER = struct.Struct(b"20s20s20s20s20s")
@@ -202,7 +203,9 b' class cg1unpacker(object):'
202 header = self.deltaheader.unpack(headerdata)
203 header = self.deltaheader.unpack(headerdata)
203 delta = readexactly(self._stream, l - self.deltaheadersize)
204 delta = readexactly(self._stream, l - self.deltaheadersize)
204 node, p1, p2, deltabase, cs, flags = self._deltaheader(header, prevnode)
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 def getchunks(self):
210 def getchunks(self):
208 """returns all the chunks contains in the bundle
211 """returns all the chunks contains in the bundle
@@ -552,6 +555,29 b' class cg3unpacker(cg2unpacker):'
552 raise error.Abort(_(b"received dir revlog group is empty"))
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 class headerlessfixup(object):
581 class headerlessfixup(object):
556 def __init__(self, fh, h):
582 def __init__(self, fh, h):
557 self._h = h
583 self._h = h
@@ -861,6 +887,7 b' class cgpacker(object):'
861 shallow=False,
887 shallow=False,
862 ellipsisroots=None,
888 ellipsisroots=None,
863 fullnodes=None,
889 fullnodes=None,
890 remote_sidedata=None,
864 ):
891 ):
865 """Given a source repo, construct a bundler.
892 """Given a source repo, construct a bundler.
866
893
@@ -893,6 +920,8 b' class cgpacker(object):'
893 nodes. We store this rather than the set of nodes that should be
920 nodes. We store this rather than the set of nodes that should be
894 ellipsis because for very large histories we expect this to be
921 ellipsis because for very large histories we expect this to be
895 significantly smaller.
922 significantly smaller.
923
924 remote_sidedata is the set of sidedata categories wanted by the remote.
896 """
925 """
897 assert oldmatcher
926 assert oldmatcher
898 assert matcher
927 assert matcher
@@ -988,7 +1017,7 b' class cgpacker(object):'
988
1017
989 for tree, deltas in it:
1018 for tree, deltas in it:
990 if tree:
1019 if tree:
991 assert self.version == b'03'
1020 assert self.version in (b'03', b'04')
992 chunk = _fileheader(tree)
1021 chunk = _fileheader(tree)
993 size += len(chunk)
1022 size += len(chunk)
994 yield chunk
1023 yield chunk
@@ -1394,6 +1423,7 b' def _makecg1packer('
1394 shallow=False,
1423 shallow=False,
1395 ellipsisroots=None,
1424 ellipsisroots=None,
1396 fullnodes=None,
1425 fullnodes=None,
1426 remote_sidedata=None,
1397 ):
1427 ):
1398 builddeltaheader = lambda d: _CHANGEGROUPV1_DELTA_HEADER.pack(
1428 builddeltaheader = lambda d: _CHANGEGROUPV1_DELTA_HEADER.pack(
1399 d.node, d.p1node, d.p2node, d.linknode
1429 d.node, d.p1node, d.p2node, d.linknode
@@ -1424,6 +1454,7 b' def _makecg2packer('
1424 shallow=False,
1454 shallow=False,
1425 ellipsisroots=None,
1455 ellipsisroots=None,
1426 fullnodes=None,
1456 fullnodes=None,
1457 remote_sidedata=None,
1427 ):
1458 ):
1428 builddeltaheader = lambda d: _CHANGEGROUPV2_DELTA_HEADER.pack(
1459 builddeltaheader = lambda d: _CHANGEGROUPV2_DELTA_HEADER.pack(
1429 d.node, d.p1node, d.p2node, d.basenode, d.linknode
1460 d.node, d.p1node, d.p2node, d.basenode, d.linknode
@@ -1453,6 +1484,7 b' def _makecg3packer('
1453 shallow=False,
1484 shallow=False,
1454 ellipsisroots=None,
1485 ellipsisroots=None,
1455 fullnodes=None,
1486 fullnodes=None,
1487 remote_sidedata=None,
1456 ):
1488 ):
1457 builddeltaheader = lambda d: _CHANGEGROUPV3_DELTA_HEADER.pack(
1489 builddeltaheader = lambda d: _CHANGEGROUPV3_DELTA_HEADER.pack(
1458 d.node, d.p1node, d.p2node, d.basenode, d.linknode, d.flags
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 _packermap = {
1541 _packermap = {
1477 b'01': (_makecg1packer, cg1unpacker),
1542 b'01': (_makecg1packer, cg1unpacker),
1478 # cg2 adds support for exchanging generaldelta
1543 # cg2 adds support for exchanging generaldelta
1479 b'02': (_makecg2packer, cg2unpacker),
1544 b'02': (_makecg2packer, cg2unpacker),
1480 # cg3 adds support for exchanging revlog flags and treemanifests
1545 # cg3 adds support for exchanging revlog flags and treemanifests
1481 b'03': (_makecg3packer, cg3unpacker),
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 # (or even to push subset of history)
1566 # (or even to push subset of history)
1500 needv03 = True
1567 needv03 = True
1501 if b'exp-sidedata-flag' in repo.requirements:
1568 has_revlogv2 = requirements.REVLOGV2_REQUIREMENT in repo.requirements
1502 needv03 = True
1569 if not has_revlogv2:
1503 # don't attempt to use 01/02 until we do sidedata cleaning
1570 versions.discard(b'04')
1504 versions.discard(b'01')
1505 versions.discard(b'02')
1506 if not needv03:
1571 if not needv03:
1507 versions.discard(b'03')
1572 versions.discard(b'03')
1508 return versions
1573 return versions
@@ -1565,6 +1630,7 b' def getbundler('
1565 shallow=False,
1630 shallow=False,
1566 ellipsisroots=None,
1631 ellipsisroots=None,
1567 fullnodes=None,
1632 fullnodes=None,
1633 remote_sidedata=None,
1568 ):
1634 ):
1569 assert version in supportedoutgoingversions(repo)
1635 assert version in supportedoutgoingversions(repo)
1570
1636
@@ -1601,6 +1667,7 b' def getbundler('
1601 shallow=shallow,
1667 shallow=shallow,
1602 ellipsisroots=ellipsisroots,
1668 ellipsisroots=ellipsisroots,
1603 fullnodes=fullnodes,
1669 fullnodes=fullnodes,
1670 remote_sidedata=remote_sidedata,
1604 )
1671 )
1605
1672
1606
1673
@@ -1644,8 +1711,15 b' def makestream('
1644 fastpath=False,
1711 fastpath=False,
1645 bundlecaps=None,
1712 bundlecaps=None,
1646 matcher=None,
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 repo = repo.unfiltered()
1724 repo = repo.unfiltered()
1651 commonrevs = outgoing.common
1725 commonrevs = outgoing.common
@@ -346,7 +346,7 b' def _debugchangegroup(ui, gen, all=None,'
346 def showchunks(named):
346 def showchunks(named):
347 ui.write(b"\n%s%s\n" % (indent_string, named))
347 ui.write(b"\n%s%s\n" % (indent_string, named))
348 for deltadata in gen.deltaiter():
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 ui.write(
350 ui.write(
351 b"%s%s %s %s %s %s %d\n"
351 b"%s%s %s %s %s %s %d\n"
352 % (
352 % (
@@ -372,7 +372,7 b' def _debugchangegroup(ui, gen, all=None,'
372 raise error.Abort(_(b'use debugbundle2 for this file'))
372 raise error.Abort(_(b'use debugbundle2 for this file'))
373 gen.changelogheader()
373 gen.changelogheader()
374 for deltadata in gen.deltaiter():
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 ui.write(b"%s%s\n" % (indent_string, hex(node)))
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 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
@@ -2279,7 +2285,12 b' def getbundlechunks('
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
@@ -2303,6 +2314,7 b' def getbundlechunks('
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
@@ -2325,6 +2337,7 b' def _getbundlechangegrouppart('
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"""
@@ -2355,7 +2368,13 b' def _getbundlechangegrouppart('
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)
@@ -417,6 +417,8 b' def _processchangesetdata(repo, tr, objs'
417 mdiff.trivialdiffheader(len(data)) + data,
417 mdiff.trivialdiffheader(len(data)) + data,
418 # Flags not yet supported.
418 # Flags not yet supported.
419 0,
419 0,
420 # Sidedata not yet supported
421 {},
420 )
422 )
421
423
422 cl.addgroup(
424 cl.addgroup(
@@ -496,6 +498,8 b' def _fetchmanifests(repo, tr, remote, ma'
496 delta,
498 delta,
497 # Flags not yet supported.
499 # Flags not yet supported.
498 0,
500 0,
501 # Sidedata not yet supported.
502 {},
499 )
503 )
500
504
501 progress.increment()
505 progress.increment()
@@ -621,6 +625,8 b' def _fetchfiles(repo, tr, remote, fnodes'
621 delta,
625 delta,
622 # Flags not yet supported.
626 # Flags not yet supported.
623 0,
627 0,
628 # Sidedata not yet supported.
629 {},
624 )
630 )
625
631
626 progress.increment()
632 progress.increment()
@@ -719,6 +725,8 b' def _fetchfilesfromcsets('
719 delta,
725 delta,
720 # Flags not yet supported.
726 # Flags not yet supported.
721 0,
727 0,
728 # Sidedata not yet supported.
729 {},
722 )
730 )
723
731
724 progress.increment()
732 progress.increment()
@@ -316,7 +316,13 b' class localpeer(repository.peer):'
316 )
316 )
317
317
318 def getbundle(
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 chunks = exchange.getbundlechunks(
327 chunks = exchange.getbundlechunks(
322 self._repo,
328 self._repo,
@@ -324,6 +330,7 b' class localpeer(repository.peer):'
324 heads=heads,
330 heads=heads,
325 common=common,
331 common=common,
326 bundlecaps=bundlecaps,
332 bundlecaps=bundlecaps,
333 remote_sidedata=remote_sidedata,
327 **kwargs
334 **kwargs
328 )[1]
335 )[1]
329 cb = util.chunkbuffer(chunks)
336 cb = util.chunkbuffer(chunks)
@@ -2527,7 +2527,7 b' class revlog(object):'
2527 deltacomputer = deltautil.deltacomputer(self)
2527 deltacomputer = deltautil.deltacomputer(self)
2528 # loop through our set of deltas
2528 # loop through our set of deltas
2529 for data in deltas:
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 link = linkmapper(linknode)
2531 link = linkmapper(linknode)
2532 flags = flags or REVIDX_DEFAULT_FLAGS
2532 flags = flags or REVIDX_DEFAULT_FLAGS
2533
2533
@@ -276,6 +276,7 b' def main():'
276 flags=b'',
276 flags=b'',
277 baserevisionsize=None,
277 baserevisionsize=None,
278 revision=b'',
278 revision=b'',
279 sidedata=b'',
279 delta=None,
280 delta=None,
280 )
281 )
281 checkzobject(rd)
282 checkzobject(rd)
@@ -147,6 +147,7 b" def addgroupcopy(rlog, tr, destname=b'_d"
147 b'flags': rlog.flags(r),
147 b'flags': rlog.flags(r),
148 b'deltabase': rlog.node(deltaparent),
148 b'deltabase': rlog.node(deltaparent),
149 b'delta': rlog.revdiff(deltaparent, r),
149 b'delta': rlog.revdiff(deltaparent, r),
150 b'sidedata': rlog.sidedata(r),
150 }
151 }
151
152
152 def deltaiter(self):
153 def deltaiter(self):
@@ -159,10 +160,11 b" def addgroupcopy(rlog, tr, destname=b'_d"
159 deltabase = chunkdata[b'deltabase']
160 deltabase = chunkdata[b'deltabase']
160 delta = chunkdata[b'delta']
161 delta = chunkdata[b'delta']
161 flags = chunkdata[b'flags']
162 flags = chunkdata[b'flags']
163 sidedata = chunkdata[b'sidedata']
162
164
163 chain = node
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 def linkmap(lnode):
169 def linkmap(lnode):
168 return rlog.rev(lnode)
170 return rlog.rev(lnode)
General Comments 0
You need to be logged in to leave comments. Login now