~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/config.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-08-17 18:13:57 UTC
  • mfrom: (5268.7.29 transport-segments)
  • Revision ID: pqm@pqm.ubuntu.com-20110817181357-y5q5eth1hk8bl3om
(jelmer) Allow specifying the colocated branch to use in the branch URL,
 and retrieving the branch name using ControlDir._get_selected_branch.
 (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
2307
2307
    def get_default(self):
2308
2308
        return self.default
2309
2309
 
 
2310
    def get_help_text(self, additional_see_also=None, plain=True):
 
2311
        result = self.help
 
2312
        from bzrlib import help_topics
 
2313
        result += help_topics._format_see_also(additional_see_also)
 
2314
        if plain:
 
2315
            result = help_topics.help_as_plain_text(result)
 
2316
        return result
 
2317
 
 
2318
 
2310
2319
# Predefined converters to get proper values from store
2311
2320
 
2312
2321
def bool_from_store(unicode_str):
2317
2326
    return int(unicode_str)
2318
2327
 
2319
2328
 
 
2329
def list_from_store(unicode_str):
 
2330
    # ConfigObj return '' instead of u''. Use 'str' below to catch all cases.
 
2331
    if isinstance(unicode_str, (str, unicode)):
 
2332
        if unicode_str:
 
2333
            # A single value, most probably the user forgot (or didn't care to
 
2334
            # add) the final ','
 
2335
            l = [unicode_str]
 
2336
        else:
 
2337
            # The empty string, convert to empty list
 
2338
            l = []
 
2339
    else:
 
2340
        # We rely on ConfigObj providing us with a list already
 
2341
        l = unicode_str
 
2342
    return l
 
2343
 
 
2344
 
2320
2345
class OptionRegistry(registry.Registry):
2321
2346
    """Register config options by their name.
2322
2347
 
2335
2360
    def register_lazy(self, key, module_name, member_name):
2336
2361
        """Register a new option to be loaded on request.
2337
2362
 
2338
 
        :param key: This is the key to use to request the option later. Since
2339
 
            the registration is lazy, it should be provided and match the
2340
 
            option name.
2341
 
 
2342
 
        :param module_name: The python path to the module. Such as 'os.path'.
2343
 
 
2344
 
        :param member_name: The member of the module to return.  If empty or
 
2363
        :param key: the key to request the option later. Since the registration
 
2364
            is lazy, it should be provided and match the option name.
 
2365
 
 
2366
        :param module_name: the python path to the module. Such as 'os.path'.
 
2367
 
 
2368
        :param member_name: the member of the module to return.  If empty or 
2345
2369
                None, get() will return the module itself.
2346
2370
        """
2347
2371
        super(OptionRegistry, self).register_lazy(key,
2362
2386
# Registered options in lexicographical order
2363
2387
 
2364
2388
option_registry.register(
2365
 
    Option('dirstate.fdatasync', default=True, from_unicode=bool_from_store,
2366
 
           help='''
 
2389
    Option('bzr.workingtree.worth_saving_limit', default=10,
 
2390
           from_unicode=int_from_store,  invalid='warning',
 
2391
           help='''\
 
2392
How many changes before saving the dirstate.
 
2393
 
 
2394
-1 means that we will never rewrite the dirstate file for only
 
2395
stat-cache changes. Regardless of this setting, we will always rewrite
 
2396
the dirstate file if a file is added/removed/renamed/etc. This flag only
 
2397
affects the behavior of updating the dirstate file after we notice that
 
2398
a file has been touched.
 
2399
'''))
 
2400
option_registry.register(
 
2401
    Option('dirstate.fdatasync', default=True,
 
2402
           from_unicode=bool_from_store,
 
2403
           help='''\
2367
2404
Flush dirstate changes onto physical disk?
2368
2405
 
2369
2406
If true (default), working tree metadata changes are flushed through the
2371
2408
should not be lost if the machine crashes.  See also repository.fdatasync.
2372
2409
'''))
2373
2410
option_registry.register(
 
2411
    Option('debug_flags', default=[], from_unicode=list_from_store,
 
2412
           help='Debug flags to activate.'))
 
2413
option_registry.register(
2374
2414
    Option('default_format', default='2a',
2375
2415
           help='Format used when creating branches.'))
2376
2416
option_registry.register(
2377
2417
    Option('editor',
2378
2418
           help='The command called to launch an editor to enter a message.'))
2379
2419
option_registry.register(
 
2420
    Option('ignore_missing_extensions', default=False,
 
2421
           from_unicode=bool_from_store,
 
2422
           help='''\
 
2423
Control the missing extensions warning display.
 
2424
 
 
2425
The warning will not be emitted if set to True.
 
2426
'''))
 
2427
option_registry.register(
2380
2428
    Option('language',
2381
2429
           help='Language to translate messages into.'))
2382
2430
option_registry.register(
 
2431
    Option('locks.steal_dead', default=False, from_unicode=bool_from_store,
 
2432
           help='''\
 
2433
Steal locks that appears to be dead.
 
2434
 
 
2435
If set to True, bzr will check if a lock is supposed to be held by an
 
2436
active process from the same user on the same machine. If the user and
 
2437
machine match, but no process with the given PID is active, then bzr
 
2438
will automatically break the stale lock, and create a new lock for
 
2439
this process.
 
2440
Otherwise, bzr will prompt as normal to break the lock.
 
2441
'''))
 
2442
option_registry.register(
2383
2443
    Option('output_encoding',
2384
2444
           help= 'Unicode encoding for output'
2385
2445
           ' (terminal encoding if not specified).'))