Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F7163828
D2903.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
D2903.diff
View Options
diff --git a/swh/journal/fixer.py b/swh/journal/fixer.py
--- a/swh/journal/fixer.py
+++ b/swh/journal/fixer.py
@@ -171,6 +171,26 @@
return rev
+def _fix_origin(origin: Dict) -> Dict:
+ """Fix legacy origin with type which is no longer part of the model.
+
+ >>> from pprint import pprint
+ >>> pprint(_fix_origin({
+ ... 'url': 'http://foo',
+ ... }))
+ {'url': 'http://foo'}
+ >>> pprint(_fix_origin({
+ ... 'url': 'http://bar',
+ ... 'type': 'foo',
+ ... }))
+ {'url': 'http://bar'}
+
+ """
+ o = origin.copy()
+ o.pop('type', None)
+ return o
+
+
def _fix_origin_visit(visit: Dict) -> Dict:
"""Fix various legacy origin visit issues.
@@ -262,6 +282,8 @@
elif object_type == 'revision':
revisions = [_fix_revision(v) for v in objects]
return [rev for rev in revisions if rev is not None]
+ elif object_type == 'origin':
+ return [_fix_origin(v) for v in objects]
elif object_type == 'origin_visit':
return [_fix_origin_visit(v) for v in objects]
else:
diff --git a/swh/journal/tests/test_replay.py b/swh/journal/tests/test_replay.py
--- a/swh/journal/tests/test_replay.py
+++ b/swh/journal/tests/test_replay.py
@@ -297,6 +297,7 @@
# the origin when needed (type is missing)
writer.send('origin', 'foo', {
'url': 'http://example.com/',
+ 'type': 'git',
})
for visit in visits:
writer.send('origin_visit', 'foo', visit)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jan 30, 4:18 PM (2 h, 11 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3219091
Attached To
D2903: replayer: Allow legacy origin to be replayed
Event Timeline
Log In to Comment