changeset 5426:86736040b0ec

topic: 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:28 +0800
parents 2c5e4339538a
children 5b1011a5c824
files hgext3rd/topic/compat.py hgext3rd/topic/stack.py hgext3rd/topic/topicmap.py
diffstat 3 files changed, 14 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/topic/compat.py	Tue Jul 21 11:59:10 2020 +0800
+++ b/hgext3rd/topic/compat.py	Tue Jul 21 11:59:28 2020 +0800
@@ -38,3 +38,11 @@
     if util.safehasattr(cl.index, 'get_rev'):
         return cl.index.get_rev
     return cl.nodemap.get
+
+# 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]
+    )
--- a/hgext3rd/topic/stack.py	Tue Jul 21 11:59:10 2020 +0800
+++ b/hgext3rd/topic/stack.py	Tue Jul 21 11:59:28 2020 +0800
@@ -44,10 +44,10 @@
     this area.
     """
     phasesets = repo._phasecache._phasesets
-    if not phasesets or None in phasesets[phases.draft:]:
+    if not phasesets:
         return repo.revs(b'(not public()) - obsolete()')
 
-    result = set.union(*phasesets[phases.draft:])
+    result = set.union(*[phasesets[phase] for phase in phases.trackedphases])
     result -= obsolete.getrevs(repo, b'obsolete')
     return result
 
--- a/hgext3rd/topic/topicmap.py	Tue Jul 21 11:59:10 2020 +0800
+++ b/hgext3rd/topic/topicmap.py	Tue Jul 21 11:59:28 2020 +0800
@@ -71,11 +71,10 @@
     cl = repo.changelog
     fr = cl.filteredrevs
     getrev = compat.getgetrev(cl)
-    for roots in repo._phasecache.phaseroots[1:]:
-        for n in roots:
-            r = getrev(n)
-            if r not in fr and r < maxrev:
-                revs.add(r)
+    for n in compat.nonpublicphaseroots(repo):
+        r = getrev(n)
+        if r not in fr and r < maxrev:
+            revs.add(r)
     key = nullid
     revs = sorted(revs)
     if revs: