comparison mercurial/scmutil.py @ 52695:b7afc38468bd

branching: merge stable into default
author Rapha?l Gom?s <rgomes@octobus.net>
date Thu, 16 Jan 2025 17:18:16 +0100
parents b3e68fd7864b 1fef0d25dcde
children e52dc683bf6b
comparison
equal deleted inserted replaced
52694:bbbb12632607 52695:b7afc38468bd
2496 2496
2497 2497
2498 RESOURCE_HIGH: int = 3 2498 RESOURCE_HIGH: int = 3
2499 RESOURCE_MEDIUM: int = 2 2499 RESOURCE_MEDIUM: int = 2
2500 RESOURCE_LOW: int = 1 2500 RESOURCE_LOW: int = 1
2501 RESOURCE_DEFAULT: int = 0
2502 2501
2503 RESOURCE_MAPPING: Dict[bytes, int] = { 2502 RESOURCE_MAPPING: Dict[bytes, int] = {
2504 b'default': RESOURCE_DEFAULT,
2505 b'low': RESOURCE_LOW, 2503 b'low': RESOURCE_LOW,
2506 b'medium': RESOURCE_MEDIUM, 2504 b'medium': RESOURCE_MEDIUM,
2507 b'high': RESOURCE_HIGH, 2505 b'high': RESOURCE_HIGH,
2508 } 2506 }
2509 2507
2514 ui: uimod.ui, dimension: Optional[bytes] = None 2512 ui: uimod.ui, dimension: Optional[bytes] = None
2515 ) -> int: 2513 ) -> int:
2516 """return the resource profile for a dimension 2514 """return the resource profile for a dimension
2517 2515
2518 If no dimension is specified, the generic value is returned""" 2516 If no dimension is specified, the generic value is returned"""
2519 generic_name = ui.config(b'usage', b'resources') 2517
2520 value = RESOURCE_MAPPING.get(generic_name, RESOURCE_DEFAULT) 2518 def config(section, name):
2521 if value == RESOURCE_DEFAULT: 2519 value_name = ui.config(section, name, default=b'default')
2522 value = DEFAULT_RESOURCE 2520 return RESOURCE_MAPPING.get(value_name)
2521
2523 if dimension is not None: 2522 if dimension is not None:
2524 sub_name = ui.config(b'usage', b'resources.%s' % dimension) 2523 value = config(b'usage', b'resources.%s' % dimension)
2525 sub_value = RESOURCE_MAPPING.get(sub_name, RESOURCE_DEFAULT) 2524 if value is not None:
2526 if sub_value != RESOURCE_DEFAULT: 2525 return value
2527 value = sub_value 2526 value = config(b'usage', b'resources')
2528 return value 2527 if value is not None:
2528 return value
2529 return DEFAULT_RESOURCE