Mercurial > public > mercurial-scm > hg
diff mercurial/changegroup.py @ 39230:b518d495a560
repository: formalize interfaces for revision deltas and requests
Now that we've sufficiently abstracted how revision deltas are
produced in changegroup code, we can now start the process of
formalizing that as part of the interfaces defined in the
repository module.
This commit essentially converts the revisiondelta and
revisiondeltarequest classes into well-defined interfaces. This
is not strictly necessary. But I want all types formalized by the
storage interface to have interfaces. This makes it much easier
to test for interface conformance and for implementing new
storage backends.
Because the interface is documented, comments and docstrings from
changegroup.py have been dropped.
Differential Revision: https://phab.mercurial-scm.org/D4225
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Thu, 09 Aug 2018 15:40:14 -0700 |
parents | 2646b8d66b7b |
children | b41d023a412a |
line wrap: on
line diff
--- a/mercurial/changegroup.py Thu Aug 09 14:31:25 2018 -0700 +++ b/mercurial/changegroup.py Thu Aug 09 15:40:14 2018 -0700 @@ -36,6 +36,7 @@ ) from .utils import ( + interfaceutil, stringutil, ) @@ -501,58 +502,27 @@ return d return readexactly(self._fh, n) +@interfaceutil.implementer(repository.irevisiondeltarequest) @attr.s(slots=True, frozen=True) class revisiondeltarequest(object): - """Describes a request to construct a revision delta. - - Instances are converted into ``revisiondelta`` later. - """ - # Revision whose delta will be generated. node = attr.ib() - - # Linknode value. linknode = attr.ib() - - # Parent revisions to record in ``revisiondelta`` instance. p1node = attr.ib() p2node = attr.ib() - - # Base revision that delta should be generated against. If nullid, - # the full revision data should be populated. If None, the delta - # may be generated against any base revision that is an ancestor of - # this revision. If any other value, the delta should be produced - # against that revision. basenode = attr.ib() - - # Whether this should be marked as an ellipsis revision. ellipsis = attr.ib(default=False) +@interfaceutil.implementer(repository.irevisiondelta) @attr.s(slots=True, frozen=True) class revisiondelta(object): - """Describes a delta entry in a changegroup. - - Captured data is sufficient to serialize the delta into multiple - formats. - - ``revision`` and ``delta`` are mutually exclusive. - """ - # 20 byte node of this revision. node = attr.ib() - # 20 byte nodes of parent revisions. p1node = attr.ib() p2node = attr.ib() - # 20 byte node of node this delta is against. basenode = attr.ib() - # 20 byte node of changeset revision this delta is associated with. linknode = attr.ib() - # 2 bytes of flags to apply to revision data. flags = attr.ib() - # Size of base revision this delta is against. May be None if - # basenode is nullid. baserevisionsize = attr.ib() - # Raw fulltext revision data. revision = attr.ib() - # Delta between the basenode and node. delta = attr.ib() def _revisiondeltatochunks(delta, headerfn):