diff mercurial/discovery.py @ 48688:053a5bf508da

discovery: port _postprocessobsolete() changes from evolve, add tests Let's make this function obsolescence-aware as well. Now we check that revisions are not obsolete first, and only then check that they are going to be common after exchange. The tests make sure that rewriting changesets doesn't confuse head computation. They rely on experimental.single-head-per-branch feature to show that remote correctly sees the expected result (i.e. either aborts the push or allows it to succeed). They are ported from evolve as well. Differential Revision: https://phab.mercurial-scm.org/D12098
author Anton Shestakov <av6@dwimlabs.net>
date Tue, 04 Jan 2022 23:38:39 +0300
parents 61fe7e17f21b
children 6000f5b25c9b
line wrap: on
line diff
--- a/mercurial/discovery.py	Fri Jan 07 11:53:23 2022 +0300
+++ b/mercurial/discovery.py	Tue Jan 04 23:38:39 2022 +0300
@@ -19,6 +19,7 @@
     bookmarks,
     branchmap,
     error,
+    obsolete,
     phases,
     pycompat,
     scmutil,
@@ -545,12 +546,16 @@
     if len(localcandidate) == 1:
         return unknownheads | set(candidate_newhs), set()
 
+    obsrevs = obsolete.getrevs(unfi, b'obsolete')
+    futurenonobsolete = frozenset(futurecommon) - obsrevs
+
     # actually process branch replacement
     while localcandidate:
         nh = localcandidate.pop()
+        r = torev(nh)
         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)):
+        if ispublic(r) or r not in obsrevs:
             newhs.add(nh)
             continue
 
@@ -572,7 +577,7 @@
         # * if we have no markers to push to obsolete it.
         if (
             any(ispublic(r) for r in branchrevs)
-            or any(torev(n) in futurecommon for n in branchnodes)
+            or any(torev(n) in futurenonobsolete for n in branchnodes)
             or any(not hasoutmarker(n) for n in branchnodes)
         ):
             newhs.add(nh)