Skip to content
Snippets Groups Projects
Commit 4f896fe2 authored by Georges Racinet's avatar Georges Racinet
Browse files

exportable heads finalization: variable sanitiy

- no more side effects on the `hg_shas` set, actually can be
  any iterable now
- explicit namings for better maintainability: result_sha,
  wild_sha instead of over-using hg_sha
parent fc59a091
No related branches found
No related tags found
1 merge request!40Take over single head enforcement, plus refactorings
......@@ -318,11 +318,10 @@
stoging extra heads in the ``wild`` namespace, according to
configuration.
:param branch: branchmap branch
:param set hg_shas: Mercurial changeset SHAs candidates that remain for
the given ``branch``
:param hg_shas: iterable of Mercurial changeset SHAs candidates that
remain for the given ``branchmap_branch``
:param dict git_refs: mapping of GitLab branches to Mercurial changeset
IDs.
"""
if not hg_shas:
return
......@@ -324,7 +323,8 @@
:param dict git_refs: mapping of GitLab branches to Mercurial changeset
IDs.
"""
if not hg_shas:
return
repo = self.repo
ui = self.repo.ui
......@@ -329,6 +329,8 @@
repo = self.repo
ui = self.repo.ui
if 1 < len(hg_shas):
if len(hg_shas) == 1:
result_sha = next(iter(hg_shas))
else:
if not allow_multiple:
# taken straight from `headchecking.enforcesinglehead`
# that is disabled in Heptapod just to avoid calling
......@@ -354,11 +356,12 @@
ui.note(logprefix, b"Multiple heads for branch '%s': %r" % (
branchmap_branch, util.format_bytes_list(hg_shas)))
for hg_sha in hg_shas:
gitlab_refs[hg_sha].heads.add(
git_branch_ref(b'wild/' + hg_sha))
for wild_sha in hg_shas:
gitlab_refs[wild_sha].heads.add(
git_branch_ref(b'wild/' + wild_sha))
ui.note(logprefix,
b"Chose %s out of multiple heads %s "
b"for forwarding branch %r" % (
result_sha, util.format_bytes_list(hg_shas),
branchmap_branch))
......@@ -360,11 +363,10 @@
ui.note(logprefix,
b"Chose %s out of multiple heads %s "
b"for forwarding branch %r" % (
result_sha, util.format_bytes_list(hg_shas),
branchmap_branch))
hg_shas = [result_sha]
hg_sha = hg_shas.pop()
gitlab_refs[hg_sha].heads.add(git_branch_ref(gitlab_branch))
gitlab_refs[result_sha].heads.add(git_branch_ref(gitlab_branch))
def published_topic_latest_hg_sha(self, topic, ctx, log_before_ctx=None):
"""Rewrapping of `latest_topic_descendant` returning hg sha.
......
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