Mercurial > hg
diff mercurial/utils/storageutil.py @ 40427:59a870a4ad6e
changegroup: refactor emitrevision to use a `deltamode` argument
This new argument gathers the semantic of `sendfulltext` and `deltaprevious`
in a single value. We are about to introduce a new type of constraints.
Avoiding yet another argument sounds like a plus.
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Tue, 09 Oct 2018 22:02:01 +0200 |
parents | b0fbd1792e2d |
children | 968dd7e02ac5 |
line wrap: on
line diff
--- a/mercurial/utils/storageutil.py Tue Oct 23 21:11:13 2018 +0900 +++ b/mercurial/utils/storageutil.py Tue Oct 09 22:02:01 2018 +0200 @@ -22,6 +22,7 @@ error, mdiff, pycompat, + repository, ) _nullhash = hashlib.sha1(nullid) @@ -269,9 +270,8 @@ def emitrevisions(store, nodes, nodesorder, resultcls, deltaparentfn=None, candeltafn=None, rawsizefn=None, revdifffn=None, flagsfn=None, - sendfulltext=False, - revisiondata=False, assumehaveparentrevisions=False, - deltaprevious=False): + deltamode=repository.CG_DELTAMODE_STD, + revisiondata=False, assumehaveparentrevisions=False): """Generic implementation of ifiledata.emitrevisions(). Emitting revision data is subtly complex. This function attempts to @@ -322,14 +322,17 @@ Callable receiving a revision number and returns the integer flags value for it. If not defined, flags value will be 0. - ``sendfulltext`` + ``deltamode`` + constaint on delta to be sent: + * CG_DELTAMODE_STD - normal mode, try to reuse storage deltas, + * CG_DELTAMODE_PREV - only delta against "prev", + * CG_DELTAMODE_FULL - only issue full snapshot. + Whether to send fulltext revisions instead of deltas, if allowed. ``nodesorder`` ``revisiondata`` ``assumehaveparentrevisions`` - ``deltaprevious`` - See ``ifiledata.emitrevisions()`` interface documentation. """ fnode = store.node @@ -345,7 +348,7 @@ prevrev = None - if deltaprevious or assumehaveparentrevisions: + if deltamode == repository.CG_DELTAMODE_PREV or assumehaveparentrevisions: prevrev = store.parentrevs(revs[0])[0] # Set of revs available to delta against. @@ -364,11 +367,11 @@ deltaparentrev = nullrev # Forced delta against previous mode. - if deltaprevious: + if deltamode == repository.CG_DELTAMODE_PREV: baserev = prevrev # We're instructed to send fulltext. Honor that. - elif sendfulltext: + elif deltamode == repository.CG_DELTAMODE_FULL: baserev = nullrev # There is a delta in storage. We try to use that because it @@ -427,7 +430,8 @@ baserevisionsize = len(store.revision(baserev, raw=True)) - elif baserev == nullrev and not deltaprevious: + elif (baserev == nullrev + and deltamode != repository.CG_DELTAMODE_PREV): revision = store.revision(node, raw=True) available.add(rev) else: