comparison mercurial/utils/storageutil.py @ 47077:119790e1c67c

cg4: introduce protocol flag to signify the presence of sidedata We need a way of signaling whether the current revision has sidedata or not, and re-using the revision flags would waste potential revlog flags and mix two normally independent layers. In this change, we add a single byte at the start of the ch4 delta header to set potential protocol flags. We also reclaim the revlog flag for sidedata, since it is no longer used, in its place now lives the (also experimental) copytracing flag. When generating deltas, apply the `CG_FLAG_SIDEDATA` flag if there is sidedata. When applying the deltas, if said flag is present, the next chunk contains the sidedata. Differential Revision: https://phab.mercurial-scm.org/D10343
author Rapha?l Gom?s <rgomes@octobus.net>
date Sat, 10 Apr 2021 11:27:40 +0200
parents d55b71393907
children 223b47235d1c
comparison
equal deleted inserted replaced
47076:08e26ef4ad35 47077:119790e1c67c
25 from ..interfaces import repository 25 from ..interfaces import repository
26 from ..revlogutils import sidedata as sidedatamod 26 from ..revlogutils import sidedata as sidedatamod
27 from ..utils import hashutil 27 from ..utils import hashutil
28 28
29 _nullhash = hashutil.sha1(sha1nodeconstants.nullid) 29 _nullhash = hashutil.sha1(sha1nodeconstants.nullid)
30
31 # revision data contains extra metadata not part of the official digest
32 # Only used in changegroup >= v4.
33 CG_FLAG_SIDEDATA = 1
30 34
31 35
32 def hashrevisionsha1(text, p1, p2): 36 def hashrevisionsha1(text, p1, p2):
33 """Compute the SHA-1 for revision data and its parents. 37 """Compute the SHA-1 for revision data and its parents.
34 38
484 store.rawdata(baserev), store.rawdata(rev) 488 store.rawdata(baserev), store.rawdata(rev)
485 ) 489 )
486 490
487 available.add(rev) 491 available.add(rev)
488 492
489 sidedata = None 493 serialized_sidedata = None
490 if sidedata_helpers: 494 if sidedata_helpers:
491 sidedata = store.sidedata(rev) 495 sidedata = store.sidedata(rev)
492 sidedata = run_sidedata_helpers( 496 sidedata = run_sidedata_helpers(
493 store=store, 497 store=store,
494 sidedata_helpers=sidedata_helpers, 498 sidedata_helpers=sidedata_helpers,
495 sidedata=sidedata, 499 sidedata=sidedata,
496 rev=rev, 500 rev=rev,
497 ) 501 )
498 sidedata = sidedatamod.serialize_sidedata(sidedata) 502 if sidedata:
503 serialized_sidedata = sidedatamod.serialize_sidedata(sidedata)
504
505 flags = flagsfn(rev) if flagsfn else 0
506 protocol_flags = 0
507 if serialized_sidedata:
508 # Advertise that sidedata exists to the other side
509 protocol_flags |= CG_FLAG_SIDEDATA
499 510
500 yield resultcls( 511 yield resultcls(
501 node=node, 512 node=node,
502 p1node=fnode(p1rev), 513 p1node=fnode(p1rev),
503 p2node=fnode(p2rev), 514 p2node=fnode(p2rev),
504 basenode=fnode(baserev), 515 basenode=fnode(baserev),
505 flags=flagsfn(rev) if flagsfn else 0, 516 flags=flags,
506 baserevisionsize=baserevisionsize, 517 baserevisionsize=baserevisionsize,
507 revision=revision, 518 revision=revision,
508 delta=delta, 519 delta=delta,
509 sidedata=sidedata, 520 sidedata=serialized_sidedata,
521 protocol_flags=protocol_flags,
510 ) 522 )
511 523
512 prevrev = rev 524 prevrev = rev
513 525
514 526