mercurial/help/internals/config.txt
branchstable
changeset 34948 ff178743e59b
parent 34932 fd78276948b4
child 34951 fb7f58daca48
equal deleted inserted replaced
34947:ff2110eadbfa 34948:ff178743e59b
    21 
    21 
    22 Complex default value
    22 Complex default value
    23 ---------------------
    23 ---------------------
    24 
    24 
    25 If the default provided is a callable, it is called to retrieve the default
    25 If the default provided is a callable, it is called to retrieve the default
    26 value when accessing the config option. This is useful for default value that
    26 value when accessing the config option. This is useful for default values that
    27 are mutable like the empty list::
    27 are mutable like the empty list::
    28 
    28 
    29     coreconfigitem('pager', 'ignore',
    29     coreconfigitem('pager', 'ignore',
    30         default=list,
    30         default=list,
    31     )
    31     )
    32 
    32 
    33 In addition, there are cases where the default is not fixed, but computed from
    33 In addition, there are cases where the default is not fixed, but computed from
    34 other properties. In this case, use the ``dynamicdefault`` object as value for
    34 other properties. In this case, use the ``dynamicdefault`` object as the value
    35 the ``default`` parameters. A default value is then explicitly required when
    35 for the ``default`` parameter. A default value is then explicitly required when
    36 reading the option::
    36 reading the option::
    37 
    37 
    38     # registration
    38     # registration
    39     coreconfigitem('web', 'name',
    39     coreconfigitem('web', 'name',
    40         default=dynamicdefault,
    40         default=dynamicdefault,
    41     )
    41     )
    42 
    42 
    43     # usage
    43     # usage
    44     ui.config('web', 'name', dirnam)
    44     ui.config('web', 'name', dirname)
    45 
    45 
    46 Free form options
    46 Free form options
    47 -----------------
    47 -----------------
    48 
    48 
    49 Some config sections use free form options (e.g. ``paths``). You can register
    49 Some config sections use free form options (e.g. ``paths``). You can register
    61         default="$local $base $other",
    61         default="$local $base $other",
    62         generic=True,
    62         generic=True,
    63         priority=-1,
    63         priority=-1,
    64     )
    64     )
    65 
    65 
    66 The ``priority`` parameter control the order used to match the generic pattern
    66 The ``priority`` parameter controls the order used to match the generic pattern
    67 (lower first).
    67 (lower first).
    68 
    68 
    69 Config Option in Extensions
    69 Config Option in Extensions
    70 ===========================
    70 ===========================
    71 
    71 
    83     )
    83     )
    84 
    84 
    85 The ``dynamicdefault`` object is then available as
    85 The ``dynamicdefault`` object is then available as
    86 ``configitem.dynamicdefault``.
    86 ``configitem.dynamicdefault``.
    87 
    87 
    88 Supporting older version
    88 Supporting older versions
    89 ------------------------
    89 -------------------------
    90 
    90 
    91 The register was introduced in Mercurial 4.3, the ``generic`` parameter was
    91 The registry was introduced in Mercurial 4.3, and the ``generic`` parameter was
    92 introduced in 4.4. Starting with Mercurial 4.4, all core options were registered
    92 introduced in 4.4. Starting with Mercurial 4.4, all core options were registered
    93 and developer warnings are emitted when accessing unregistered option.
    93 and developer warnings are emitted when accessing unregistered option.
    94 
    94 
    95 Extensions supporting version older than Mercurial-4.3 cannot rely on the
    95 Extensions supporting versions older than Mercurial 4.3 cannot rely on the
    96 default value registered. The simplest way to register option while still
    96 default value being registered. The simplest way to register an option while
    97 supporting older version is to use ``dynamicdefault`` for option requiring a
    97 still supporting an older version is to use ``dynamicdefault`` for options
    98 default value. The existing code passing an explicit default can then stay in
    98 requiring a default value. The existing code passing an explicit default can
    99 use until compatibility to Mercurial 4.2 is dropped.
    99 then stay in use until compatibility with Mercurial 4.2 is dropped.
   100 
   100 
   101 As reminder here are the default value for each config types:
   101 As reminder, here are the default values for each config type:
   102 - config:      None
   102 - config:      None
   103 - configbool:  False
   103 - configbool:  False
   104 - configbytes: 0
   104 - configbytes: 0
   105 - configdate:  None
   105 - configdate:  None
   106 - configint:   None
   106 - configint:   None
   107 - configlist:  []
   107 - configlist:  []
   108 - configpath: None
   108 - configpath:  None