178
213
def _get_signing_policy(self):
179
214
"""Template method to override signature creation policy."""
218
def expand_options(self, string, env=None):
219
"""Expand option references in the string in the configuration context.
221
:param string: The string containing option to expand.
223
:param env: An option dict defining additional configuration options or
224
overriding existing ones.
226
:returns: The expanded string.
228
return self._expand_options_in_string(string, env)
230
def _expand_options_in_list(self, slist, env=None, _ref_stack=None):
231
"""Expand options in a list of strings in the configuration context.
233
:param slist: A list of strings.
235
:param env: An option dict defining additional configuration options or
236
overriding existing ones.
238
:param _ref_stack: Private list containing the options being
239
expanded to detect loops.
241
:returns: The flatten list of expanded strings.
243
# expand options in each value separately flattening lists
246
value = self._expand_options_in_string(s, env, _ref_stack)
247
if isinstance(value, list):
253
def _expand_options_in_string(self, string, env=None, _ref_stack=None):
254
"""Expand options in the string in the configuration context.
256
:param string: The string to be expanded.
258
:param env: An option dict defining additional configuration options or
259
overriding existing ones.
261
:param _ref_stack: Private list containing the options being
262
expanded to detect loops.
264
:returns: The expanded string.
267
# Not much to expand there
269
if _ref_stack is None:
270
# What references are currently resolved (to detect loops)
272
if self.option_ref_re is None:
273
# We want to match the most embedded reference first (i.e. for
274
# '{{foo}}' we will get '{foo}',
275
# for '{bar{baz}}' we will get '{baz}'
276
self.option_ref_re = re.compile('({[^{}]+})')
278
# We need to iterate until no more refs appear ({{foo}} will need two
279
# iterations for example).
281
raw_chunks = self.option_ref_re.split(result)
282
if len(raw_chunks) == 1:
283
# Shorcut the trivial case: no refs
287
# Split will isolate refs so that every other chunk is a ref
289
for chunk in raw_chunks:
292
# Keep only non-empty strings (or we get bogus empty
293
# slots when a list value is involved).
298
if name in _ref_stack:
299
raise errors.OptionExpansionLoop(string, _ref_stack)
300
_ref_stack.append(name)
301
value = self._expand_option(name, env, _ref_stack)
303
raise errors.ExpandingUnknownOption(name, string)
304
if isinstance(value, list):
312
# Once a list appears as the result of an expansion, all
313
# callers will get a list result. This allows a consistent
314
# behavior even when some options in the expansion chain
315
# defined as strings (no comma in their value) but their
316
# expanded value is a list.
317
return self._expand_options_in_list(chunks, env, _ref_stack)
319
result = ''.join(chunks)
322
def _expand_option(self, name, env, _ref_stack):
323
if env is not None and name in env:
324
# Special case, values provided in env takes precedence over
328
# FIXME: This is a limited implementation, what we really need is a
329
# way to query the bzr config for the value of an option,
330
# respecting the scope rules (That is, once we implement fallback
331
# configs, getting the option value should restart from the top
332
# config, not the current one) -- vila 20101222
333
value = self.get_user_option(name, expand=False)
334
if isinstance(value, list):
335
value = self._expand_options_in_list(value, env, _ref_stack)
337
value = self._expand_options_in_string(value, env, _ref_stack)
181
340
def _get_user_option(self, option_name):
182
341
"""Template method to provide a user option."""
185
def get_user_option(self, option_name):
186
"""Get a generic option - no special process, no default."""
187
return self._get_user_option(option_name)
189
def get_user_option_as_bool(self, option_name):
344
def get_user_option(self, option_name, expand=None):
345
"""Get a generic option - no special process, no default.
347
:param option_name: The queried option.
349
:param expand: Whether options references should be expanded.
351
:returns: The value of the option.
354
expand = _get_expand_default_value()
355
value = self._get_user_option(option_name)
357
if isinstance(value, list):
358
value = self._expand_options_in_list(value)
359
elif isinstance(value, dict):
360
trace.warning('Cannot expand "%s":'
361
' Dicts do not support option expansion'
364
value = self._expand_options_in_string(value)
367
def get_user_option_as_bool(self, option_name, expand=None):
190
368
"""Get a generic option as a boolean - no special process, no default.
192
370
:return None if the option doesn't exist or its value can't be
193
371
interpreted as a boolean. Returns True or False otherwise.
195
s = self._get_user_option(option_name)
373
s = self.get_user_option(option_name, expand=expand)
197
375
# The option doesn't exist
1517
2076
return StringIO()
1519
2078
def _get_configobj(self):
1520
return ConfigObj(self._get_config_file(), encoding='utf-8')
2079
f = self._get_config_file()
2081
return ConfigObj(f, encoding='utf-8')
1522
2085
def _set_configobj(self, configobj):
1523
2086
out_file = StringIO()
1524
2087
configobj.write(out_file)
1525
2088
out_file.seek(0)
1526
2089
self._transport.put_file(self._filename, out_file)
2092
class Option(object):
2093
"""An option definition.
2095
The option *values* are stored in config files and found in sections.
2097
Here we define various properties about the option itself, its default
2098
value, in which config files it can be stored, etc (TBC).
2101
def __init__(self, name, default=None):
2103
self.default = default
2105
def get_default(self):
2111
option_registry = registry.Registry()
2114
# FIXME: Delete the following dummy option once we register the real ones
2116
option_registry.register('foo', Option('foo'), help='Dummy option')
2119
class Section(object):
2120
"""A section defines a dict of option name => value.
2122
This is merely a read-only dict which can add some knowledge about the
2123
options. It is *not* a python dict object though and doesn't try to mimic
2127
def __init__(self, section_id, options):
2128
self.id = section_id
2129
# We re-use the dict-like object received
2130
self.options = options
2132
def get(self, name, default=None):
2133
return self.options.get(name, default)
2136
# Mostly for debugging use
2137
return "<config.%s id=%s>" % (self.__class__.__name__, self.id)
2140
_NewlyCreatedOption = object()
2141
"""Was the option created during the MutableSection lifetime"""
2144
class MutableSection(Section):
2145
"""A section allowing changes and keeping track of the original values."""
2147
def __init__(self, section_id, options):
2148
super(MutableSection, self).__init__(section_id, options)
2151
def set(self, name, value):
2152
if name not in self.options:
2153
# This is a new option
2154
self.orig[name] = _NewlyCreatedOption
2155
elif name not in self.orig:
2156
self.orig[name] = self.get(name, None)
2157
self.options[name] = value
2159
def remove(self, name):
2160
if name not in self.orig:
2161
self.orig[name] = self.get(name, None)
2162
del self.options[name]
2165
class Store(object):
2166
"""Abstract interface to persistent storage for configuration options."""
2168
readonly_section_class = Section
2169
mutable_section_class = MutableSection
2171
def is_loaded(self):
2172
"""Returns True if the Store has been loaded.
2174
This is used to implement lazy loading and ensure the persistent
2175
storage is queried only when needed.
2177
raise NotImplementedError(self.is_loaded)
2180
"""Loads the Store from persistent storage."""
2181
raise NotImplementedError(self.load)
2183
def _load_from_string(self, str_or_unicode):
2184
"""Create a store from a string in configobj syntax.
2186
:param str_or_unicode: A string representing the file content. This will
2187
be encoded to suit store needs internally.
2189
This is for tests and should not be used in production unless a
2190
convincing use case can be demonstrated :)
2192
raise NotImplementedError(self._load_from_string)
2195
"""Saves the Store to persistent storage."""
2196
raise NotImplementedError(self.save)
2198
def external_url(self):
2199
raise NotImplementedError(self.external_url)
2201
def get_sections(self):
2202
"""Returns an ordered iterable of existing sections.
2204
:returns: An iterable of (name, dict).
2206
raise NotImplementedError(self.get_sections)
2208
def get_mutable_section(self, section_name=None):
2209
"""Returns the specified mutable section.
2211
:param section_name: The section identifier
2213
raise NotImplementedError(self.get_mutable_section)
2216
# Mostly for debugging use
2217
return "<config.%s(%s)>" % (self.__class__.__name__,
2218
self.external_url())
2221
class IniFileStore(Store):
2222
"""A config Store using ConfigObj for storage.
2224
:ivar transport: The transport object where the config file is located.
2226
:ivar file_name: The config file basename in the transport directory.
2228
:ivar _config_obj: Private member to hold the ConfigObj instance used to
2229
serialize/deserialize the config file.
2232
def __init__(self, transport, file_name):
2233
"""A config Store using ConfigObj for storage.
2235
:param transport: The transport object where the config file is located.
2237
:param file_name: The config file basename in the transport directory.
2239
super(IniFileStore, self).__init__()
2240
self.transport = transport
2241
self.file_name = file_name
2242
self._config_obj = None
2244
def is_loaded(self):
2245
return self._config_obj != None
2248
"""Load the store from the associated file."""
2249
if self.is_loaded():
2251
content = self.transport.get_bytes(self.file_name)
2252
self._load_from_string(content)
2254
def _load_from_string(self, str_or_unicode):
2255
"""Create a config store from a string.
2257
:param str_or_unicode: A string representing the file content. This will
2258
be utf-8 encoded internally.
2260
This is for tests and should not be used in production unless a
2261
convincing use case can be demonstrated :)
2263
if self.is_loaded():
2264
raise AssertionError('Already loaded: %r' % (self._config_obj,))
2265
co_input = StringIO(str_or_unicode.encode('utf-8'))
2267
# The config files are always stored utf8-encoded
2268
self._config_obj = ConfigObj(co_input, encoding='utf-8')
2269
except configobj.ConfigObjError, e:
2270
self._config_obj = None
2271
raise errors.ParseConfigError(e.errors, self.external_url())
2274
if not self.is_loaded():
2278
self._config_obj.write(out)
2279
self.transport.put_bytes(self.file_name, out.getvalue())
2281
def external_url(self):
2282
# FIXME: external_url should really accepts an optional relpath
2283
# parameter (bug #750169) :-/ -- vila 2011-04-04
2284
# The following will do in the interim but maybe we don't want to
2285
# expose a path here but rather a config ID and its associated
2286
# object </hand wawe>.
2287
return urlutils.join(self.transport.external_url(), self.file_name)
2289
def get_sections(self):
2290
"""Get the configobj section in the file order.
2292
:returns: An iterable of (name, dict).
2294
# We need a loaded store
2297
except errors.NoSuchFile:
2298
# If the file doesn't exist, there is no sections
2300
cobj = self._config_obj
2302
yield self.readonly_section_class(None, cobj)
2303
for section_name in cobj.sections:
2304
yield self.readonly_section_class(section_name, cobj[section_name])
2306
def get_mutable_section(self, section_name=None):
2307
# We need a loaded store
2310
except errors.NoSuchFile:
2311
# The file doesn't exist, let's pretend it was empty
2312
self._load_from_string('')
2313
if section_name is None:
2314
section = self._config_obj
2316
section = self._config_obj.setdefault(section_name, {})
2317
return self.mutable_section_class(section_name, section)
2320
# Note that LockableConfigObjStore inherits from ConfigObjStore because we need
2321
# unlockable stores for use with objects that can already ensure the locking
2322
# (think branches). If different stores (not based on ConfigObj) are created,
2323
# they may face the same issue.
2326
class LockableIniFileStore(IniFileStore):
2327
"""A ConfigObjStore using locks on save to ensure store integrity."""
2329
def __init__(self, transport, file_name, lock_dir_name=None):
2330
"""A config Store using ConfigObj for storage.
2332
:param transport: The transport object where the config file is located.
2334
:param file_name: The config file basename in the transport directory.
2336
if lock_dir_name is None:
2337
lock_dir_name = 'lock'
2338
self.lock_dir_name = lock_dir_name
2339
super(LockableIniFileStore, self).__init__(transport, file_name)
2340
self._lock = lockdir.LockDir(self.transport, self.lock_dir_name)
2342
def lock_write(self, token=None):
2343
"""Takes a write lock in the directory containing the config file.
2345
If the directory doesn't exist it is created.
2347
# FIXME: This doesn't check the ownership of the created directories as
2348
# ensure_config_dir_exists does. It should if the transport is local
2349
# -- vila 2011-04-06
2350
self.transport.create_prefix()
2351
return self._lock.lock_write(token)
2356
def break_lock(self):
2357
self._lock.break_lock()
2361
# We need to be able to override the undecorated implementation
2365
super(LockableIniFileStore, self).save()
2368
# FIXME: global, bazaar, shouldn't that be 'user' instead or even
2369
# 'user_defaults' as opposed to 'user_overrides', 'system_defaults'
2370
# (/etc/bzr/bazaar.conf) and 'system_overrides' ? -- vila 2011-04-05
2372
# FIXME: Moreover, we shouldn't need classes for these stores either, factory
2373
# functions or a registry will make it easier and clearer for tests, focusing
2374
# on the relevant parts of the API that needs testing -- vila 20110503 (based
2375
# on a poolie's remark)
2376
class GlobalStore(LockableIniFileStore):
2378
def __init__(self, possible_transports=None):
2379
t = transport.get_transport(config_dir(),
2380
possible_transports=possible_transports)
2381
super(GlobalStore, self).__init__(t, 'bazaar.conf')
2384
class LocationStore(LockableIniFileStore):
2386
def __init__(self, possible_transports=None):
2387
t = transport.get_transport(config_dir(),
2388
possible_transports=possible_transports)
2389
super(LocationStore, self).__init__(t, 'locations.conf')
2392
# FIXME: We should rely on the branch itself to be locked (possibly checking
2393
# that even) but we shouldn't lock ourselves. This may make `bzr config` is
2394
# abit trickier though but I punt for now -- vila 20110512
2395
class BranchStore(LockableIniFileStore):
2397
def __init__(self, branch):
2398
super(BranchStore, self).__init__(branch.control_transport,
2401
class SectionMatcher(object):
2402
"""Select sections into a given Store.
2404
This intended to be used to postpone getting an iterable of sections from a
2408
def __init__(self, store):
2411
def get_sections(self):
2412
# This is where we require loading the store so we can see all defined
2414
sections = self.store.get_sections()
2415
# Walk the revisions in the order provided
2420
def match(self, secion):
2421
raise NotImplementedError(self.match)
2424
class LocationSection(Section):
2426
def __init__(self, section, length, extra_path):
2427
super(LocationSection, self).__init__(section.id, section.options)
2428
self.length = length
2429
self.extra_path = extra_path
2431
def get(self, name, default=None):
2432
value = super(LocationSection, self).get(name, default)
2433
if value is not None:
2434
policy_name = self.get(name + ':policy', None)
2435
policy = _policy_value.get(policy_name, POLICY_NONE)
2436
if policy == POLICY_APPENDPATH:
2437
value = urlutils.join(value, self.extra_path)
2441
class LocationMatcher(SectionMatcher):
2443
def __init__(self, store, location):
2444
super(LocationMatcher, self).__init__(store)
2445
if location.startswith('file://'):
2446
location = urlutils.local_path_from_url(location)
2447
self.location = location
2449
def _get_matching_sections(self):
2450
"""Get all sections matching ``location``."""
2451
# We slightly diverge from LocalConfig here by allowing the no-name
2452
# section as the most generic one and the lower priority.
2453
no_name_section = None
2455
# Filter out the no_name_section so _iter_for_location_by_parts can be
2456
# used (it assumes all sections have a name).
2457
for section in self.store.get_sections():
2458
if section.id is None:
2459
no_name_section = section
2461
sections.append(section)
2462
# Unfortunately _iter_for_location_by_parts deals with section names so
2463
# we have to resync.
2464
filtered_sections = _iter_for_location_by_parts(
2465
[s.id for s in sections], self.location)
2466
iter_sections = iter(sections)
2467
matching_sections = []
2468
if no_name_section is not None:
2469
matching_sections.append(
2470
LocationSection(no_name_section, 0, self.location))
2471
for section_id, extra_path, length in filtered_sections:
2472
# a section id is unique for a given store so it's safe to iterate
2474
section = iter_sections.next()
2475
if section_id == section.id:
2476
matching_sections.append(
2477
LocationSection(section, length, extra_path))
2478
return matching_sections
2480
def get_sections(self):
2481
# Override the default implementation as we want to change the order
2482
matching_sections = self._get_matching_sections()
2483
# We want the longest (aka more specific) locations first
2484
sections = sorted(matching_sections,
2485
key=lambda section: (section.length, section.id),
2487
# Sections mentioning 'ignore_parents' restrict the selection
2488
for section in sections:
2489
# FIXME: We really want to use as_bool below -- vila 2011-04-07
2490
ignore = section.get('ignore_parents', None)
2491
if ignore is not None:
2492
ignore = ui.bool_from_string(ignore)
2495
# Finally, we have a valid section
2499
class Stack(object):
2500
"""A stack of configurations where an option can be defined"""
2502
def __init__(self, sections_def, store=None, mutable_section_name=None):
2503
"""Creates a stack of sections with an optional store for changes.
2505
:param sections_def: A list of Section or callables that returns an
2506
iterable of Section. This defines the Sections for the Stack and
2507
can be called repeatedly if needed.
2509
:param store: The optional Store where modifications will be
2510
recorded. If none is specified, no modifications can be done.
2512
:param mutable_section_name: The name of the MutableSection where
2513
changes are recorded. This requires the ``store`` parameter to be
2516
self.sections_def = sections_def
2518
self.mutable_section_name = mutable_section_name
2520
def get(self, name):
2521
"""Return the *first* option value found in the sections.
2523
This is where we guarantee that sections coming from Store are loaded
2524
lazily: the loading is delayed until we need to either check that an
2525
option exists or get its value, which in turn may require to discover
2526
in which sections it can be defined. Both of these (section and option
2527
existence) require loading the store (even partially).
2529
# FIXME: No caching of options nor sections yet -- vila 20110503
2531
# Ensuring lazy loading is achieved by delaying section matching (which
2532
# implies querying the persistent storage) until it can't be avoided
2533
# anymore by using callables to describe (possibly empty) section
2535
for section_or_callable in self.sections_def:
2536
# Each section can expand to multiple ones when a callable is used
2537
if callable(section_or_callable):
2538
sections = section_or_callable()
2540
sections = [section_or_callable]
2541
for section in sections:
2542
value = section.get(name)
2543
if value is not None:
2545
if value is not None:
2548
# If the option is registered, it may provide a default value
2550
opt = option_registry.get(name)
2555
value = opt.get_default()
2558
def _get_mutable_section(self):
2559
"""Get the MutableSection for the Stack.
2561
This is where we guarantee that the mutable section is lazily loaded:
2562
this means we won't load the corresponding store before setting a value
2563
or deleting an option. In practice the store will often be loaded but
2564
this allows helps catching some programming errors.
2566
section = self.store.get_mutable_section(self.mutable_section_name)
2569
def set(self, name, value):
2570
"""Set a new value for the option."""
2571
section = self._get_mutable_section()
2572
section.set(name, value)
2574
def remove(self, name):
2575
"""Remove an existing option."""
2576
section = self._get_mutable_section()
2577
section.remove(name)
2580
# Mostly for debugging use
2581
return "<config.%s(%s)>" % (self.__class__.__name__, id(self))
2584
class _CompatibleStack(Stack):
2585
"""Place holder for compatibility with previous design.
2587
This intended to ease the transition from the Config-based design to the
2588
Stack-based design and should not be used nor relied upon by plugins.
2590
One assumption made here is that the daughter classes will all use Stores
2591
derived from LockableIniFileStore).
2594
def set(self, name, value):
2595
# Force a reload (assuming we use a LockableIniFileStore)
2596
self.store._config_obj = None
2597
super(_CompatibleStack, self).set(name, value)
2598
# Force a write to persistent storage
2602
class GlobalStack(_CompatibleStack):
2606
gstore = GlobalStore()
2607
super(GlobalStack, self).__init__([gstore.get_sections], gstore)
2610
class LocationStack(_CompatibleStack):
2612
def __init__(self, location):
2613
lstore = LocationStore()
2614
matcher = LocationMatcher(lstore, location)
2615
gstore = GlobalStore()
2616
super(LocationStack, self).__init__(
2617
[matcher.get_sections, gstore.get_sections], lstore)
2619
# FIXME: See BranchStore, same remarks -- vila 20110512
2620
class BranchStack(_CompatibleStack):
2622
def __init__(self, branch):
2623
bstore = BranchStore(branch)
2624
lstore = LocationStore()
2625
matcher = LocationMatcher(lstore, branch.base)
2626
gstore = GlobalStore()
2627
super(BranchStack, self).__init__(
2628
[matcher.get_sections, bstore.get_sections, gstore.get_sections],
2632
class cmd_config(commands.Command):
2633
__doc__ = """Display, set or remove a configuration option.
2635
Display the active value for a given option.
2637
If --all is specified, NAME is interpreted as a regular expression and all
2638
matching options are displayed mentioning their scope. The active value
2639
that bzr will take into account is the first one displayed for each option.
2641
If no NAME is given, --all .* is implied.
2643
Setting a value is achieved by using name=value without spaces. The value
2644
is set in the most relevant scope and can be checked by displaying the
2648
takes_args = ['name?']
2652
# FIXME: This should be a registry option so that plugins can register
2653
# their own config files (or not) -- vila 20101002
2654
commands.Option('scope', help='Reduce the scope to the specified'
2655
' configuration file',
2657
commands.Option('all',
2658
help='Display all the defined values for the matching options.',
2660
commands.Option('remove', help='Remove the option from'
2661
' the configuration file'),
2664
@commands.display_command
2665
def run(self, name=None, all=False, directory=None, scope=None,
2667
if directory is None:
2669
directory = urlutils.normalize_url(directory)
2671
raise errors.BzrError(
2672
'--all and --remove are mutually exclusive.')
2674
# Delete the option in the given scope
2675
self._remove_config_option(name, directory, scope)
2677
# Defaults to all options
2678
self._show_matching_options('.*', directory, scope)
2681
name, value = name.split('=', 1)
2683
# Display the option(s) value(s)
2685
self._show_matching_options(name, directory, scope)
2687
self._show_value(name, directory, scope)
2690
raise errors.BzrError(
2691
'Only one option can be set.')
2692
# Set the option value
2693
self._set_config_option(name, value, directory, scope)
2695
def _get_configs(self, directory, scope=None):
2696
"""Iterate the configurations specified by ``directory`` and ``scope``.
2698
:param directory: Where the configurations are derived from.
2700
:param scope: A specific config to start from.
2702
if scope is not None:
2703
if scope == 'bazaar':
2704
yield GlobalConfig()
2705
elif scope == 'locations':
2706
yield LocationConfig(directory)
2707
elif scope == 'branch':
2708
(_, br, _) = bzrdir.BzrDir.open_containing_tree_or_branch(
2710
yield br.get_config()
2713
(_, br, _) = bzrdir.BzrDir.open_containing_tree_or_branch(
2715
yield br.get_config()
2716
except errors.NotBranchError:
2717
yield LocationConfig(directory)
2718
yield GlobalConfig()
2720
def _show_value(self, name, directory, scope):
2722
for c in self._get_configs(directory, scope):
2725
for (oname, value, section, conf_id, parser) in c._get_options():
2727
# Display only the first value and exit
2729
# FIXME: We need to use get_user_option to take policies
2730
# into account and we need to make sure the option exists
2731
# too (hence the two for loops), this needs a better API
2733
value = c.get_user_option(name)
2734
# Quote the value appropriately
2735
value = parser._quote(value)
2736
self.outf.write('%s\n' % (value,))
2740
raise errors.NoSuchConfigOption(name)
2742
def _show_matching_options(self, name, directory, scope):
2743
name = re.compile(name)
2744
# We want any error in the regexp to be raised *now* so we need to
2745
# avoid the delay introduced by the lazy regexp.
2746
name._compile_and_collapse()
2749
for c in self._get_configs(directory, scope):
2750
for (oname, value, section, conf_id, parser) in c._get_options():
2751
if name.search(oname):
2752
if cur_conf_id != conf_id:
2753
# Explain where the options are defined
2754
self.outf.write('%s:\n' % (conf_id,))
2755
cur_conf_id = conf_id
2757
if (section not in (None, 'DEFAULT')
2758
and cur_section != section):
2759
# Display the section if it's not the default (or only)
2761
self.outf.write(' [%s]\n' % (section,))
2762
cur_section = section
2763
self.outf.write(' %s = %s\n' % (oname, value))
2765
def _set_config_option(self, name, value, directory, scope):
2766
for conf in self._get_configs(directory, scope):
2767
conf.set_user_option(name, value)
2770
raise errors.NoSuchConfig(scope)
2772
def _remove_config_option(self, name, directory, scope):
2774
raise errors.BzrCommandError(
2775
'--remove expects an option to remove.')
2777
for conf in self._get_configs(directory, scope):
2778
for (section_name, section, conf_id) in conf._get_sections():
2779
if scope is not None and conf_id != scope:
2780
# Not the right configuration file
2783
if conf_id != conf.config_id():
2784
conf = self._get_configs(directory, conf_id).next()
2785
# We use the first section in the first config where the
2786
# option is defined to remove it
2787
conf.remove_user_option(name, section_name)
2792
raise errors.NoSuchConfig(scope)
2794
raise errors.NoSuchConfigOption(name)
2798
# We need adapters that can build a Store or a Stack in a test context. Test
2799
# classes, based on TestCaseWithTransport, can use the registry to parametrize
2800
# themselves. The builder will receive a test instance and should return a
2801
# ready-to-use store or stack. Plugins that define new store/stacks can also
2802
# register themselves here to be tested against the tests defined in
2803
# bzrlib.tests.test_config. Note that the builder can be called multiple times
2804
# for the same tests.
2806
# The registered object should be a callable receiving a test instance
2807
# parameter (inheriting from tests.TestCaseWithTransport) and returning a Store
2809
test_store_builder_registry = registry.Registry()
2811
# Thre registered object should be a callable receiving a test instance
2812
# parameter (inheriting from tests.TestCaseWithTransport) and returning a Stack
2814
test_stack_builder_registry = registry.Registry()