~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to doc/developers/configuration.txt

  • Committer: Martin Pool
  • Date: 2011-12-01 08:12:30 UTC
  • mto: This revision was merged to the branch mainline in revision 6347.
  • Revision ID: mbp@canonical.com-20111201081230-j76ar868bz9lrd9n
Attempted developer documentation of configuration

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
 
9
9
* a value: a unicode string or a list of unicode strings.
10
10
 
 
11
The short story
 
12
---------------
 
13
 
 
14
As a Bazaar developer there are three things you need to know about
 
15
configuration.
 
16
 
 
17
1: To get a value, you construct or get a reference to a ConfigStack
 
18
subclass that's relevant to the context where you want to look up a value.
 
19
For instance, given a branch::
 
20
 
 
21
  print branch.get_config_stack().get('log_format')
 
22
 
 
23
This will look up the stack through all relevant configuration sources.
 
24
The value returned is of the type declared for that Option and if nothing
 
25
is specifically declared you will get the default for that option.
 
26
 
 
27
2: To add a new option, you add a new `Option` to the `option_registry`,
 
28
either inside ``bzrlib/config.py`` or during initialization of your
 
29
plugin.  New plugins should have systematic hierarchical names so that
 
30
related values are grouped together.  ::
 
31
 
 
32
  option_registry.register(
 
33
      Option('dirstate.fdatasync', default=True,
 
34
            from_unicode=bool_from_store,
 
35
            help="Flush dirstate changes onto physical disk? ...."))
 
36
 
 
37
3: There is (as of late 2011) some older and some newer configuration
 
38
code.  The old code has specific methods for various checks or uses
 
39
classes like `GlobalConfig`.  Don't add to to it; try to remove it.
 
40
 
11
41
Option
12
42
------
13
43