D8693: sidedata: test changes for incoming and local changes [POC]
joerg.sonnenberger (Joerg Sonnenberger)
phabricator at mercurial-scm.org
Tue Jul 7 13:55:18 UTC 2020
joerg.sonnenberger created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
Fixes wireproto v2 to not send the raw data with flags=0
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D8693
AFFECTED FILES
mercurial/bundle2.py
mercurial/changelog.py
mercurial/configitems.py
mercurial/exchange.py
mercurial/wireprotov2server.py
CHANGE DETAILS
diff --git a/mercurial/wireprotov2server.py b/mercurial/wireprotov2server.py
--- a/mercurial/wireprotov2server.py
+++ b/mercurial/wireprotov2server.py
@@ -1046,7 +1046,7 @@
followingdata = []
if b'revision' in fields:
- revisiondata = cl.rawdata(node)
+ revisiondata = cl._revisiondata(node)[0]
followingmeta.append((b'revision', len(revisiondata)))
followingdata.append(revisiondata)
diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -1070,8 +1070,6 @@
cgpart.addparam(b'version', version)
if b'treemanifest' in pushop.repo.requirements:
cgpart.addparam(b'treemanifest', b'1')
- if b'exp-sidedata-flag' in pushop.repo.requirements:
- cgpart.addparam(b'exp-sidedata', b'1')
def handlereply(op):
"""extract addchangegroup returns from server reply"""
@@ -2560,9 +2558,6 @@
if b'treemanifest' in repo.requirements:
part.addparam(b'treemanifest', b'1')
- if b'exp-sidedata-flag' in repo.requirements:
- part.addparam(b'exp-sidedata', b'1')
-
if (
kwargs.get('narrow', False)
and kwargs.get('narrow_acl', False)
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -778,7 +778,7 @@
experimental=True,
)
coreconfigitem(
- b'format', b'exp-use-side-data', default=False, experimental=True,
+ b'format', b'exp-use-side-data', default=True, experimental=True,
)
coreconfigitem(
b'format', b'internal-phase', default=False, experimental=True,
diff --git a/mercurial/changelog.py b/mercurial/changelog.py
--- a/mercurial/changelog.py
+++ b/mercurial/changelog.py
@@ -362,6 +362,87 @@
class changelog(revlog.revlog):
+ def _addrevision(
+ self,
+ node,
+ rawtext,
+ transaction,
+ link,
+ p1,
+ p2,
+ flags,
+ cachedelta,
+ ifh,
+ dfh,
+ alwayscache=False,
+ deltacomputer=None,
+ ):
+ assert flags & revlog.REVIDX_SIDEDATA
+ return revlog.revlog._addrevision(
+ self,
+ node,
+ rawtext,
+ transaction,
+ link,
+ p1,
+ p2,
+ flags,
+ cachedelta,
+ ifh,
+ dfh,
+ alwayscache=alwayscache,
+ deltacomputer=deltacomputer,
+ )
+
+ def addgroup(self, deltas, linkmapper, transaction, addrevisioncb=None):
+ from .revlogutils import sidedata as _sidedata, flagutil
+ from . import mdiff
+
+ def deltascb():
+ for data in deltas:
+ node, p1, p2, linknode, deltabase, delta, flags = data
+ if deltabase == nullid:
+ delta = mdiff.patch(b'', delta)
+ else:
+ delta = mdiff.patch(self._revisiondata(deltabase)[0], delta)
+ if flags & revlog.REVIDX_SIDEDATA:
+ delta, validatehash, sidedata = flagutil.processflagsread(
+ self, delta, flags
+ )
+ if validatehash:
+ self.checkhash(delta, node, p1=p1, p2=p2)
+ else:
+ sidedata = {}
+ sidedata.update(
+ {
+ _sidedata.SD_TEST1: b'test-key',
+ _sidedata.SD_TEST2: b'test-node',
+ }
+ )
+ flags |= revlog.REVIDX_SIDEDATA
+ data, validatehash = flagutil.processflagswrite(
+ self, delta, flags, sidedata=sidedata
+ )
+ if validatehash:
+ self.checkhash(data, node, p1=p1, p2=p2)
+ yield (
+ node,
+ p1,
+ p2,
+ linknode,
+ nullid,
+ mdiff.trivialdiffheader(len(data)) + data,
+ flags,
+ )
+
+ return revlog.revlog.addgroup(
+ self,
+ deltascb(),
+ linkmapper,
+ transaction,
+ addrevisioncb=addrevisioncb,
+ )
+
def __init__(self, opener, trypending=False):
"""Load a changelog revlog using an opener.
@@ -601,6 +682,13 @@
sidedata[sidedatamod.SD_FILESREMOVED] = filesremoved
if not sidedata:
sidedata = None
+ if sidedata is None:
+ sidedata = {}
+ from .revlogutils import sidedata as _sidedata
+
+ sidedata.update(
+ {_sidedata.SD_TEST1: b'test-key', _sidedata.SD_TEST2: b'test-node',}
+ )
if extra:
extra = encodeextra(extra)
diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -1715,8 +1715,6 @@
part.addparam(
b'targetphase', b'%d' % phases.secret, mandatory=False
)
- if b'exp-sidedata-flag' in repo.requirements:
- part.addparam(b'exp-sidedata', b'1')
if opts.get(b'streamv2', False):
addpartbundlestream2(bundler, repo, stream=True)
@@ -1937,13 +1935,7 @@
@parthandler(
b'changegroup',
- (
- b'version',
- b'nbchanges',
- b'exp-sidedata',
- b'treemanifest',
- b'targetphase',
- ),
+ (b'version', b'nbchanges', b'treemanifest', b'targetphase',),
)
def handlechangegroup(op, inpart):
"""apply a changegroup part on the repo
@@ -1979,13 +1971,6 @@
)
op.repo._writerequirements()
- bundlesidedata = bool(b'exp-sidedata' in inpart.params)
- reposidedata = bool(b'exp-sidedata-flag' in op.repo.requirements)
- if reposidedata and not bundlesidedata:
- msg = b"repository is using sidedata but the bundle source do not"
- hint = b'this is currently unsupported'
- raise error.Abort(msg, hint=hint)
-
extrakwargs = {}
targetphase = inpart.params.get(b'targetphase')
if targetphase is not None:
@@ -2577,7 +2562,5 @@
part.addparam(b'version', cgversion)
if b'treemanifest' in repo.requirements:
part.addparam(b'treemanifest', b'1')
- if b'exp-sidedata-flag' in repo.requirements:
- part.addparam(b'exp-sidedata', b'1')
return bundler
To: joerg.sonnenberger, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
More information about the Mercurial-devel
mailing list