Mercurial > public > mercurial-scm > hg
comparison mercurial/exchangev2.py @ 39641:aa7e312375cf
wireprotov2: let clients drive delta behavior
Previously, the "manifestdata" and "filedata" commands assumed the
receiver had all parent revisions for requested nodes. Unless the
revision had no parents, they emitted a delta instead of a fulltext.
This strategy isn't appropriate for shallow clones and for clients
that only want to access fulltext revision data for a single node
without fetching their parent revisions.
This commit adds an "haveparents" argument to the "manifestdata"
and "filedata" commands that controls delta generation behavior.
Unless "haveparents" is set, the server assumes that the client
doesn't have parent revisions unless they were previously sent
as part of the current group of revisions.
This change allows the fulltext revision data of any individual
revision to be obtained. This will facilitate shallow clones
and other data retrieval strategies that don't require all previous
revisions of an entity to be fetched.
Differential Revision: https://phab.mercurial-scm.org/D4492
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Thu, 30 Aug 2018 14:55:34 -0700 |
parents | 039bf1eddc2e |
children | d059cb669632 |
comparison
equal
deleted
inserted
replaced
39640:039bf1eddc2e | 39641:aa7e312375cf |
---|---|
281 with remote.commandexecutor() as e: | 281 with remote.commandexecutor() as e: |
282 objs = e.callcommand(b'manifestdata', { | 282 objs = e.callcommand(b'manifestdata', { |
283 b'tree': b'', | 283 b'tree': b'', |
284 b'nodes': batch, | 284 b'nodes': batch, |
285 b'fields': {b'parents', b'revision'}, | 285 b'fields': {b'parents', b'revision'}, |
286 b'haveparents': True, | |
286 }).result() | 287 }).result() |
287 | 288 |
288 # Chomp off header object. | 289 # Chomp off header object. |
289 next(objs) | 290 next(objs) |
290 | 291 |
372 | 373 |
373 for path, nodes in batch: | 374 for path, nodes in batch: |
374 fs.append((path, e.callcommand(b'filedata', { | 375 fs.append((path, e.callcommand(b'filedata', { |
375 b'path': path, | 376 b'path': path, |
376 b'nodes': sorted(nodes), | 377 b'nodes': sorted(nodes), |
377 b'fields': {b'parents', b'revision'} | 378 b'fields': {b'parents', b'revision'}, |
379 b'haveparents': True, | |
378 }))) | 380 }))) |
379 | 381 |
380 locallinkrevs[path] = { | 382 locallinkrevs[path] = { |
381 node: linkrevs[manifestnode] | 383 node: linkrevs[manifestnode] |
382 for node, manifestnode in nodes.iteritems()} | 384 for node, manifestnode in nodes.iteritems()} |