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

gitlab-mirror: filtering out obsolete heads in branchmap

As of hg-evolve 9.3.1, some obsolete heads are ignored in the
protection agains multiple heads. These happen typically in
stacked topic scenarios, after amendment of the anterior topic.

These should not count as multiple heads in our exposition to GitLab
either, we're applying the same function to filter them out.

This has us convert systematically to changeset contexts (standard
abbrev being `ctx`) whereas we were doing so before only in the loop
to ignore closed branches.
parent f6622702df2b
No related branches found
No related tags found
1 merge request!23gitlab-mirror: better handling of stacked topic cases
Pipeline #5680 passed
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
from dulwich.protocol import ZERO_SHA from dulwich.protocol import ZERO_SHA
from hggit.git_handler import GitHandler from hggit.git_handler import GitHandler
from heptapod import gitlab from heptapod import gitlab
from hgext3rd.evolve import headchecking
from mercurial.i18n import _ from mercurial.i18n import _
from mercurial.node import hex from mercurial.node import hex
from mercurial import ( from mercurial import (
...@@ -195,6 +196,9 @@ ...@@ -195,6 +196,9 @@
for _, bm in self._filter_for_bookmarks(all_bookmarks)} for _, bm in self._filter_for_bookmarks(all_bookmarks)}
for branch, hg_nodes in repo.branchmap().iteritems(): for branch, hg_nodes in repo.branchmap().iteritems():
gb = self.git_branch_for_branchmap_branch(branch) gb = self.git_branch_for_branchmap_branch(branch)
revs = [repo[n].rev() for n in hg_nodes]
ctxs = [repo[r]
for r in headchecking._filter_obsolete_heads(repo, revs)]
if ui.configbool('experimental', if ui.configbool('experimental',
'hg-git.prune-newly-closed-branches', True): 'hg-git.prune-newly-closed-branches', True):
...@@ -198,6 +202,6 @@ ...@@ -198,6 +202,6 @@
if ui.configbool('experimental', if ui.configbool('experimental',
'hg-git.prune-newly-closed-branches', True): 'hg-git.prune-newly-closed-branches', True):
hg_nodes = [n for n in hg_nodes if not repo[n].closesbranch()] ctxs = [c for c in ctxs if not c.closesbranch()]
if not hg_nodes: if not ctxs:
to_prune[git_branch_ref(gb)] = 'closed' to_prune[git_branch_ref(gb)] = 'closed'
...@@ -203,3 +207,2 @@ ...@@ -203,3 +207,2 @@
to_prune[git_branch_ref(gb)] = 'closed' to_prune[git_branch_ref(gb)] = 'closed'
hg_shas = {hex(n) for n in hg_nodes}
...@@ -205,4 +208,5 @@ ...@@ -205,4 +208,5 @@
hg_shas = {c.hex() for c in ctxs}
# We ignore bookmarked changesets because: # We ignore bookmarked changesets because:
# - we don't want them in the 'wild' namespace # - we don't want them in the 'wild' namespace
# - no other Git ref would be relevant for them # - no other Git ref would be relevant for them
......
Mercurial>=5.2,<5.4 Mercurial>=5.2,<5.4
hg-evolve>=9.2.1 hg-evolve>=9.3.1
hg-git>=0.8.13 hg-git>=0.8.13
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