Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9339741
D1507.id4955.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Subscribers
None
D1507.id4955.diff
View Options
diff --git a/swh/loader/mercurial/bundle20_reader.py b/swh/loader/mercurial/bundle20_reader.py
--- a/swh/loader/mercurial/bundle20_reader.py
+++ b/swh/loader/mercurial/bundle20_reader.py
@@ -323,7 +323,7 @@
commit['time'] = datetime.fromtimestamp(float(tstamp))
commit['time_offset_seconds'] = int(tz)
if extra:
- commit['extra'] = extra[0]
+ commit['extra'] = b' '.join(extra)
commit['changed_files'] = parts[3:]
return commit
diff --git a/swh/loader/mercurial/loader.py b/swh/loader/mercurial/loader.py
--- a/swh/loader/mercurial/loader.py
+++ b/swh/loader/mercurial/loader.py
@@ -376,6 +376,10 @@
for e in extra.split(b'\x00'):
k, v = e.split(b':', 1)
k = k.decode('utf-8')
+ # transplant_source stores binary reference to a changeset
+ # prefer to dump hexadecimal one in the revision metadata
+ if k == 'transplant_source':
+ v = hash_to_hex(v)
extra_meta.append([k, v])
revision = {
diff --git a/swh/loader/mercurial/tests/resources/transplant.tgz b/swh/loader/mercurial/tests/resources/transplant.tgz
new file mode 100644
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
GIT binary patch
literal 0
Hc$@<O00001
literal 0
Hc$@<O00001
diff --git a/swh/loader/mercurial/tests/test_loader.py b/swh/loader/mercurial/tests/test_loader.py
--- a/swh/loader/mercurial/tests/test_loader.py
+++ b/swh/loader/mercurial/tests/test_loader.py
@@ -29,7 +29,7 @@
self.storage = self.loader.storage
-class LoaderTestT1(BaseHgLoaderTest):
+class WithoutReleaseLoaderTest(BaseHgLoaderTest):
"""Load a mercurial repository without release
"""
@@ -190,7 +190,7 @@
self.assertEqual(self.loader.visit_status(), 'full')
-class LoaderTest2(BaseHgLoaderTest, CommonHgLoaderData):
+class WithReleaseLoaderTest(BaseHgLoaderTest, CommonHgLoaderData):
"""Load a mercurial repository with release
"""
@@ -247,3 +247,43 @@
self.assertCountRevisions(0)
self.assertCountReleases(0)
self.assertCountSnapshots(0)
+
+
+class WithTransplantLoaderTest(BaseHgLoaderTest):
+ """Load a mercurial repository where transplant operations
+ have been used.
+
+ """
+ def setUp(self):
+ super().setUp(archive_name='transplant.tgz', filename='transplant')
+
+ def test_load(self):
+ # load hg repository
+ self.loader.load(
+ origin_url=self.repo_url,
+ visit_date='2019-05-23 12:06:00+00',
+ directory=self.destination_path)
+
+ # collect swh revisions
+ origin_id = self.storage.origin_get([
+ {'type': 'hg', 'url': self.repo_url}])[0]['id']
+ snapshot = self.storage.snapshot_get_latest(origin_id)
+ revisions = []
+ for branch in snapshot['branches'].values():
+ if branch['target_type'] != 'revision':
+ continue
+ revisions.append(branch['target'])
+
+ # extract original changesets info and the transplant sources
+ hg_changesets = set()
+ transplant_sources = set()
+ for rev in self.storage.revision_log(revisions):
+ hg_changesets.add(rev['metadata']['node'])
+ for k, v in rev['metadata']['extra_headers']:
+ if k == 'transplant_source':
+ transplant_sources.add(v)
+
+ # check extracted data are valid
+ self.assertTrue(len(hg_changesets) > 0)
+ self.assertTrue(len(transplant_sources) > 0)
+ self.assertTrue(transplant_sources.issubset(hg_changesets))
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Jul 3 2025, 9:52 AM (5 w, 2 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3214533
Attached To
D1507: Properly handle transplant_source in changeset extra fields
Event Timeline
Log In to Comment