filteredhash: move the hashing in its own function
authorPierre-Yves David <pierre-yves.david@octobus.net>
Tue, 05 Mar 2024 15:21:18 +0100
changeset 51524 4bfae99c4021
parent 51523 ef369d16965d
child 51525 530b4cffd6a6
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.
mercurial/scmutil.py
--- 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"""