Changeset View
Changeset View
Standalone View
Standalone View
swh/provenance/graph.py
from datetime import datetime, timezone | from datetime import datetime, timezone | ||||
import logging | import logging | ||||
import os | import os | ||||
from typing import Dict, Optional, Set | from typing import Dict, Optional, Set | ||||
from swh.model.model import Sha1Git | |||||
from .archive import ArchiveInterface | from .archive import ArchiveInterface | ||||
from .model import DirectoryEntry, RevisionEntry | from .model import DirectoryEntry, RevisionEntry | ||||
from .provenance import ProvenanceInterface | from .provenance import ProvenanceInterface | ||||
UTCMIN = datetime.min.replace(tzinfo=timezone.utc) | UTCMIN = datetime.min.replace(tzinfo=timezone.utc) | ||||
class HistoryNode: | class HistoryNode: | ||||
▲ Show 20 Lines • Show All 147 Lines • ▼ Show 20 Lines | ) -> IsochroneNode: | ||||
# Build the nodes structure | # Build the nodes structure | ||||
root_date = provenance.directory_get_date_in_isochrone_frontier(directory) | root_date = provenance.directory_get_date_in_isochrone_frontier(directory) | ||||
root = IsochroneNode(directory, dbdate=root_date) | root = IsochroneNode(directory, dbdate=root_date) | ||||
stack = [root] | stack = [root] | ||||
logging.debug( | logging.debug( | ||||
f"Recursively creating isochrone graph for revision {revision.id.hex()}..." | f"Recursively creating isochrone graph for revision {revision.id.hex()}..." | ||||
) | ) | ||||
fdates: Dict[bytes, datetime] = {} # map {file_id: date} | fdates: Dict[Sha1Git, datetime] = {} # map {file_id: date} | ||||
while stack: | while stack: | ||||
current = stack.pop() | current = stack.pop() | ||||
if current.dbdate is None or current.dbdate > revision.date: | if current.dbdate is None or current.dbdate > revision.date: | ||||
# If current directory has an associated date in the isochrone frontier that | # If current directory has an associated date in the isochrone frontier that | ||||
# is greater or equal to the current revision's one, it should be ignored as | # is greater or equal to the current revision's one, it should be ignored as | ||||
# the revision is being processed out of order. | # the revision is being processed out of order. | ||||
if current.dbdate is not None and current.dbdate > revision.date: | if current.dbdate is not None and current.dbdate > revision.date: | ||||
logging.debug( | logging.debug( | ||||
▲ Show 20 Lines • Show All 79 Lines • Show Last 20 Lines |