diff --git a/swh/provenance/provenance.py b/swh/provenance/provenance.py --- a/swh/provenance/provenance.py +++ b/swh/provenance/provenance.py @@ -227,12 +227,12 @@ class IsochroneNode: def __init__( - self, entry: DirectoryEntry, dates: Dict[bytes, datetime] = {}, depth: int = 0 + self, entry: DirectoryEntry, date: Optional[datetime] = None, depth: int = 0 ): self.entry = entry self.depth = depth - self.date = dates.get(self.entry.id, None) - self.known = self.date is not None + self.date = date + self.known: bool = self.date is not None self.children: List[IsochroneNode] = [] self.maxdate: Optional[datetime] = None @@ -240,7 +240,8 @@ self, child: DirectoryEntry, dates: Dict[bytes, datetime] = {} ) -> "IsochroneNode": assert isinstance(self.entry, DirectoryEntry) and self.date is None - node = IsochroneNode(child, dates=dates, depth=self.depth + 1) + node = IsochroneNode( + child, date=dates.get(child.id, None), depth=self.depth + 1) self.children.append(node) return node @@ -255,9 +256,8 @@ assert revision.root == directory.id # Build the nodes structure - root = IsochroneNode(directory) - root.date = provenance.directory_get_date_in_isochrone_frontier(directory) - root.known = root.date is not None + root_date = provenance.directory_get_date_in_isochrone_frontier(directory) + root = IsochroneNode(directory, date=root_date) stack = [root] logging.debug( f"Recursively creating graph for revision {hash_to_hex(revision.id)}..."