diff --git a/mercurial/configitems.toml b/mercurial/configitems.toml --- a/mercurial/configitems.toml +++ b/mercurial/configitems.toml @@ -2501,6 +2501,64 @@ Currently recognised values are: """ [[items]] +section = "usage" +name = "resources" +default = "default" +documentation = """How aggressive Mercurial can be with resource usage: + +Currently recognised values are: +- default: the default value currently is equivalent to medium, +- high: allows for higher cpu, memory and disk-space usage to improve the performance of some operations. +- medium: aims at a moderate resource usage, +- low: reduces resources usage when possible, decreasing overall performance. + +For finer configuration, see also `usage.resources.cpu`, +`usage.resources.disk` and `usage.resources.memory`. +""" + +[[items]] +section = "usage" +name = "resources.cpu" +default = "default" +documentation = """How aggressive Mercurial can be in terms of cpu usage: + +Currently recognised values are: +- default: the default value, inherits the value from `usage.resources`, +- high: allows for more aggressive cpu usage, improving storage quality and + the performance of some operations at the expense of machine load +- medium: aims at a moderate cpu usage, +- low: reduces cpu usage when possible, potentially at the expense of + slower operations, increased storage and exchange payload. + +""" + +[[items]] +section = "usage" +name = "resources.disk" +default = "default" +documentation = """How aggressive Mercurial can be in terms of disk usage: + +Currently recognised values are: +- default: the default value, inherits the value from `usage.resources`, +- high: allows for more disk space usage where it can improve the performance, +- medium: aims at a moderate disk usage, +- low: reduces disk usage when possible, decreasing performance in some occasion. +""" + +[[items]] +section = "usage" +name = "resources.memory" +default = "default" +documentation = """How aggressive Mercurial can be in terms of memory usage: + +Currently recognised values are: +- default: the default value, inherits the value from `usage.resources`, +- high: allows for more aggressive memory usage to improve overall performance, +- medium: aims at a moderate memory usage, +- low: reduces memory usage when possible at the cost of overall performance. +""" + +[[items]] section = "verify" name = "skipflags" default = 0 diff --git a/mercurial/helptext/config.txt b/mercurial/helptext/config.txt --- a/mercurial/helptext/config.txt +++ b/mercurial/helptext/config.txt @@ -3005,6 +3005,52 @@ User interface controls. Currently recognised values are: - default: an all purpose repository +``resources`` + How aggressive Mercurial can be with resource usage: + + Currently recognised values are: + - default: the default value currently is equivalent to medium, + - high: allows for higher cpu, memory and disk-space usage to improve + performance of some operations. + - medium: aims at a moderate resource usage, + - low: reduces resources usage when possible, decreasing overall + performance. + + For finer configuration, see also `usage.resources.cpu`, + `usage.resources.disk` and `usage.resources.memory`. + +``resources.cpu`` + How aggressive Mercurial can be in terms of cpu usage: + + Currently recognised values are: + - default: the default value, inherits the value from `usage.resources`, + - high: allows for more aggressive cpu usage, improving storage quality and + the performance of some operations at the expense of machine load + - medium: aims at a moderate cpu usage, + - low: reduces cpu usage when possible, potentially at the expense of + slower operations, increased storage and exchange payload. + +``resources.disk`` + How aggressive Mercurial can be in terms of disk usage: + + Currently recognised values are: + - default: the default value, inherits the value from `usage.resources`, + - high: allows for more disk space usage where it can improve performance, + - medium: aims at a moderate disk usage, + - low: reduces disk usage when possible, decreasing performance in some + occasion. + +``resources.memory`` + How aggressive Mercurial can be in terms of memory usage: + + Currently recognised values are: + - default: the default value, inherits the value from `usage.resources`, + - high: allows for more aggressive memory usage to improve overall + performance, + - medium: aims at a moderate memory usage, + - low: reduces memory usage when possible at the cost of overall + performance. + ``command-templates`` --------------------- diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py --- a/mercurial/scmutil.py +++ b/mercurial/scmutil.py @@ -2325,3 +2325,34 @@ def ismember(ui, username, userlist): schemes. """ return userlist == [b'*'] or username in userlist + + +RESOURCE_HIGH = 3 +RESOURCE_MEDIUM = 2 +RESOURCE_LOW = 1 +RESOURCE_DEFAULT = 0 + +RESOURCE_MAPPING = { + b'default': RESOURCE_DEFAULT, + b'low': RESOURCE_LOW, + b'medium': RESOURCE_MEDIUM, + b'high': RESOURCE_HIGH, +} + +DEFAULT_RESOURCE = RESOURCE_MEDIUM + + +def get_resource_profile(ui, dimension=None): + """return the resource profile for a dimension + + If no dimension is specified, the generic value is returned""" + generic_name = ui.config(b'usage', b'resources') + value = RESOURCE_MAPPING.get(generic_name, RESOURCE_DEFAULT) + if value == RESOURCE_DEFAULT: + value = DEFAULT_RESOURCE + if dimension is not None: + sub_name = ui.config(b'usage', b'resources.%s' % dimension) + sub_value = RESOURCE_MAPPING.get(sub_name, RESOURCE_DEFAULT) + if sub_value != RESOURCE_DEFAULT: + value = sub_value + return value