comparison mercurial/scmutil.py @ 51280:83c6dceeb10d

usage: add configuration option to adjust resources usage They currently do nothing, but this open the way to actually use them.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 09 Oct 2023 15:12:16 +0200
parents fd1aa5e18f75
children 4bfae99c4021
comparison
equal deleted inserted replaced
51279:d737bc8a36c9 51280:83c6dceeb10d
2323 If userlist has a single '*' member, all users are considered members. 2323 If userlist has a single '*' member, all users are considered members.
2324 Can be overridden by extensions to provide more complex authorization 2324 Can be overridden by extensions to provide more complex authorization
2325 schemes. 2325 schemes.
2326 """ 2326 """
2327 return userlist == [b'*'] or username in userlist 2327 return userlist == [b'*'] or username in userlist
2328
2329
2330 RESOURCE_HIGH = 3
2331 RESOURCE_MEDIUM = 2
2332 RESOURCE_LOW = 1
2333 RESOURCE_DEFAULT = 0
2334
2335 RESOURCE_MAPPING = {
2336 b'default': RESOURCE_DEFAULT,
2337 b'low': RESOURCE_LOW,
2338 b'medium': RESOURCE_MEDIUM,
2339 b'high': RESOURCE_HIGH,
2340 }
2341
2342 DEFAULT_RESOURCE = RESOURCE_MEDIUM
2343
2344
2345 def get_resource_profile(ui, dimension=None):
2346 """return the resource profile for a dimension
2347
2348 If no dimension is specified, the generic value is returned"""
2349 generic_name = ui.config(b'usage', b'resources')
2350 value = RESOURCE_MAPPING.get(generic_name, RESOURCE_DEFAULT)
2351 if value == RESOURCE_DEFAULT:
2352 value = DEFAULT_RESOURCE
2353 if dimension is not None:
2354 sub_name = ui.config(b'usage', b'resources.%s' % dimension)
2355 sub_value = RESOURCE_MAPPING.get(sub_name, RESOURCE_DEFAULT)
2356 if sub_value != RESOURCE_DEFAULT:
2357 value = sub_value
2358 return value