# HG changeset patch # User Georges Racinet <georges.racinet@octobus.net> # Date 1588759481 -7200 # Wed May 06 12:04:41 2020 +0200 # Branch heptapod-0-12 # Node ID 5016d915ae0d3bc0151ef918e9d04e2597ca7bf9 # Parent f6622702df2b8ecae4a33382ff0cb42fa556b510 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. diff --git a/hgext3rd/heptapod/git.py b/hgext3rd/heptapod/git.py --- a/hgext3rd/heptapod/git.py +++ b/hgext3rd/heptapod/git.py @@ -12,6 +12,7 @@ from dulwich.protocol import ZERO_SHA from hggit.git_handler import GitHandler from heptapod import gitlab +from hgext3rd.evolve import headchecking from mercurial.i18n import _ from mercurial.node import hex from mercurial import ( @@ -195,14 +196,17 @@ for _, bm in self._filter_for_bookmarks(all_bookmarks)} for branch, hg_nodes in repo.branchmap().iteritems(): 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', 'hg-git.prune-newly-closed-branches', True): - hg_nodes = [n for n in hg_nodes if not repo[n].closesbranch()] - if not hg_nodes: + ctxs = [c for c in ctxs if not c.closesbranch()] + if not ctxs: to_prune[git_branch_ref(gb)] = 'closed' - hg_shas = {hex(n) for n in hg_nodes} + hg_shas = {c.hex() for c in ctxs} # We ignore bookmarked changesets because: # - we don't want them in the 'wild' namespace # - no other Git ref would be relevant for them diff --git a/install-requirements.txt b/install-requirements.txt --- a/install-requirements.txt +++ b/install-requirements.txt @@ -1,3 +1,3 @@ Mercurial>=5.2,<5.4 -hg-evolve>=9.2.1 +hg-evolve>=9.3.1 hg-git>=0.8.13