filteredhash: move the hashing in its own function
This will help us to reuse this logic in variants of the hashes used for branch
cache validation.
--- a/mercurial/scmutil.py Sun Feb 25 23:31:50 2024 +0100
+++ b/mercurial/scmutil.py Tue Mar 05 15:21:18 2024 +0100
@@ -377,14 +377,19 @@
if not result:
revs = sorted(r for r in cl.filteredrevs | obsrevs if r <= maxrev)
if revs:
- s = hashutil.sha1()
- for rev in revs:
- s.update(b'%d;' % rev)
- result = s.digest()
+ result = _hash_revs(revs)
cl._filteredrevs_hashcache[key] = result
return result
+def _hash_revs(revs):
+ """return a hash from a list of revision numbers"""
+ s = hashutil.sha1()
+ for rev in revs:
+ s.update(b'%d;' % rev)
+ return s.digest()
+
+
def walkrepos(path, followsym=False, seen_dirs=None, recurse=False):
"""yield every hg repository under path, always recursively.
The recurse flag will only control recursion into repo working dirs"""