Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/ui.py @ 45062:02b17231f6c3
util: provide a helper function to estimate RAM size
For POSIX systems, it uses sysconf. For Windows, it uses the win32 API
directly.
Differential Revision: https://phab.mercurial-scm.org/D8644
author | Joerg Sonnenberger <joerg@bec.de> |
---|---|
date | Tue, 09 Jun 2020 11:22:31 +0200 |
parents | b4b6ff83ed9c |
children | 14ac6a74e7e7 ed84a4d48910 |
comparison
equal
deleted
inserted
replaced
45061:baffdfa5bd1a | 45062:02b17231f6c3 |
---|---|
2117 # just restoring ui.quiet config to the previous value is not enough | 2117 # just restoring ui.quiet config to the previous value is not enough |
2118 # as it does not update ui.quiet class member | 2118 # as it does not update ui.quiet class member |
2119 if (b'ui', b'quiet') in overrides: | 2119 if (b'ui', b'quiet') in overrides: |
2120 self.fixconfig(section=b'ui') | 2120 self.fixconfig(section=b'ui') |
2121 | 2121 |
2122 def estimatememory(self): | |
2123 """Provide an estimate for the available system memory in Bytes. | |
2124 | |
2125 This can be overriden via ui.available-memory. It returns None, if | |
2126 no estimate can be computed. | |
2127 """ | |
2128 value = self.config(b'ui', b'available-memory') | |
2129 if value is not None: | |
2130 try: | |
2131 return util.sizetoint(value) | |
2132 except error.ParseError: | |
2133 raise error.ConfigError( | |
2134 _(b"ui.available-memory value is invalid ('%s')") % value | |
2135 ) | |
2136 return util._estimatememory() | |
2137 | |
2122 | 2138 |
2123 class paths(dict): | 2139 class paths(dict): |
2124 """Represents a collection of paths and their configs. | 2140 """Represents a collection of paths and their configs. |
2125 | 2141 |
2126 Data is initially derived from ui instances and the config files they have | 2142 Data is initially derived from ui instances and the config files they have |