obsolete: always return frozensets from obsolete.getrevs()
getrevs function already returns an empty frozenset when there is no obsstore,
but let's make sure to return a frozenset in any case. This makes it possible
to use the result of this function as a dict key or provide it to hash()
built-in function without any conversions.
Differential Revision: https://phab.mercurial-scm.org/D12156
--- a/mercurial/obsolete.py Wed Jan 26 13:18:48 2022 +0100
+++ b/mercurial/obsolete.py Mon Feb 07 12:25:46 2022 +0300
@@ -940,8 +940,7 @@
getnode = repo.changelog.node
notpublic = _mutablerevs(repo)
isobs = repo.obsstore.successors.__contains__
- obs = {r for r in notpublic if isobs(getnode(r))}
- return obs
+ return frozenset(r for r in notpublic if isobs(getnode(r)))
@cachefor(b'orphan')
@@ -959,14 +958,14 @@
if p in obsolete or p in unstable:
unstable.add(r)
break
- return unstable
+ return frozenset(unstable)
@cachefor(b'suspended')
def _computesuspendedset(repo):
"""the set of obsolete parents with non obsolete descendants"""
suspended = repo.changelog.ancestors(getrevs(repo, b'orphan'))
- return {r for r in getrevs(repo, b'obsolete') if r in suspended}
+ return frozenset(r for r in getrevs(repo, b'obsolete') if r in suspended)
@cachefor(b'extinct')
@@ -998,7 +997,7 @@
# we have a public predecessor
bumped.add(rev)
break # Next draft!
- return bumped
+ return frozenset(bumped)
@cachefor(b'contentdivergent')
@@ -1025,7 +1024,7 @@
divergent.add(rev)
break
toprocess.update(obsstore.predecessors.get(prec, ()))
- return divergent
+ return frozenset(divergent)
def makefoldid(relation, user):