[Request] [+ ] D12156: obsolete: always return frozensets from obsolete.getrevs()
av6 (Anton Shestakov)
phabricator at mercurial-scm.org
Wed Feb 9 15:44:25 UTC 2022
av6 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
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.
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D12156
AFFECTED FILES
mercurial/obsolete.py
CHANGE DETAILS
diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -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):
To: av6, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20220209/fe5b5542/attachment.html>
More information about the Mercurial-patches
mailing list