app.services.diff¶
Unified diff between stored snapshots (GET /api/v1/records/{id}/diff).
The diff compares the exact canonical snapshots in the revision
store (never Git history). Defaults:
from: the identity’s last decided snapshot other than the current digest (latest acceptance, else latest rejection,app.domain.approval.last_decided()); else the record’sprevious_digest; else there is no base (reason: "no_prior_revision").to: the record’s current digest.
Only digests related to the record may be requested: its current and
previous digest, digests decided for its identity, and the current
digests of its identity siblings. Any other digest is answered with
404 unknown_revision, so the endpoint cannot be used to read
arbitrary snapshots.
Public API: DiffEndpoint, RecordDiff,
diff_record(), short_digest().
- class app.services.diff.DiffEndpoint(*, digest, label, decided_at=None)¶
Bases:
objectOne side of a diff.
- Parameters:
- class app.services.diff.RecordDiff(*, base, target, reason, unified_diff, identical, lines_added, lines_removed)¶
Bases:
objectA unified diff between two snapshots of one record’s identity.
- Parameters:
base (
DiffEndpoint|None) – Thefromside,Nonewithout a prior revision.target (
DiffEndpoint) – Thetoside.reason (
str|None) –no_prior_revisionwhen there is no base.unified_diff (
str) –difflibunified diff text (empty when the snapshots are identical or there is no base).identical (
bool) – Whether both snapshots are the same content.lines_added (
int) – Number of added lines.lines_removed (
int) – Number of removed lines.
- base: DiffEndpoint | None¶
- target: DiffEndpoint¶
- app.services.diff.diff_record(store, record_id, *, from_digest=None, to_digest=None)¶
Diff two snapshots of a record’s identity.
- Parameters:
- Return type:
- Returns:
The diff.
- Raises:
NotFoundError –
record_not_foundorunknown_revision.