Skip to content
Snippets Groups Projects
Verified Commit cacf65dc authored by Antoine R. Dumont's avatar Antoine R. Dumont
Browse files

directory: Build snapshot with svn revision branch name

Otherwise, we'd lose the context in the snapshot.

Refs. swh/meta#4979
parent a1a53593
No related branches found
Tags v1.8.0
1 merge request!228directory: Build snapshot with svn revision branch name
Pipeline #2860 passed
......@@ -12,6 +12,7 @@ from typing import Iterator, Optional
from swh.loader.core.loader import BaseDirectoryLoader
from swh.loader.svn.svn_repo import SvnRepo, get_svn_repo
from swh.model.model import Snapshot, SnapshotBranch, TargetType
class SvnDirectoryLoader(BaseDirectoryLoader):
......@@ -25,6 +26,9 @@ class SvnDirectoryLoader(BaseDirectoryLoader):
id: <bytes>
branches:
HEAD:
target_type: alias
target: rev_<svn-revision>
rev_<svn-revision>:
target_type: directory
target: <directory-id>
......@@ -51,3 +55,20 @@ class SvnDirectoryLoader(BaseDirectoryLoader):
assert self.svnrepo is not None
_, local_url = self.svnrepo.export_temporary(self.svn_revision)
yield Path(local_url.decode())
def build_snapshot(self) -> Snapshot:
"""Build snapshot without losing the svn revision context."""
assert self.directory is not None
branch_name = f"rev_{self.svn_revision}".encode()
return Snapshot(
branches={
b"HEAD": SnapshotBranch(
target_type=TargetType.ALIAS,
target=branch_name,
),
branch_name: SnapshotBranch(
target_type=TargetType.DIRECTORY,
target=self.directory.hash,
),
}
)
......@@ -48,13 +48,20 @@ def test_loader_svn_directory(swh_storage, datadir, tmp_path):
assert actual_result == {"status": "eventful"}
assert_last_visit_matches(
actual_visit = assert_last_visit_matches(
swh_storage,
repo_url,
status="full",
type="svn-export",
)
snapshot = swh_storage.snapshot_get(actual_visit.snapshot)
assert snapshot is not None
branches = snapshot["branches"].keys()
expected_branch = f"rev_{svn_revision}".encode()
assert set(branches) == {b"HEAD", expected_branch}
assert get_stats(swh_storage) == {
"content": 18,
"directory": 6,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment