Mercurial > public > mercurial-scm > hg-stable
diff mercurial/exchange.py @ 46726:bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Each repo will advertise the sidedata categories it requires (categories being
unique and canonical), and have a set of "computers", functions to generate
sidedata from `(repo, revlog, rev, previous_sidedata)`, for a given category.
The set of computers can be a superset of the set of the wanted categories, but
not smaller: repos are expected to be coherent in their handling of sidedata.
Differential Revision: https://phab.mercurial-scm.org/D10028
author | Rapha?l Gom?s <rgomes@octobus.net> |
---|---|
date | Fri, 19 Feb 2021 10:53:27 +0100 |
parents | a41565bef69f |
children | 6266d19556ad |
line wrap: on
line diff
--- a/mercurial/exchange.py Thu Feb 18 18:18:35 2021 +0100 +++ b/mercurial/exchange.py Fri Feb 19 10:53:27 2021 +0100 @@ -420,7 +420,20 @@ b'unbundle wire protocol command' ) ) - + for category in sorted(bundle2.read_remote_wanted_sidedata(pushop.remote)): + # Check that a computer is registered for that category for at least + # one revlog kind. + for kind, computers in repo._sidedata_computers.items(): + if computers.get(category): + break + else: + raise error.Abort( + _( + b'cannot push: required sidedata category not supported' + b" by this client: '%s'" + ) + % pycompat.bytestr(category) + ) # get lock as we might write phase data wlock = lock = None try: @@ -865,8 +878,15 @@ if not cgversions: raise error.Abort(_(b'no common changegroup version')) version = max(cgversions) + + remote_sidedata = bundle2.read_remote_wanted_sidedata(pushop.remote) cgstream = changegroup.makestream( - pushop.repo, pushop.outgoing, version, b'push' + pushop.repo, + pushop.outgoing, + version, + b'push', + bundlecaps=b2caps, + remote_sidedata=remote_sidedata, ) cgpart = bundler.newpart(b'changegroup', data=cgstream) if cgversions: @@ -1607,6 +1627,23 @@ ) % (b', '.join(sorted(missing))) raise error.Abort(msg) + for category in repo._wanted_sidedata: + # Check that a computer is registered for that category for at least + # one revlog kind. + for kind, computers in repo._sidedata_computers.items(): + if computers.get(category): + break + else: + # This should never happen since repos are supposed to be able to + # generate the sidedata they require. + raise error.ProgrammingError( + _( + b'sidedata category requested by local side without local' + b"support: '%s'" + ) + % pycompat.bytestr(category) + ) + pullop.trmanager = transactionmanager(repo, b'pull', remote.url()) wlock = util.nullcontextmanager() if not bookmod.bookmarksinstore(repo): @@ -1820,6 +1857,10 @@ pullop.stepsdone.add(b'obsmarkers') _pullbundle2extraprepare(pullop, kwargs) + remote_sidedata = bundle2.read_remote_wanted_sidedata(pullop.remote) + if remote_sidedata: + kwargs[b'remote_sidedata'] = remote_sidedata + with pullop.remote.commandexecutor() as e: args = dict(kwargs) args[b'source'] = b'pull' @@ -2388,6 +2429,8 @@ if b'exp-sidedata-flag' in repo.requirements: part.addparam(b'exp-sidedata', b'1') + sidedata = bundle2.format_remote_wanted_sidedata(repo) + part.addparam(b'exp-wanted-sidedata', sidedata) if ( kwargs.get('narrow', False)