diff mercurial/exchange.py @ 45062:72feaeb510b3

clonebundles: optional memory-requirement attribution The new REQUIREDRAM option allows a client to skip bundles it isn't expected to handle well, e.g. without swapping. This allows a fallback path to be provided e.g. using zstd level 10 instead of 22. Differential Revision: https://phab.mercurial-scm.org/D8645
author Joerg Sonnenberger <joerg@bec.de>
date Mon, 22 Jun 2020 00:00:07 +0200
parents bd7b2c8d06cc
children b1e51ef4e536
line wrap: on
line diff
--- a/mercurial/exchange.py	Tue Jun 09 11:22:31 2020 +0200
+++ b/mercurial/exchange.py	Mon Jun 22 00:00:07 2020 +0200
@@ -3025,6 +3025,23 @@
             )
             continue
 
+        if b'REQUIREDRAM' in entry:
+            try:
+                requiredram = util.sizetoint(entry[b'REQUIREDRAM'])
+            except error.ParseError:
+                repo.ui.debug(
+                    b'filtering %s due to a bad REQUIREDRAM attribute\n'
+                    % entry[b'URL']
+                )
+                continue
+            actualram = repo.ui.estimatememory()
+            if actualram is not None and actualram * 0.66 < requiredram:
+                repo.ui.debug(
+                    b'filtering %s as it needs more than 2/3 of system memory\n'
+                    % entry[b'URL']
+                )
+                continue
+
         newentries.append(entry)
 
     return newentries