Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9341128
D3500.id12363.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
D3500.id12363.diff
View Options
diff --git a/swh/storage/in_memory.py b/swh/storage/in_memory.py
--- a/swh/storage/in_memory.py
+++ b/swh/storage/in_memory.py
@@ -605,7 +605,7 @@
if target_types:
next_branch = None
branches = {}
- for (branch_name, branch) in snapshot.branches.items():
+ for (branch_name, branch) in sorted(snapshot.branches.items()):
if branch_name in sorted_branch_names[from_index:]:
if branch and branch.target_type.value in target_types:
if len(branches) < branches_count:
diff --git a/swh/storage/tests/test_storage.py b/swh/storage/tests/test_storage.py
--- a/swh/storage/tests/test_storage.py
+++ b/swh/storage/tests/test_storage.py
@@ -2749,6 +2749,36 @@
assert snapshot == expected_snapshot
+ def test_snapshot_add_get_branch_by_type(self, swh_storage):
+ snapshot = copy.deepcopy(data.complete_snapshot)
+
+ alias1 = b"alias1"
+ alias2 = b"alias2"
+ target1 = random.choice(list(snapshot["branches"].keys()))
+ target2 = random.choice(list(snapshot["branches"].keys()))
+
+ snapshot["branches"][alias2] = {
+ "target": target2,
+ "target_type": "alias",
+ }
+
+ snapshot["branches"][alias1] = {
+ "target": target1,
+ "target_type": "alias",
+ }
+
+ swh_storage.snapshot_add([snapshot])
+
+ branches = swh_storage.snapshot_get_branches(
+ snapshot["id"],
+ target_types=["alias"],
+ branches_from=alias1,
+ branches_count=1,
+ )["branches"]
+
+ assert len(branches) == 1
+ assert alias1 in branches
+
def test_snapshot_add_get(self, swh_storage):
origin_url = swh_storage.origin_add_one(data.origin)
visit = OriginVisit(
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jul 3, 11:43 AM (3 w, 3 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3234131
Attached To
D3500: in_memory: Fix snapshot_get_branches regression with target_types
Event Timeline
Log In to Comment