comparison mercurial/repository.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 a232e6744ba3
children b41d023a412a
comparison
equal deleted inserted replaced
39229:2646b8d66b7b 39230:b518d495a560
315 return 315 return
316 316
317 raise error.CapabilityError( 317 raise error.CapabilityError(
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
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.""")
320 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
324 Types implementing this behave like lists of tuples. The index 405 Types implementing this behave like lists of tuples. The index