changeset 5428:3214dc282085 stable

serverminitopic: compatibility with sparse phaseroots and phasesets in 5.5 See also: https://phab.mercurial-scm.org/D8694 and its stack.
author Joerg Sonnenberger <joerg@bec.de>
date Tue, 21 Jul 2020 11:59:10 +0800
parents 1b5afe8bb26a
children e4c7d4a03de7
files hgext3rd/serverminitopic.py
diffstat 1 files changed, 12 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/serverminitopic.py	Sat Jun 27 22:46:08 2020 +0800
+++ b/hgext3rd/serverminitopic.py	Tue Jul 21 11:59:10 2020 +0800
@@ -33,6 +33,14 @@
                default=False,
     )
 
+# hg <= 5.4 (e2d17974a869)
+def nonpublicphaseroots(repo):
+    if util.safehasattr(repo._phasecache, 'nonpublicphaseroots'):
+        return repo._phasecache.nonpublicphaseroots(repo)
+    return set().union(
+        *[roots for roots in repo._phasecache.phaseroots[1:] if roots]
+    )
+
 def hasminitopic(repo):
     """true if minitopic is enabled on the repository
 
@@ -106,11 +114,10 @@
     cl = repo.changelog
     fr = cl.filteredrevs
     nm = cl.nodemap
-    for roots in repo._phasecache.phaseroots[1:]:
-        for n in roots:
-            r = nm.get(n)
-            if r not in fr and r < maxrev:
-                revs.add(r)
+    for n in nonpublicphaseroots(repo):
+        r = nm.get(n)
+        if r not in fr and r < maxrev:
+            revs.add(r)
     key = node.nullid
     revs = sorted(revs)
     if revs: