comparison hgext3rd/serverminitopic.py @ 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 a4d081923c81
children ad7c9c0b7a63
comparison
equal deleted inserted replaced
5424:ca76e63e76dc 5425:2c5e4339538a
31 configitem = registrar.configitem(configtable) 31 configitem = registrar.configitem(configtable)
32 configitem(b'experimental', b'server-mini-topic', 32 configitem(b'experimental', b'server-mini-topic',
33 default=False, 33 default=False,
34 ) 34 )
35 35
36 # hg <= 5.4 (e2d17974a869)
37 def nonpublicphaseroots(repo):
38 if util.safehasattr(repo._phasecache, 'nonpublicphaseroots'):
39 return repo._phasecache.nonpublicphaseroots(repo)
40 return set().union(
41 *[roots for roots in repo._phasecache.phaseroots[1:] if roots]
42 )
43
36 def hasminitopic(repo): 44 def hasminitopic(repo):
37 """true if minitopic is enabled on the repository 45 """true if minitopic is enabled on the repository
38 46
39 (The value is cached on the repository) 47 (The value is cached on the repository)
40 """ 48 """
104 """uniq ID for a phase matching a set of rev""" 112 """uniq ID for a phase matching a set of rev"""
105 revs = set() 113 revs = set()
106 cl = repo.changelog 114 cl = repo.changelog
107 fr = cl.filteredrevs 115 fr = cl.filteredrevs
108 nm = cl.nodemap 116 nm = cl.nodemap
109 for roots in repo._phasecache.phaseroots[1:]: 117 for n in nonpublicphaseroots(repo):
110 for n in roots: 118 r = nm.get(n)
111 r = nm.get(n) 119 if r not in fr and r < maxrev:
112 if r not in fr and r < maxrev: 120 revs.add(r)
113 revs.add(r)
114 key = node.nullid 121 key = node.nullid
115 revs = sorted(revs) 122 revs = sorted(revs)
116 if revs: 123 if revs:
117 s = hashlib.sha1() 124 s = hashlib.sha1()
118 for rev in revs: 125 for rev in revs: