diff mercurial/discovery.py @ 44450:7d5455b988ec stable

discovery: avoid wrong detection of multiple branch heads (issue6256) This fix the code using obsolescence markers to remove "to be obsoleted" heads during the detection of new head creation from push. The code turned out to not use the branch information at all. This lead changeset from different branch to be detected as new head on unrelated branch. The code fix is actually quite simple. New tests have been added to covers these cases. Differential Revision: https://phab.mercurial-scm.org/D8259
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 06 Mar 2020 23:27:28 +0100
parents 65d6770273c8
children a08bbdf839ae b561f3a68e41
line wrap: on
line diff
--- a/mercurial/discovery.py	Fri Mar 06 00:28:09 2020 +0100
+++ b/mercurial/discovery.py	Fri Mar 06 23:27:28 2020 +0100
@@ -498,7 +498,6 @@
     # define various utilities and containers
     repo = pushop.repo
     unfi = repo.unfiltered()
-    tonode = unfi.changelog.node
     torev = unfi.changelog.index.get_rev
     public = phases.public
     getphase = unfi._phasecache.phase
@@ -530,6 +529,7 @@
     # actually process branch replacement
     while localcandidate:
         nh = localcandidate.pop()
+        current_branch = unfi[nh].branch()
         # run this check early to skip the evaluation of the whole branch
         if torev(nh) in futurecommon or ispublic(torev(nh)):
             newhs.add(nh)
@@ -540,7 +540,12 @@
         branchrevs = unfi.revs(
             b'only(%n, (%ln+%ln))', nh, localcandidate, newhs
         )
-        branchnodes = [tonode(r) for r in branchrevs]
+
+        branchnodes = []
+        for r in branchrevs:
+            c = unfi[r]
+            if c.branch() == current_branch:
+                branchnodes.append(c.node())
 
         # The branch won't be hidden on the remote if
         # * any part of it is public,