3472
3472
class GlobalStack(_CompatibleStack):
3473
"""Global options only stack."""
3473
"""Global options only stack.
3475
The following sections are queried:
3477
* command-line overrides,
3479
* the 'DEFAULT' section in bazaar.conf
3481
This stack will use the ``DEFAULT`` section in bazaar.conf as its
3475
3485
def __init__(self):
3477
3486
gstore = GlobalStore()
3478
3487
super(GlobalStack, self).__init__(
3479
[self._get_overrides, NameMatcher(gstore, 'DEFAULT').get_sections],
3488
[self._get_overrides,
3489
NameMatcher(gstore, 'DEFAULT').get_sections],
3480
3490
gstore, mutable_section_id='DEFAULT')
3483
3493
class LocationStack(_CompatibleStack):
3484
"""Per-location options falling back to global options stack."""
3494
"""Per-location options falling back to global options stack.
3497
The following sections are queried:
3499
* command-line overrides,
3501
* the sections matching ``location`` in ``locations.conf``, the order being
3502
defined by the number of path components in the section glob, higher
3503
numbers first (from most specific section to most generic).
3505
* the 'DEFAULT' section in bazaar.conf
3507
This stack will use the ``location`` section in locations.conf as its
3486
3511
def __init__(self, location):
3487
3512
"""Make a new stack for a location and global configuration.
3490
3515
lstore = LocationStore()
3491
3516
if location.startswith('file://'):
3492
3517
location = urlutils.local_path_from_url(location)
3493
matcher = LocationMatcher(lstore, location)
3494
3518
gstore = GlobalStore()
3495
3519
super(LocationStack, self).__init__(
3496
3520
[self._get_overrides,
3497
matcher.get_sections, NameMatcher(gstore, 'DEFAULT').get_sections],
3521
LocationMatcher(lstore, location).get_sections,
3522
NameMatcher(gstore, 'DEFAULT').get_sections],
3498
3523
lstore, mutable_section_id=location)
3501
3526
class BranchStack(_CompatibleStack):
3502
"""Per-location options falling back to branch then global options stack."""
3527
"""Per-location options falling back to branch then global options stack.
3529
The following sections are queried:
3531
* command-line overrides,
3533
* the sections matching ``location`` in ``locations.conf``, the order being
3534
defined by the number of path components in the section glob, higher
3535
numbers first (from most specific section to most generic),
3537
* the no-name section in branch.conf,
3539
* the ``DEFAULT`` section in ``bazaar.conf``.
3541
This stack will use the no-name section in ``branch.conf`` as its
3504
3545
def __init__(self, branch):
3546
lstore = LocationStore()
3505
3547
bstore = branch._get_config_store()
3506
lstore = LocationStore()
3507
matcher = LocationMatcher(lstore, branch.base)
3508
3548
gstore = GlobalStore()
3509
3549
super(BranchStack, self).__init__(
3510
3550
[self._get_overrides,
3511
matcher.get_sections, bstore.get_sections,
3551
LocationMatcher(lstore, branch.base).get_sections,
3552
NameMatcher(bstore, None).get_sections,
3512
3553
NameMatcher(gstore, 'DEFAULT').get_sections],
3514
3555
self.branch = branch
3524
3565
def __init__(self, bzrdir):
3525
3566
cstore = bzrdir._get_config_store()
3526
3567
super(RemoteControlStack, self).__init__(
3527
[cstore.get_sections],
3568
[NameMatcher(cstore, None).get_sections],
3529
3570
self.bzrdir = bzrdir
3539
3580
def __init__(self, branch):
3540
3581
bstore = branch._get_config_store()
3541
3582
super(RemoteBranchStack, self).__init__(
3542
[bstore.get_sections],
3583
[NameMatcher(bstore, None).get_sections],
3544
3585
self.branch = branch