changeset 51567:530b4cffd6a6

filteredhash: split the computation of revision sets The branch2's filteredhash combines the filtered revisions and the obsolete ones, this will creates issue for implicit reference to heads we want to introduce for the v3 of the branch cache format. So we isolate this logic for alternative use.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 06 Mar 2024 01:43:51 +0100
parents 4bfae99c4021
children a03fa40afd01
files mercurial/scmutil.py
diffstat 1 files changed, 18 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/scmutil.py	Tue Mar 05 15:21:18 2024 +0100
+++ b/mercurial/scmutil.py	Wed Mar 06 01:43:51 2024 +0100
@@ -375,13 +375,30 @@
 
     result = cl._filteredrevs_hashcache.get(key)
     if not result:
-        revs = sorted(r for r in cl.filteredrevs | obsrevs if r <= maxrev)
+        revs, obs_revs = _filtered_and_obs_revs(repo, maxrev)
+        if needobsolete:
+            revs = revs | obs_revs
+        revs = sorted(revs)
         if revs:
             result = _hash_revs(revs)
             cl._filteredrevs_hashcache[key] = result
     return result
 
 
+def _filtered_and_obs_revs(repo, max_rev):
+    """return the set of filtered and non-filtered obsolete revision"""
+    cl = repo.changelog
+    obs_set = obsolete.getrevs(repo, b'obsolete')
+    filtered_set = cl.filteredrevs
+    if cl.filteredrevs:
+        obs_set = obs_set - cl.filteredrevs
+    if max_rev < (len(cl) - 1):
+        # there might be revision to filter out
+        filtered_set = set(r for r in filtered_set if r <= max_rev)
+        obs_set = set(r for r in obs_set if r <= max_rev)
+    return (filtered_set, obs_set)
+
+
 def _hash_revs(revs):
     """return a hash from a list of revision numbers"""
     s = hashutil.sha1()