Changeset View
Changeset View
Standalone View
Standalone View
swh/provenance/revision.py
Show First 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | |||||
@statsd.timed(metric=REVISION_DURATION_METRIC, tags={"method": "main"}) | @statsd.timed(metric=REVISION_DURATION_METRIC, tags={"method": "main"}) | ||||
def revision_add( | def revision_add( | ||||
provenance: ProvenanceInterface, | provenance: ProvenanceInterface, | ||||
archive: ArchiveInterface, | archive: ArchiveInterface, | ||||
revisions: List[RevisionEntry], | revisions: List[RevisionEntry], | ||||
trackall: bool = True, | trackall: bool = True, | ||||
flatten: bool = True, | |||||
lower: bool = True, | lower: bool = True, | ||||
mindepth: int = 1, | mindepth: int = 1, | ||||
minsize: int = 0, | minsize: int = 0, | ||||
commit: bool = True, | commit: bool = True, | ||||
) -> None: | ) -> None: | ||||
for revision in revisions: | for revision in revisions: | ||||
assert revision.date is not None | assert revision.date is not None | ||||
assert revision.root is not None | assert revision.root is not None | ||||
# Processed content starting from the revision's root directory. | # Processed content starting from the revision's root directory. | ||||
date = provenance.revision_get_date(revision) | date = provenance.revision_get_date(revision) | ||||
if date is None or revision.date < date: | if date is None or revision.date < date: | ||||
graph = build_isochrone_graph( | graph = build_isochrone_graph( | ||||
provenance, | provenance, | ||||
archive, | archive, | ||||
revision, | revision, | ||||
DirectoryEntry(revision.root), | DirectoryEntry(revision.root), | ||||
minsize=minsize, | minsize=minsize, | ||||
) | ) | ||||
revision_process_content( | revision_process_content( | ||||
provenance, | provenance, | ||||
archive, | archive, | ||||
revision, | revision, | ||||
graph, | graph, | ||||
trackall=trackall, | trackall=trackall, | ||||
flatten=flatten, | |||||
lower=lower, | lower=lower, | ||||
mindepth=mindepth, | mindepth=mindepth, | ||||
minsize=minsize, | minsize=minsize, | ||||
) | ) | ||||
if commit: | if commit: | ||||
provenance.flush() | provenance.flush() | ||||
@statsd.timed(metric=REVISION_DURATION_METRIC, tags={"method": "process_content"}) | @statsd.timed(metric=REVISION_DURATION_METRIC, tags={"method": "process_content"}) | ||||
def revision_process_content( | def revision_process_content( | ||||
provenance: ProvenanceInterface, | provenance: ProvenanceInterface, | ||||
archive: ArchiveInterface, | archive: ArchiveInterface, | ||||
revision: RevisionEntry, | revision: RevisionEntry, | ||||
graph: IsochroneNode, | graph: IsochroneNode, | ||||
trackall: bool = True, | trackall: bool = True, | ||||
flatten: bool = True, | |||||
lower: bool = True, | lower: bool = True, | ||||
mindepth: int = 1, | mindepth: int = 1, | ||||
minsize: int = 0, | minsize: int = 0, | ||||
) -> None: | ) -> None: | ||||
assert revision.date is not None | assert revision.date is not None | ||||
provenance.revision_add(revision) | provenance.revision_add(revision) | ||||
stack = [graph] | stack = [graph] | ||||
Show All 23 Lines | while stack: | ||||
# frontier. | # frontier. | ||||
provenance.directory_set_date_in_isochrone_frontier( | provenance.directory_set_date_in_isochrone_frontier( | ||||
current.entry, current.maxdate | current.entry, current.maxdate | ||||
) | ) | ||||
if trackall: | if trackall: | ||||
provenance.directory_add_to_revision( | provenance.directory_add_to_revision( | ||||
revision, current.entry, current.path | revision, current.entry, current.path | ||||
) | ) | ||||
if flatten: | |||||
directory_flatten( | directory_flatten( | ||||
provenance, archive, current.entry, minsize=minsize | provenance, archive, current.entry, minsize=minsize | ||||
) | ) | ||||
else: | else: | ||||
# If current node is an invalidated frontier, update its date for future | # If current node is an invalidated frontier, update its date for future | ||||
# revisions to get the proper value. | # revisions to get the proper value. | ||||
if current.invalid: | if current.invalid: | ||||
provenance.directory_set_date_in_isochrone_frontier( | provenance.directory_set_date_in_isochrone_frontier( | ||||
current.entry, current.maxdate | current.entry, current.maxdate | ||||
) | ) | ||||
# No point moving the frontier here. Either there are no files or they | # No point moving the frontier here. Either there are no files or they | ||||
▲ Show 20 Lines • Show All 76 Lines • Show Last 20 Lines |