##// END OF EJS Templates
repository: formalize interfaces for revision deltas and requests...
Gregory Szorc -
r39266:b518d495 default
parent child Browse files
Show More
@@ -36,6 +36,7 b' from . import ('
36 )
36 )
37
37
38 from .utils import (
38 from .utils import (
39 interfaceutil,
39 stringutil,
40 stringutil,
40 )
41 )
41
42
@@ -501,58 +502,27 b' class headerlessfixup(object):'
501 return d
502 return d
502 return readexactly(self._fh, n)
503 return readexactly(self._fh, n)
503
504
505 @interfaceutil.implementer(repository.irevisiondeltarequest)
504 @attr.s(slots=True, frozen=True)
506 @attr.s(slots=True, frozen=True)
505 class revisiondeltarequest(object):
507 class revisiondeltarequest(object):
506 """Describes a request to construct a revision delta.
507
508 Instances are converted into ``revisiondelta`` later.
509 """
510 # Revision whose delta will be generated.
511 node = attr.ib()
508 node = attr.ib()
512
513 # Linknode value.
514 linknode = attr.ib()
509 linknode = attr.ib()
515
516 # Parent revisions to record in ``revisiondelta`` instance.
517 p1node = attr.ib()
510 p1node = attr.ib()
518 p2node = attr.ib()
511 p2node = attr.ib()
519
520 # Base revision that delta should be generated against. If nullid,
521 # the full revision data should be populated. If None, the delta
522 # may be generated against any base revision that is an ancestor of
523 # this revision. If any other value, the delta should be produced
524 # against that revision.
525 basenode = attr.ib()
512 basenode = attr.ib()
526
527 # Whether this should be marked as an ellipsis revision.
528 ellipsis = attr.ib(default=False)
513 ellipsis = attr.ib(default=False)
529
514
515 @interfaceutil.implementer(repository.irevisiondelta)
530 @attr.s(slots=True, frozen=True)
516 @attr.s(slots=True, frozen=True)
531 class revisiondelta(object):
517 class revisiondelta(object):
532 """Describes a delta entry in a changegroup.
533
534 Captured data is sufficient to serialize the delta into multiple
535 formats.
536
537 ``revision`` and ``delta`` are mutually exclusive.
538 """
539 # 20 byte node of this revision.
540 node = attr.ib()
518 node = attr.ib()
541 # 20 byte nodes of parent revisions.
542 p1node = attr.ib()
519 p1node = attr.ib()
543 p2node = attr.ib()
520 p2node = attr.ib()
544 # 20 byte node of node this delta is against.
545 basenode = attr.ib()
521 basenode = attr.ib()
546 # 20 byte node of changeset revision this delta is associated with.
547 linknode = attr.ib()
522 linknode = attr.ib()
548 # 2 bytes of flags to apply to revision data.
549 flags = attr.ib()
523 flags = attr.ib()
550 # Size of base revision this delta is against. May be None if
551 # basenode is nullid.
552 baserevisionsize = attr.ib()
524 baserevisionsize = attr.ib()
553 # Raw fulltext revision data.
554 revision = attr.ib()
525 revision = attr.ib()
555 # Delta between the basenode and node.
556 delta = attr.ib()
526 delta = attr.ib()
557
527
558 def _revisiondeltatochunks(delta, headerfn):
528 def _revisiondeltatochunks(delta, headerfn):
@@ -318,6 +318,87 b' class peer(object):'
318 _('cannot %s; remote repository does not support the %r '
318 _('cannot %s; remote repository does not support the %r '
319 'capability') % (purpose, name))
319 'capability') % (purpose, name))
320
320
321 class irevisiondelta(interfaceutil.Interface):
322 """Represents a delta between one revision and another.
323
324 Instances convey enough information to allow a revision to be exchanged
325 with another repository.
326
327 Instances represent the fulltext revision data or a delta against
328 another revision. Therefore the ``revision`` and ``delta`` attributes
329 are mutually exclusive.
330
331 Typically used for changegroup generation.
332 """
333
334 node = interfaceutil.Attribute(
335 """20 byte node of this revision.""")
336
337 p1node = interfaceutil.Attribute(
338 """20 byte node of 1st parent of this revision.""")
339
340 p2node = interfaceutil.Attribute(
341 """20 byte node of 2nd parent of this revision.""")
342
343 linknode = interfaceutil.Attribute(
344 """20 byte node of the changelog revision this node is linked to.""")
345
346 flags = interfaceutil.Attribute(
347 """2 bytes of integer flags that apply to this revision.""")
348
349 basenode = interfaceutil.Attribute(
350 """20 byte node of the revision this data is a delta against.
351
352 ``nullid`` indicates that the revision is a full revision and not
353 a delta.
354 """)
355
356 baserevisionsize = interfaceutil.Attribute(
357 """Size of base revision this delta is against.
358
359 May be ``None`` if ``basenode`` is ``nullid``.
360 """)
361
362 revision = interfaceutil.Attribute(
363 """Raw fulltext of revision data for this node.""")
364
365 delta = interfaceutil.Attribute(
366 """Delta between ``basenode`` and ``node``.
367
368 Stored in the bdiff delta format.
369 """)
370
371 class irevisiondeltarequest(interfaceutil.Interface):
372 """Represents a request to generate an ``irevisiondelta``."""
373
374 node = interfaceutil.Attribute(
375 """20 byte node of revision being requested.""")
376
377 p1node = interfaceutil.Attribute(
378 """20 byte node of 1st parent of revision.""")
379
380 p2node = interfaceutil.Attribute(
381 """20 byte node of 2nd parent of revision.""")
382
383 linknode = interfaceutil.Attribute(
384 """20 byte node to store in ``linknode`` attribute.""")
385
386 basenode = interfaceutil.Attribute(
387 """Base revision that delta should be generated against.
388
389 If ``nullid``, the derived ``irevisiondelta`` should have its
390 ``revision`` field populated and no delta should be generated.
391
392 If ``None``, the delta may be generated against any revision that
393 is an ancestor of this revision. Or a full revision may be used.
394
395 If any other value, the delta should be produced against that
396 revision.
397 """)
398
399 ellipsis = interfaceutil.Attribute(
400 """Boolean on whether the ellipsis flag should be set.""")
401
321 class ifilerevisionssequence(interfaceutil.Interface):
402 class ifilerevisionssequence(interfaceutil.Interface):
322 """Contains index data for all revisions of a file.
403 """Contains index data for all revisions of a file.
323
404
@@ -21,6 +21,7 b' from mercurial.thirdparty.zope.interface'
21 verify as ziverify,
21 verify as ziverify,
22 )
22 )
23 from mercurial import (
23 from mercurial import (
24 changegroup,
24 bundlerepo,
25 bundlerepo,
25 filelog,
26 filelog,
26 httppeer,
27 httppeer,
@@ -196,4 +197,29 b' def main():'
196 # Conforms to imanifestdict.
197 # Conforms to imanifestdict.
197 checkzobject(mctx.read())
198 checkzobject(mctx.read())
198
199
200 ziverify.verifyClass(repository.irevisiondelta,
201 changegroup.revisiondelta)
202 ziverify.verifyClass(repository.irevisiondeltarequest,
203 changegroup.revisiondeltarequest)
204
205 rd = changegroup.revisiondelta(
206 node=b'',
207 p1node=b'',
208 p2node=b'',
209 basenode=b'',
210 linknode=b'',
211 flags=b'',
212 baserevisionsize=None,
213 revision=b'',
214 delta=None)
215 checkzobject(rd)
216
217 rdr = changegroup.revisiondeltarequest(
218 node=b'',
219 linknode=b'',
220 p1node=b'',
221 p2node=b'',
222 basenode=b'')
223 checkzobject(rdr)
224
199 main()
225 main()
General Comments 0
You need to be logged in to leave comments. Login now