mercurial/discovery.py
changeset 44470 a08bbdf839ae
parent 44452 9d2b2df2c2ba
parent 44450 7d5455b988ec
child 44729 26ce8e751503
--- a/mercurial/discovery.py	Mon Mar 09 05:19:02 2020 +0100
+++ b/mercurial/discovery.py	Mon Mar 09 10:18:40 2020 -0700
@@ -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,