Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F7122902
D6717.id24464.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Subscribers
None
D6717.id24464.diff
View Options
diff --git a/swh/provenance/cli.py b/swh/provenance/cli.py
--- a/swh/provenance/cli.py
+++ b/swh/provenance/cli.py
@@ -179,6 +179,7 @@
@cli.command(name="iter-revisions")
@click.argument("filename")
@click.option("-a", "--track-all", default=True, type=bool)
+@click.option("-f", "--flatten", default=True, type=bool)
@click.option("-l", "--limit", type=int)
@click.option("-m", "--min-depth", default=1, type=int)
@click.option("-r", "--reuse", default=True, type=bool)
@@ -188,6 +189,7 @@
ctx: click.core.Context,
filename: str,
track_all: bool,
+ flatten: bool,
limit: Optional[int],
min_depth: int,
reuse: bool,
@@ -208,6 +210,7 @@
archive,
[revision],
trackall=track_all,
+ flatten=flatten,
lower=reuse,
mindepth=min_depth,
minsize=min_size,
diff --git a/swh/provenance/revision.py b/swh/provenance/revision.py
--- a/swh/provenance/revision.py
+++ b/swh/provenance/revision.py
@@ -57,6 +57,7 @@
archive: ArchiveInterface,
revisions: List[RevisionEntry],
trackall: bool = True,
+ flatten: bool = True,
lower: bool = True,
mindepth: int = 1,
minsize: int = 0,
@@ -81,6 +82,7 @@
revision,
graph,
trackall=trackall,
+ flatten=flatten,
lower=lower,
mindepth=mindepth,
minsize=minsize,
@@ -96,6 +98,7 @@
revision: RevisionEntry,
graph: IsochroneNode,
trackall: bool = True,
+ flatten: bool = True,
lower: bool = True,
mindepth: int = 1,
minsize: int = 0,
@@ -135,9 +138,10 @@
provenance.directory_add_to_revision(
revision, current.entry, current.path
)
- directory_flatten(
- provenance, archive, current.entry, minsize=minsize
- )
+ if flatten:
+ directory_flatten(
+ provenance, archive, current.entry, minsize=minsize
+ )
else:
# If current node is an invalidated frontier, update its date for future
# revisions to get the proper value.
diff --git a/swh/provenance/tests/test_revision_content_layer.py b/swh/provenance/tests/test_revision_content_layer.py
--- a/swh/provenance/tests/test_revision_content_layer.py
+++ b/swh/provenance/tests/test_revision_content_layer.py
@@ -12,8 +12,9 @@
from swh.model.hashutil import hash_to_bytes
from swh.model.model import Sha1Git
from swh.provenance.archive import ArchiveInterface
+from swh.provenance.directory import directory_add
from swh.provenance.interface import EntityType, ProvenanceInterface, RelationType
-from swh.provenance.model import RevisionEntry
+from swh.provenance.model import DirectoryEntry, RevisionEntry
from swh.provenance.revision import revision_add
from swh.provenance.tests.conftest import (
fill_storage,
@@ -148,13 +149,18 @@
@pytest.mark.parametrize(
- "repo, lower, mindepth",
+ "repo, lower, mindepth, flatten",
(
- ("cmdbts2", True, 1),
- ("cmdbts2", False, 1),
- ("cmdbts2", True, 2),
- ("cmdbts2", False, 2),
- ("out-of-order", True, 1),
+ ("cmdbts2", True, 1, True),
+ ("cmdbts2", True, 1, False),
+ ("cmdbts2", False, 1, True),
+ ("cmdbts2", False, 1, False),
+ ("cmdbts2", True, 2, True),
+ ("cmdbts2", True, 2, False),
+ ("cmdbts2", False, 2, True),
+ ("cmdbts2", False, 2, False),
+ ("out-of-order", True, 1, True),
+ ("out-of-order", True, 1, False),
),
)
def test_revision_content_result(
@@ -163,6 +169,7 @@
repo: str,
lower: bool,
mindepth: int,
+ flatten: bool,
) -> None:
# read data/README.md for more details on how these datasets are generated
data = load_repo_data(repo)
@@ -195,7 +202,28 @@
date=ts2dt(revision["date"]),
root=revision["directory"],
)
- revision_add(provenance, archive, [entry], lower=lower, mindepth=mindepth)
+
+ if flatten:
+ revision_add(provenance, archive, [entry], lower=lower, mindepth=mindepth)
+ else:
+ prev_directories = provenance.storage.entity_get_all(EntityType.DIRECTORY)
+ revision_add(
+ provenance,
+ archive,
+ [entry],
+ lower=lower,
+ mindepth=mindepth,
+ flatten=False,
+ )
+ directories = [
+ DirectoryEntry(id=sha1)
+ for sha1 in provenance.storage.entity_get_all(
+ EntityType.DIRECTORY
+ ).difference(prev_directories)
+ ]
+ for directory in directories:
+ assert not provenance.directory_already_flattenned(directory)
+ directory_add(provenance, archive, directories)
# each "entry" in the synth file is one new revision
rows["revision"].add(synth_rev["sha1"])
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 17, 10:38 AM (1 w, 5 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3226460
Attached To
D6717: Add new flag to skip directory flattening while processing revisions
Event Timeline
Log In to Comment