changeset 5425:2c5e4339538a

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 ca76e63e76dc
children 86736040b0ec
files hgext3rd/serverminitopic.py
diffstat 1 files changed, 12 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/serverminitopic.py	Fri Jul 17 10:00:43 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: