Changeset View
Changeset View
Standalone View
Standalone View
swh/provenance/model.py
Show First 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | ): | ||||
self.date = date | self.date = date | ||||
assert self.date is None or self.date.tzinfo is not None | assert self.date is None or self.date.tzinfo is not None | ||||
self.root = root | self.root = root | ||||
self._parents = parents | self._parents = parents | ||||
self._nodes: List[RevisionEntry] = [] | self._nodes: List[RevisionEntry] = [] | ||||
def parents(self, archive: ArchiveInterface): | def parents(self, archive: ArchiveInterface): | ||||
if self._parents is None: | if self._parents is None: | ||||
revision = archive.revision_get([self.id]) | revision = list(archive.revision_get([self.id])) | ||||
if revision: | if revision: | ||||
self._parents = list(revision)[0].parents | self._parents = revision[0].parents | ||||
if self._parents and not self._nodes: | if self._parents and not self._nodes: | ||||
self._nodes = [ | self._nodes = [ | ||||
RevisionEntry( | RevisionEntry( | ||||
id=rev.id, | id=rev.id, | ||||
root=rev.directory, | root=rev.directory, | ||||
date=rev.date, | date=rev.date.to_datetime(), | ||||
parents=rev.parents, | parents=rev.parents, | ||||
) | ) | ||||
for rev in archive.revision_get(self._parents) | for rev in archive.revision_get(self._parents) | ||||
if rev | if rev is not None and rev.date is not None | ||||
] | ] | ||||
douardda: please use the new `TimestampWithTimwzone.to_datetime()` recently added in `swh.model` (in v2.6. | |||||
Done Inline Actionssure. It just wasn't there when this modification was originally done aeviso: sure. It just wasn't there when this modification was originally done | |||||
Not Done Inline Actions
indeed, since I've added it explicitly for this :-) douardda: > sure. It just wasn't there when this modification was originally done
indeed, since I've… | |||||
yield from self._nodes | yield from self._nodes | ||||
def __str__(self): | def __str__(self): | ||||
return f"<MRevision[{self.id.hex()}] {self.date.isoformat()}>" | return f"<MRevision[{self.id.hex()}] {self.date.isoformat()}>" | ||||
class DirectoryEntry: | class DirectoryEntry: | ||||
def __init__(self, id: bytes, name: bytes = b""): | def __init__(self, id: bytes, name: bytes = b""): | ||||
▲ Show 20 Lines • Show All 64 Lines • Show Last 20 Lines |
please use the new TimestampWithTimwzone.to_datetime() recently added in swh.model (in v2.6.0) instead.