Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F7123679
D511.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Subscribers
None
D511.diff
View Options
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
@@ -47,6 +47,8 @@
TEMPORARY_DIR_PREFIX_PATTERN = 'swh.loader.mercurial.'
+HEAD_POINTER_NAME = b'tip'
+
class HgBundle20Loader(SWHStatelessLoader):
"""Mercurial loader able to deal with remote or local repository.
@@ -97,21 +99,22 @@
def get_heads(self, repo):
"""Read the closed branches heads (branch, bookmarks) and returns a
- dict with branch_name (bytes) and mercurial's node id
- (bytes). Those needs conversion to swh-ids. This is taken
+ dict with key the branch_name (bytes) and values the tuple
+ (pointer nature (bytes), mercurial's node id
+ (bytes)). Those needs conversion to swh-ids. This is taken
care of in get_revisions.
"""
b = {}
- for _, node_hash_id, _, branch_name, *_ in repo.heads():
- b[branch_name] = hash_to_bytes(
- node_hash_id.decode())
+ for _, node_hash_id, pointer_nature, branch_name, *_ in repo.heads():
+ b[branch_name] = (
+ pointer_nature, hash_to_bytes(node_hash_id.decode()))
bookmarks = repo.bookmarks()
if bookmarks and bookmarks[0]:
for bookmark_name, _, target_short in bookmarks[0]:
target = repo[target_short].node()
- b[bookmark_name] = hash_to_bytes(target.decode())
+ b[bookmark_name] = (None, hash_to_bytes(target.decode()))
return b
@@ -409,8 +412,8 @@
# Converts heads to use swh ids
self.heads = {
- branch_name: self.node_2_rev[node_id]
- for branch_name, node_id in self.heads.items()
+ branch_name: (pointer_nature, self.node_2_rev[node_id])
+ for branch_name, (pointer_nature, node_id) in self.heads.items()
}
missing_revs = revisions.keys()
@@ -475,8 +478,10 @@
def get_snapshot(self):
"""Get the snapshot that need to be loaded."""
branches = {}
- for name, target in self.heads.items():
+ for name, (pointer_nature, target) in self.heads.items():
branches[name] = {'target': target, 'target_type': 'revision'}
+ if pointer_nature == HEAD_POINTER_NAME:
+ branches[b'HEAD'] = {'target': name, 'target_type': 'alias'}
for name, target in self.releases.items():
branches[name] = {'target': target, 'target_type': 'release'}
diff --git a/swh/loader/mercurial/loader_verifier.py b/swh/loader/mercurial/loader_verifier.py
--- a/swh/loader/mercurial/loader_verifier.py
+++ b/swh/loader/mercurial/loader_verifier.py
@@ -218,7 +218,7 @@
self.visit = 'foo'
logging.debug('getting snapshot')
o = self.get_snapshot()
- logging.debug(o['branches'].keys())
+ logging.debug('Snapshot: %s' % o)
finally:
self.cleanup()
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
@@ -173,7 +173,7 @@
self.assertCountSnapshots(1)
expected_snapshot = {
- 'id': '05cad59e8980069d9fe2324d406cf226c0021e1c',
+ 'id': '3b8fe58e467deb7597b12a5fd3b2c096b8c02028',
'branches': {
'develop': {
'target': tip_revision_develop,
@@ -183,6 +183,10 @@
'target': tip_revision_default,
'target_type': 'revision'
},
+ 'HEAD': {
+ 'target': 'develop',
+ 'target_type': 'alias',
+ }
}
}
@@ -233,7 +237,7 @@
self.assertCountSnapshots(1)
expected_snapshot = {
- 'id': 'fa537f8e0cbdb8a54e29533302ed6fcbee28cb7b',
+ 'id': 'd35668e02e2ba4321dc951cd308cf883786f918a',
'branches': {
'default': {
'target': tip_revision_default,
@@ -242,6 +246,10 @@
'0.1': {
'target': tip_release,
'target_type': 'release'
+ },
+ 'HEAD': {
+ 'target': 'default',
+ 'target_type': 'alias',
}
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Dec 19 2024, 6:05 PM (11 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3216472
Attached To
D511: loader-mercurial: Add default branch's tip as alias in snapshot's branches
Event Timeline
Log In to Comment