changeset 5429:e4c7d4a03de7 stable

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 3214dc282085
children e320a84b65c1
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: