HEX
Server: Apache
System: Linux infong-uk86 4.4.400-icpu-106 #2 SMP Mon Sep 15 08:23:40 UTC 2025 x86_64
User: u44115835 (4976590)
PHP: 8.4.17
Disabled: NONE
Upload Files
File: //kunden/lib/python3/dist-packages/breezy/__pycache__/config.cpython-39.pyc
a

�*�^zJ�	@s	dZddlmZddlZddlZddlZddlZddlmZee�d�ddl	m
Z
mZmZm
Z
mZmZddlmZmZmZmZmZdZdZd	ZdZdZd	ZdZdZd	Zeded
ediZeeeed�Z eZ!eZ"eZ#d
Z$dZ%Gdd�dej&�Z'Gdd�dej&�Z(Gdd�dej&�Z)Gdd�dej&�Z*Gdd�dej&�Z+Gdd�dej&�Z,Gdd�dej&�Z-Gdd�dej&�Z.Gdd �d ej&�Z/d!d"�Z0d#d$�Z1d%d&�Z2d'd(�Z3Gd)d*�d*ej4�Z4Gd+d,�d,e5�Z6Gd-d.�d.e
j7�Z8e8�Z9Gd/d0�d0e
j7�Z:e:�Z;Gd1d2�d2e6�Z<Gd3d4�d4e<�Z=Gd5d6�d6e=�Z>d7d8�Z?Gd9d:�d:e=�Z@Gd;d<�d<e6�ZAd=d>�ZBd?d@�ZCGdAdB�dBe<�ZDeE�ZFGdCdD�dDe5�ZGGdEdF�dFejH�ZIeI�ZJGdGdH�dHe5�ZKGdIdJ�dJeK�ZLeJjMdKeLeLjdL�dKeJ_NGdMdN�dNeK�ZOeJjMdOeOeOjdL�GdPdQ�dQe5�ZPGdRdS�dSe5�ZQGdTdU�dUe5�ZRdVdW�ZSdXdY�ZTeUdZd[d\d]�ZVd^d_�ZWd`da�ZXej4idbdcddde�ZYGdfdg�dgeR�ZZGdhdi�dieR�Z[e�\dj�Z]dkdl�Z^Gdmdn�dnejH�Z_e_�Z`e`�MeRdodeSdpdqdr��e`�MeZdsddtdu��e`�MeRdvdweWdxdy��e`�MeRdzdeSd{dy��e`�MeRd|dd}du��e`�MeRd~ddeSddy��e`�ad�d�d��e`�MeRd�d�eTdpd�dr��e`�MeRd�dd�du��e`�MeRd�dceSd�dy��e`�MeRd�ee0d�dy��e`�MeRd�d�dL��e`�MeRd�d�dL��e`�MeRd�ee1d�dy��e`�MeRd�dceSd�dy��e`�MeZd�gd�du��e`�MeRd�d�d�du��e`�MeRd�d�dL��e`�MeRd�d�d�gejbd�d���e`�MeRd�dd�du��e`�MeRd�d�dL��e`�MeRd�dceSd�dy��e`�MeRd�d�d�du��e`�ad�d�d��e`�MeRd�d�dL��e`�MeRd�dd�du��e`�MeRd�dd�du��e`�ad�d�d��e`�MeRd�dd�du��e`�MeRd�dd�du��e`�MeRd�deSd�dy��e`�MeRd�dceSd�dy��e`�ad�d�d��e`�ad�d�d��e`�ad�d�d��e`�MeRd�d�eTd�dy��e`�MeRd�deSd�dy��e`�MeRd�d�eXd�dy��e`�MeRd�dd�gd�d̍�e`�MeRd�dd�du��e`�MeRd�dd�du��e`�MeRd�d�dL��e`�MeZd�gd�du��e`�MeRd�ddeSdpd�dr��e`�ad�d�d١e`�ad�d�dۡGd�d݄d�e5�Zce5�Zde5�ZeGd�d߄d�ec�ZfGd�d�d�e5�ZgGd�d�d�eg�ZhGd�d�d�eg�ZiGd�d�d�ei�ZjGd�d�d�ej�ZkGd�d�d�ek�ZlGd�d�d�ek�ZmGd�d�d�ej�ZnGd�d�d�ek�ZoGd�d�d�e5�ZpGd�d��d�ep�ZqGd�d��d�ec�ZrGd�d��d�ep�ZsGd�d��d�ep�ZtiZuddavGd�d��d�e5�ZwGd�d��d�ew�ZxG�d�d��dew�ZyG�d�d��dew�ZzG�d�d��dew�Z{G�d�d��dew�Z|G�d�d	��d	ew�Z}G�d
�d��dew�Z~G�d�d
��d
e
j�Z�e�H�Z�e�H�Z�dS(a
	Configuration that affects the behaviour of Breezy.

Currently this configuration resides in ~/.config/breezy/breezy.conf
and ~/.config/breezy/locations.conf, which is written to by brz.

If the first location doesn't exist, then brz falls back to reading
Bazaar configuration files in ~/.bazaar or ~/.config/bazaar.

In breezy.conf the following options may be set:
[DEFAULT]
editor=name-of-program
email=Your Name <your@email.address>
check_signatures=require|ignore|check-available(default)
create_signatures=always|never|when-required(default)
log_format=name-of-format
validate_signatures_in_log=true|false(default)
acceptable_keys=pattern1,pattern2
gpg_signing_key=amy@example.com

in locations.conf, you specify the url of a branch and options for it.
Wildcards may be used - * and ? as normal in shell completion. Options
set in both breezy.conf and locations.conf are overridden by the locations.conf
setting.
[/home/robertc/source]
recurse=False|True(default)
email= as above
check_signatures= as above
create_signatures= as above.
validate_signatures_in_log=as above
acceptable_keys=as above

explanation of options
----------------------
editor - this option sets the pop up editor to use during commits.
email - this option sets the user id brz will use when committing.
check_signatures - this option will control whether brz will require good gpg
                   signatures, ignore them, or check them if they are
                   present.  Currently it is unused except that
                   check_signatures turns on create_signatures.
create_signatures - this option controls whether brz will always create
                    gpg signatures or not on commits.  There is an unused
                    option which in future is expected to work if
                    branch settings require signatures.
log_format - this option sets the default log format.  Possible values are
             long, short, line, or a plugin can register new formats.
validate_signatures_in_log - show GPG signature validity in log output
acceptable_keys - comma separated list of key patterns acceptable for
                  verify-signatures command

In breezy.conf you can also define aliases in the ALIASES sections, example

[ALIASES]
lastlog=log --line -r-10..-1
ll=log --line -r-10..-1
h=help
up=pull
�)�absolute_importN�)�lazy_importa@
import base64
import errno
import fnmatch
import re
import stat

from breezy import (
    atomicfile,
    cmdline,
    controldir,
    debug,
    directory_service,
    lock,
    lockdir,
    mergetools,
    osutils,
    trace,
    transport,
    ui,
    urlutils,
    win32utils,
    )
from breezy.i18n import gettext
)�commands�bedding�errors�hooks�
lazy_regex�registry)�binary_type�BytesIO�PY3�string_types�	text_type��	norecurse�
appendpath)NZnonerr��c@seZdZdZdd�ZdS)�OptionExpansionLoopz5Loop involving %(refs)r while expanding "%(string)s".cCs||_d�|�|_dS)Nz->)�string�join�refs)�selfrr�r�//usr/lib/python3/dist-packages/breezy/config.py�__init__�szOptionExpansionLoop.__init__N��__name__�
__module__�__qualname__Z_fmtrrrrrr�src@seZdZdZdd�ZdS)�ExpandingUnknownOptionz>Option "%(name)s" is not defined while expanding "%(string)s".cCs||_||_dS�N)�namer)rr#rrrrr�szExpandingUnknownOption.__init__Nrrrrrr!�sr!c@seZdZdZdd�ZdS)�IllegalOptionNamez!Option "%(name)s" is not allowed.cCs
||_dSr"�r#�rr#rrrr�szIllegalOptionName.__init__Nrrrrrr$�sr$c@seZdZdZdd�ZdS)�ConfigContentErrorz.Config file %(filename)s is not UTF-8 encoded
cCs
||_dSr")�filename)rr(rrrr�szConfigContentError.__init__Nrrrrrr'�sr'c@seZdZdZdd�ZdS)�ParseConfigErrorz5Error(s) parsing config file %(filename)s:
%(errors)scCs ||_d�dd�|D��|_dS)N�
css|]}|jVqdSr")�msg)�.0�errr�	<genexpr>��z,ParseConfigError.__init__.<locals>.<genexpr>)r(rr)rrr(rrrr�szParseConfigError.__init__Nrrrrrr)�sr)c@seZdZdZdd�ZdS)�ConfigOptionValueErrorzFBad value "%(value)s" for option "%(name)s".
See ``brz help %(name)s``cCstjj|||d�dS)N)r#�value�r�BzrErrorr�rr#r1rrrr�szConfigOptionValueError.__init__Nrrrrrr0�sr0c@seZdZdZdd�ZdS)�NoEmailInUsernamez@%(username)r does not seem to contain a reasonable email addresscCs
||_dSr")�username)rr6rrrr�szNoEmailInUsername.__init__Nrrrrrr5�sr5c@seZdZdZdd�ZdS)�NoSuchConfigz1The "%(config_id)s" configuration does not exist.cCstjj||d�dS)N)�	config_idr2)rr8rrrr�szNoSuchConfig.__init__Nrrrrrr7�sr7c@seZdZdZdd�ZdS)�NoSuchConfigOptionz:The "%(option_name)s" configuration option does not exist.cCstjj||d�dS)N)�option_namer2�rr:rrrr�szNoSuchConfigOption.__init__Nrrrrrr9�sr9cCs@|��dkrtS|��dkr tS|��dkr0tStd|��dS)�%Convert a string to a signing policy.zcheck-available�ignoreZrequirezInvalid signatures policy '%s'N)�lower�CHECK_IF_POSSIBLE�CHECK_NEVER�CHECK_ALWAYS�
ValueError�Zsignature_stringrrr�signature_policy_from_unicode�s�rDcCs@|��dkrtS|��dkr tS|��dkr0tStd|��dS)r<z
when-required�never�alwayszInvalid signing policy '%s'N)r>�SIGN_WHEN_REQUIRED�
SIGN_NEVER�SIGN_ALWAYSrBrCrrr�signing_policy_from_unicode�s�rJcCs@trdSt��}t|dd�}|r<|dd�}t|dt�r<dSdS)z=True if configobj will fail to decode to unicode on Python 2.F�_decodeNs§�utf-8rT)r
�	configobj�	ConfigObj�getattr�
isinstance�str)�conf�decode�resultrrr�_has_decode_bugs
rUcCs,t��}t|dd�}|r(|d�dkr(dSdS)z6True if triple quote logic is reversed, see lp:710410.�_get_triple_quoteN�"""z'''TF)rMrNrO)rR�quoterrr�_has_triplequote_bugs
rYcsReZdZd�fdd�	Ze�r(�fdd�Ze�r:�fdd�Zdd	�Zd
d�Z	�Z
S)
rNNcs tt|�jf|dd�|��dS)NF)�infile�
interpolation)�superrNr)rrZ�kwargs��	__class__rrrs
��zConfigObj.__init__cs0t|t�r|r|�|��d�Stt|��||�S)NT)rPrQrS�
splitlinesr\rNrK)rrZ�encodingr^rrrK$szConfigObj._decodecs&tt|��|�}|tjkr tjStjSr")r\rNrVrMZtdquotZtsquot)rr1Zquotr^rrrV*s
zConfigObj._get_triple_quotecCs||�|�Sr")�as_bool)r�section�keyrrr�get_bool0szConfigObj.get_boolcCs2|dkr&z
||WSty$Yn0|||S�N�DEFAULT)�KeyError)rrcr#rrr�	get_value3s
zConfigObj.get_value)N)rrr rrUrKrYrVreri�
__classcell__rrr^rrNsrNcseZdZdZ�fdd�Zdd�Zdd�Zdd	�Zd
d�ZdZ	d:d
d�Z
d;dd�Zd<dd�Zdd�Z
dd�Zd=dd�Zd>dd�Zd?dd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Z�Z S)@�Configz>A configuration policy - what username, editor, gpg needs etc.cstt|���dSr")r\rkr�rr^rrr@szConfig.__init__cCst|j��dS)z#Returns a unique ID for the config.N)�NotImplementedErrorr8rlrrrr8CszConfig.config_idcCslddlm}|��}|dur dS|�dd�}|�dd�}t�|�}d|vrX|�ddg�|j�|||t	j
�S)Nr)�diffz	@old_pathz
{old_path}z	@new_pathz
{new_path})�breezyrn�_get_change_editor�replace�cmdline�split�extendZDiffFromTool�from_string�sys�stdout)rZold_treeZnew_treern�cmdrrr�get_change_editorGs
�zConfig.get_change_editorcCsdS)z6Template method to override signature checking policy.Nrrlrrr�_get_signature_checkingTszConfig._get_signature_checkingcCsdS)z6Template method to override signature creation policy.Nrrlrrr�_get_signing_policyWszConfig._get_signing_policyNcCs|�||�S)a,Expand option references in the string in the configuration context.

        :param string: The string containing option to expand.

        :param env: An option dict defining additional configuration options or
            overriding existing ones.

        :returns: The expanded string.
        ��_expand_options_in_string�rr�envrrr�expand_options\s
zConfig.expand_optionscCs@g}|D]2}|�|||�}t|t�r0|�|�q|�|�q|S)a�Expand options in  a list of strings in the configuration context.

        :param slist: A list of strings.

        :param env: An option dict defining additional configuration options or
            overriding existing ones.

        :param _ref_stack: Private list containing the options being
            expanded to detect loops.

        :returns: The flatten list of expanded strings.
        )r}rP�listrt�append)rZslistr�
_ref_stackrT�sr1rrr�_expand_options_in_lisths
zConfig._expand_options_in_listcCs|durdS|durg}|jdur.t�d�|_|}|j�|�}t|�dkrN|Sg}d}d}|D]�}	|sz|	rt|�|	�d}q^|	dd�}
|
|vr�t||��|�|
�|�|
||�}|dur�t|
|��t	|t
�r�d}|�|�n
|�|�|��d}q^|�r|�
|||�Sd�|�}q2|S)a�Expand options in the string in the configuration context.

        :param string: The string to be expanded.

        :param env: An option dict defining additional configuration options or
            overriding existing ones.

        :param _ref_stack: Private list containing the options being
            expanded to detect loops.

        :returns: The expanded string.
        Nz
({[^{}]+})rFT����)�
option_ref_re�re�compilers�lenr�r�_expand_optionr!rPr�rt�popr�r)rrrr�rTZ
raw_chunks�chunksZ
list_valueZchunk_is_ref�chunkr#r1rrrr}sF







z Config._expand_options_in_stringcCsT|dur||vr||}n6|j|dd�}t|t�rB|�|||�}n|�|||�}|S)NF��expand)�get_user_optionrPr�r�r})rr#rr�r1rrrr��s

zConfig._expand_optioncCsdS)z)Template method to provide a user option.Nrr;rrr�_get_user_option�szConfig._get_user_optionTcCsh|�|�}|rJt|t�r$|�|�}n&t|t�r@t�d|f�n
|�|�}tdD]}||||�qR|S)z�Get a generic option - no special process, no default.

        :param option_name: The queried option.

        :param expand: Whether options references should be expanded.

        :returns: The value of the option.
        z9Cannot expand "%s": Dicts do not support option expansion�get)	r�rPr�r��dict�trace�warningr}�OldConfigHooks)rr:r�r1�hookrrrr��s	


�
zConfig.get_user_optioncCs>|j||d�}|dur|St�|�}|dur:t�d||�|S)aCGet a generic option as a boolean.

        :param expand: Allow expanding references to other config values.
        :param default: Default value if nothing is configured
        :return None if the option doesn't exist or its value can't be
            interpreted as a boolean. Returns True or False otherwise.
        r�Nz$Value "%s" is not a boolean for "%s")r��ui�bool_from_stringr�r�)rr:r��defaultr��valrrr�get_user_option_as_bool�s
�zConfig.get_user_option_as_boolcCs"|j||d�}t|t�r|g}|S)z�Get a generic option as a list - no special process, no default.

        :return None if the option doesn't exist. Returns the value as a list
            otherwise.
        r�)r�rPr)rr:r��lrrr�get_user_option_as_lists
zConfig.get_user_option_as_listcCsdS)zSee log_format().Nrrlrrr�_log_formatszConfig._log_formatcCs|��}|dkrd}nd}|S)z"Show GPG signature validity in log�trueTF)�_validate_signatures_in_log)rrTrrr�validate_signatures_in_logs
z!Config.validate_signatures_in_logcCsdS)z!See validate_signatures_in_log().Nrrlrrrr�sz"Config._validate_signatures_in_logcCsdS)�See Config.post_commit.Nrrlrrr�_post_commit"szConfig._post_commitcCst|���S)z.Return just the email component of a username.)�extract_email_addressr6rlrrr�
user_email&szConfig.user_emailcCsJtj�d�ptj�d�}|r2ts.|�t���}|S|��}|rB|St�	�S)aBReturn email-style username.

        Something similar to 'Martin Pool <mbp@sourcefrog.net>'

        $BRZ_EMAIL or $BZR_EMAIL can be set to override this, then
        the concrete policy type is checked, and finally
        $EMAIL is examined.
        If no username can be found, NoWhoami exception is raised.
        �	BRZ_EMAIL�	BZR_EMAIL)
�os�environr�r
rS�osutils�get_user_encoding�_get_user_idr�
default_email)r�vrrrr6*s
zConfig.usernamecCs
|�|�Sr")�
_get_alias�rr1rrr�	get_alias>szConfig.get_aliascCsdSr"rr�rrrr�AszConfig._get_aliascCs|��Sr")�
_get_nicknamerlrrr�get_nicknameDszConfig.get_nicknamecCsdSr"rrlrrrr�GszConfig._get_nicknamecCs>ztjdWSty8|�d�}|dur0d}|YS0dS)NZBZR_REMOTE_PATHZbzr_remote_pathZbzr)r�r�rhr�)r�pathrrr�get_bzr_remote_pathJs
zConfig.get_bzr_remote_pathcCs&|�d�}|dus||vrdSdSdS)z�Should the warning be suppressed or emitted.

        :param warning: The name of the warning being tested.

        :returns: True if the warning should be suppressed, False otherwise.
        �suppress_warningsNFT)r�)rr��warningsrrr�suppress_warningSs
zConfig.suppress_warningcCsXi}|��D]8\}}}}}|�d�r|td�d�}|�|d�||<qt�d|�|S)Nzbzr.mergetool.Fzloaded merge tools: %r)�_get_options�
startswithr�r�r��mutter)rZtools�onamer1rcZconf_id�parserZ	tool_namerrr�get_merge_tools`s
zConfig.get_merge_toolscCs$|jd|dd�ptj�|d�}|S)Nzbzr.mergetool.%sFr�)r�Z
mergetoolsZknown_merge_toolsr�)rr#Zcommand_linerrr�find_merge_toolis
��zConfig.find_merge_tool)N)NN)NN)T)NN)N)!rrr �__doc__rr8ryrzr{r�r�r�r}r�r�r�r�r�r�r�r�r�r�r6r�r�r�r�r�r�r�r�rjrrr^rrk=s:



E



		
	rkcs eZdZdZ�fdd�Z�ZS)�_ConfigHooks�CA dict mapping hook names and a list of callables for configs.
    cs\tt|��dd�|�ddd�|�ddd�|�dd	d�|�d
dd�|�dd
d�dS)��Create the default hooks.

        These are all empty initially, because by default nothing should get
        notified.
        �
breezy.config�ConfigHooks�loadz@Invoked when a config store is loaded. The signature is (store).�rr�savez?Invoked when a config store is saved. The signature is (store).r�zLInvoked when a config option is read. The signature is (stack, name, value).�setzKInvoked when a config option is set. The signature is (stack, name, value).�removezHInvoked when a config option is removed. The signature is (stack, name).N)r\r�r�add_hookrlr^rrrxs*�����z_ConfigHooks.__init__�rrr r�rrjrrr^rr�tsr�cs eZdZdZ�fdd�Z�ZS)�_OldConfigHooksr�cs\tt|��dd�|�ddd�|�ddd�|�dd	d�|�d
dd�|�dd
d�dS)r�r�r�r�zAInvoked when a config store is loaded. The signature is (config).r�r�z@Invoked when a config store is saved. The signature is (config).r�zMInvoked when a config option is read. The signature is (config, name, value).r�zLInvoked when a config option is set. The signature is (config, name, value).r�zIInvoked when a config option is removed. The signature is (config, name).N)r\r�rr�rlr^rrr�s.
������z_OldConfigHooks.__init__r�rrr^rr��sr�cs�eZdZdZd2�fdd�	Zed3dd��Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zd4dd�Zd5dd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd6d.d/�Zd0d1�Z�ZS)7�IniBasedConfigz1A configuration policy that draws from ini files.Ncs*tt|���||_||_d|_d|_dS)z}Base class for configuration files using an ini-like syntax.

        :param file_name: The configuration file path.
        N)r\r�r�	file_name�_content�_parser�rr�r^rrr�s
zIniBasedConfig.__init__FcCs||d�}|�||�|S)aCreate a config object from a string.

        :param str_or_unicode: A string representing the file content. This
            will be utf-8 encoded.

        :param file_name: The configuration file path.

        :param _save: Whether the file should be saved upon creation.
        �r���_create_from_string)�cls�str_or_unicoder�r�rRrrrru�s
zIniBasedConfig.from_stringcCs.t|t�r|�d�}t|�|_|r*|��dS)NrL)rPr�encoderr��_write_config_file)rr�r�rrrr��s



z"IniBasedConfig._create_from_stringc
Cs�|jdur|jS|jdur"|j}n|jdur6td��n|j}zt|dd�|_WnPtjy�}zt|j|j	j
��WYd}~n$d}~0ty�t|j��Yn0|j|j_
t
dD]}||�q�|jS)Nz'We have no content to create the configrL�rar�)r�r�r��AssertionErrorrNrM�ConfigObjErrorr)r�configr(�UnicodeDecodeErrorr'r�)r�co_inputr-r�rrr�_get_parser�s"



$

zIniBasedConfig._get_parsercCs@|jdurtd��|jdur&|j��tdD]}||�q.dS)z!Reload the config file from disk.Nz(We need a file name to reload the configr�)r�r�r��reloadr�)rr�rrrr��s


zIniBasedConfig.reloadcCs"|��}|dur|dfgSgSdS)z�Return an ordered list of (section_name, extra_path) pairs.

        If the section contains inherited configuration, extra_path is
        a string containing the additional path components.
        Nr�)�_get_section�rrcrrr�_get_matching_sectionss
z%IniBasedConfig._get_matching_sectionscCsdS)z7Override this to define the section used by the config.rgrrlrrrr�szIniBasedConfig._get_sectionccs:|��}|dur&||||��fVnd||��fVdS)a�Returns an iterator of the sections specified by ``name``.

        :param name: The section name. If None is supplied, the default
            configurations are yielded.

        :return: A tuple (name, section, config_id) for all sections that will
            be walked by user_get_option() in the 'right' order. The first one
            is where set_user_option() will update the value.
        N�r�r8�rr#r�rrr�
_get_sectionss
zIniBasedConfig._get_sectionsc		cs�|durX|��}g}|��D]:\}}z||}WntyFYqYn0|�||f�q|��}|D]0\}}|��D]\}}||�|�|||fVqtqddS)aReturn an ordered list of (name, value, section, config_id) tuples.

        All options are returned with their associated value and the section
        they appeared in. ``config_id`` is a unique identifier for the
        configuration file the option is defined in.

        :param sections: Default to ``_get_matching_sections`` if not
            specified. This gives a better control to daughter classes about
            which sections should be searched. This is a list of (name,
            configobj) tuples.
        N)r�r�rhr�r8�	iteritems�_quote)	r�sectionsr��section_name�_rcr8r#r1rrrr�%s
�zIniBasedConfig._get_optionscCstS)�<Return the policy for the given (section, option_name) pair.)�POLICY_NONE)rrcr:rrr�_get_option_policyCsz!IniBasedConfig._get_option_policycCs|jddd�S)NZ
change_editorFr��r�rlrrrrpGsz!IniBasedConfig._get_change_editorcCs|�d�}|rt|�SdS)�#See Config._get_signature_checking.�check_signaturesN)r�rD�r�policyrrrrzJs
z&IniBasedConfig._get_signature_checkingcCs|�d�}|rt|�SdS)zSee Config._get_signing_policy�create_signaturesN)r�rJr�rrrr{Ps
z"IniBasedConfig._get_signing_policycCs
|�d�S)z<Get the user id from the 'email' key in the current section.�email�r�rlrrrr�VszIniBasedConfig._get_user_idc	Cs�|��D]�\}}z|���||�}Wnty:YqYn0|�||�}|tkrX|S|tkrr|rhqq�|Sq|tkr�|r�t�	||�}|St
d|��qdS)�See Config._get_user_option.zUnexpected config policy %rN)r�r�rirhr�r��POLICY_NORECURSE�POLICY_APPENDPATH�urlutilsrr�)rr:rc�
extra_pathr1r�rrrr�Zs$

zIniBasedConfig._get_user_optioncCs
|�d�S)�See Config.log_format.�
log_formatr�rlrrrr�sszIniBasedConfig._log_formatcCs
|�d�S)�&See Config.validate_signatures_in_log.r�r�rlrrrr�wsz*IniBasedConfig._validate_signatures_in_logcCs
|�d�S)�See Config.acceptable_keys.�acceptable_keysr�rlrrr�_acceptable_keys{szIniBasedConfig._acceptable_keyscCs
|�d�S)r��post_commitr�rlrrrr�szIniBasedConfig._post_commitcCs*z|���d|�WSty$Yn0dS)N�ALIASES)r�rirhr�rrrr��s
�zIniBasedConfig._get_aliascCs
|�d�S)NZnicknamer�rlrrrr��szIniBasedConfig._get_nicknamecCsp|��|��}|dur|}n||}z
||=WntyJt|��Yn0|��tdD]}|||�q\dS)z�Remove a user option and save the configuration file.

        :param option_name: The option to be removed.

        :param section_name: The section the option is defined in, default to
            the default section.
        Nr�)r�r�rhr9r�r�)rr:r�r�rcr�rrr�remove_user_option�s
z!IniBasedConfig.remove_user_optioncCs�|jdurtd��tj�|j�}t�|�t�|j��}|�	��
|�Wd�n1sZ0Yt�|j�t
dD]}||�qxdS)Nz&We cannot save, self.file_name is Noner�)r�r�r�r��dirnamer�ensure_config_dir_existsZ
atomicfileZ
AtomicFiler��writer�Zcopy_ownership_from_pathr�)r�conf_dirZatomic_filer�rrrr��s

,z!IniBasedConfig._write_config_file)N)NF)N)N)N)rrr r�r�classmethodrur�r�r�r�r�r�r�r�rprzr{r�r�r�r�rr�r�r�rr�rjrrr^rr��s2		


r�csdeZdZdZdZ�fdd�Z�fdd�Zddd	�Zd
d�Zdd
�Z	d�fdd�	Z
�fdd�Z�ZS)�LockableConfiga�A configuration needing explicit locking for access.

    If several processes try to write the config file, the accesses need to be
    serialized.

    Daughter classes should use the self.lock_write() decorator method when
    they upate a config (they call, directly or indirectly, the
    ``_write_config_file()`` method. These methods (typically ``set_option()``
    and variants must reload the config file from disk before calling
    ``_write_config_file()``), this can be achieved by calling the
    ``self.reload()`` method. Note that the lock scope should cover both the
    reading and the writing of the config file which is why the decorator can't
    be applied to ``_write_config_file()`` only.

    This should be enough to implement the following logic:
    - lock for exclusive write access,
    - reload the config file from disk,
    - set the new value
    - unlock

    This logic guarantees that a writer can update a value without erasing an
    update made by another writer.
    �lockcsJtt|�j|d�t�t�|j��|_t�	|j�|_t
�|j|j�|_
dS�Nr�)r\rrr�r	Zsafe_unicoder��dir�	transport�get_transport_from_path�lockdir�LockDir�	lock_name�_lockr�r^rrr�szLockableConfig.__init__cs2tt|��|d�|r.|��|��|��dS�NF)r\rr��
lock_writer��unlock)rZ
unicode_bytesr�r^rrr��s
z"LockableConfig._create_from_stringNcCs&t�|j�|j�|�}t�|j|�S�zTakes a write lock in the directory containing the config file.

        If the directory doesn't exist it is created.
        )rr
rrrr�LogicalLockResultr�r�tokenrrrr�szLockableConfig.lock_writecCs|j��dSr"�rrrlrrrr�szLockableConfig.unlockcCs|j��dSr"�r�
break_lockrlrrrr!�szLockableConfig.break_lockcs>|���"tt|��||�Wd�n1s00YdSr"�rr\rr�rr:r�r^rrr�s

�z!LockableConfig.remove_user_optioncs.|jdus|jjst�|��tt|���dSr")rZis_heldrZObjectNotLockedr\rr�rlr^rrr��s
z!LockableConfig._write_config_file)N)N)
rrr r�rrr�rrr!rr�rjrrr^rr�s	
	rcsveZdZdZ�fdd�Zdd�Zeddd��Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zddd�Z
d�fdd�	Z�ZS)�GlobalConfigz>The configuration that should be used for a specific location.cstt|�jt��d�dSr)r\r$rrZconfig_pathrlr^rrr�szGlobalConfig.__init__cCsdS)Nrorrlrrrr8szGlobalConfig.config_idFcCs|�}|�||�|S)z�Create a config object from a string.

        :param str_or_unicode: A string representing the file content. This
            will be utf-8 encoded.

        :param save: Whether the file should be saved upon creation.
        r�)r�r�r�rRrrrrus	zGlobalConfig.from_stringcCs:|���|�||d�Wd�n1s,0YdS)�/Save option and its value in the configuration.rgN�r�_set_option)r�optionr1rrr�set_user_options
zGlobalConfig.set_user_optioncCs d|��vr|��dSiSdS)zReturn the aliases section.rN)r�rlrrr�get_aliasesszGlobalConfig.get_aliasescCs:|���|�||d�Wd�n1s,0YdS)z$Save the alias in the configuration.rNr&)r�
alias_nameZ
alias_commandrrr�	set_aliass
zGlobalConfig.set_aliascCsf|���J|��|���d�}|r,||vr6t�|��||=|��Wd�n1sX0YdS)zUnset an existing alias.rN)rr�r�r�rZNoSuchAliasr�)rr+�aliasesrrr�unset_alias!s

zGlobalConfig.unset_aliascCsB|��||���|i�|<|��tdD]}||||�q,dS)Nr�)r�r��
setdefaultr�r�)rr(r1rcr�rrrr'+s
zGlobalConfig._set_optionNccs<|��}|dvr$d}d|vr$i|d<||||��fVdS)�#See IniBasedConfig._get_sections().rfrgNr�r�rrrr�2szGlobalConfig._get_sectionscsJ|durd}|���"tt|��||�Wd�n1s<0YdSrfr"r#r^rrr?s

�zGlobalConfig.remove_user_option)F)N)N)rrr r�rr8r
rur)r*r,r.r'r�rrjrrr^rr$�s


r$c	cs�|�d��d�}|D]�}|�d�r.t�|�}n|}|�d��d�}d}t|�t|�kr\d}n,t||�D] }t�|d|d�sfd}q�qf|s�qd�|t|�d��}||t|�fVqdS)a,Keep only the sessions matching the specified location.

    :param sections: An iterable of section names.

    :param location: An url or a local path to match against.

    :returns: An iterator of (section, extra_path, nb_parts) where nb is the
        number of path components in the section name, section is the section
        name and extra_path is the difference between location and the section
        name.

    ``location`` will always be a local path and never a 'file://' url but the
    section names themselves can be in either form.
    �/�file://TFrrN)	�rstriprsr�r��local_path_from_urlr��zip�fnmatchr)	r��location�location_partsrc�section_path�
section_partsZmatchedr#r�rrr�_iter_for_location_by_partsJs"

r;csdeZdZdZ�fdd�Zdd�Zeddd��Zd	d
�Zddd
�Z	dd�Z
dd�Zefdd�Z
�ZS)�LocationConfigz<A configuration object that gives the policy for a location.cs4tt|�jt��d�|�d�r*t�|�}||_dS)Nr�r2)	r\r<rrZlocations_config_pathr�r�r4r7)rr7r^rrr�s
�

zLocationConfig.__init__cCsdS)N�	locationsrrlrrrr8�szLocationConfig.config_idFcCs||�}|�||�|S)a,Create a config object from a string.

        :param str_or_unicode: A string representing the file content. This will
            be utf-8 encoded.

        :param location: The location url to filter the configuration.

        :param save: Whether the file should be saved upon creation.
        r�)r�r�r7r�rRrrrru�szLocationConfig.from_stringc	csltt|��|j�dd�dd�}|D]D\}}}||fVz|��|�d�rPWqhWq"tydYq"0q"dS)z?Return an ordered list of section names matching this location.cSs|d|dfS)Nrrr��matchrrr�<lambda>�r/z7LocationConfig._get_matching_sections.<locals>.<lambda>T�rd�reverse�ignore_parentsN)�sortedr;r�r7rbrh)rZmatchesrcr��lengthrrrr��s�

z%LocationConfig._get_matching_sectionsNccs2|��}|��D]\}}||||��fVqdS)r0N)r�r�r8)rr#r�r�rrrr��szLocationConfig._get_sectionscCsrz|��|�d�}Wnty,d}Yn0|s6tS|d}z|��||}Wntyhd}Yn0t|S)r��recurseT�:policyN)r�rbrhr��
_policy_value)rrcr:rF�
policy_key�policy_namerrrr��s

z!LocationConfig._get_option_policycCsL|d}t|}|dur*||��||<n||��|vrH|��||=dS)z>Set the policy for the given option name in the given section.rGN)�_policy_namer�)rrcr:Z
option_policyrIrJrrr�_set_option_policy�sz!LocationConfig._set_option_policycCs�|tttfvrtd||f��|����|��|j}|�d�rL|dd�}|��}||vrr|d|vrri||<n|d|vr�|d}||||<|�	|||�|�
�tdD]}||||�q�Wd�n1s�0YdS)r%zbad storage policy %r for %rr1Nr�r�)�STORE_LOCATION�STORE_LOCATION_NORECURSE�STORE_LOCATION_APPENDPATHrBrr�r7�endswithr�rLr�r�)rr(r1�storer7r�r�rrrr)�s,��


zLocationConfig.set_user_option)F)N)rrr r�rr8r
rur�r�r�rLrMr)rjrrr^rr<}s


r<cs�eZdZdZ�fdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zd2dd�Zd3dd�Zedfd d!�Zd4d"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Z�ZS)5�BranchConfigz6A configuration object giving the policy for a branch.cs<tt|���d|_d|_d|_||_|j|j|j	f|_
dSr")r\rRr�_location_config�_branch_data_config�_global_config�branch�_get_location_config�_get_branch_data_config�_get_global_config�option_sources�rrVr^rrr�s�zBranchConfig.__init__cCsdS)NrVrrlrrrr8�szBranchConfig.config_idcCs&|jdur t|j�|_|j|j_|jSr")rT�
TreeConfigrVr8rlrrrrX�s

z$BranchConfig._get_branch_data_configcCs|jdurt|jj�|_|jSr")rSr<rV�baserlrrrrW�s
z!BranchConfig._get_location_configcCs|jdurt�|_|jSr")rUr$rlrrrrYs
zBranchConfig._get_global_configcCs.|jD]"}t|�|��}|dur|SqdS)z�This returns a user option from local, tree or global config.

        They are tried in that order.  Use get_safe_value if trusted values
        are necessary.
        N)rZrO�rr:�sourcer1rrr�_get_best_value	s


zBranchConfig._get_best_valuecCs4|j|jfD]"}t|�|��}|dur|SqdS)a*This variant of get_best_value never returns untrusted values.

        It does not return values from the branch data, because the branch may
        not be controlled by the user.

        We may wish to allow locations.conf to control whether branches are
        trusted in the future.
        N)rWrYrOr^rrr�_get_safe_values
	
zBranchConfig._get_safe_valuecCs
|�d�S)z�Return the full user id for the branch.

        e.g. "John Hacker <jhacker@example.com>"
        This is looked up in the email controlfile for the branch.
        r��r`rlrrrr�$szBranchConfig._get_user_idcCs
|�d�S)Nrprbrlrrrrp,szBranchConfig._get_change_editorcCs
|�d�S)r�rzrbrlrrrrz/sz$BranchConfig._get_signature_checkingcCs
|�d�S)zSee Config._get_signing_policy.r{rbrlrrrr{3sz BranchConfig._get_signing_policycCs,|jD] }|��|�}|dur|SqdS)r�N)rZr�r^rrrr�7s


zBranchConfig._get_user_optionNccs(|jD]}|��|�D]
}|VqqdS)z"See IniBasedConfig.get_sections().N)rZr�)rr#r_rcrrrr�?s
zBranchConfig._get_sectionsc	cs�|����D]
}|Vq|��}|dur6d|��fg}|��}|D].\}}|��D]\}}|||||��fVqRqB|����D]
}|Vq~dSrf)rWr�rXr�r8r�rY)	rr�r(�
branch_configr8r�rcr#r1rrrr�Es�
zBranchConfig._get_optionsFcCs�|tkr|���||�n,|tkr4|���||�n|���|||�|sNdS|ttfvr�|���|�}|dur�t�	d||�n0|tkr�|��}|�|�}|dur�t�	d||�dS)Nz0Value "%s" is masked by "%s" from locations.confz-Value "%s" is masked by "%s" from branch.conf)
�STORE_BRANCHrX�
set_option�STORE_GLOBALrYr)rWr�r�r�)rr#r1rQZwarn_maskedZ
mask_valuercrrrr)Xs(�
�zBranchConfig.set_user_optioncCs|���||�dSr")rX�
remove_optionr#rrrroszBranchConfig.remove_user_optioncCs
|�d�S)r�r�)rarlrrrr�rszBranchConfig._post_commitcCs<|��}|dur|S|jjr$|jjSt�|jj�d�d�S)Nr1���)�_get_explicit_nicknamerVr#r��unescaper]rsr�rrrr�vszBranchConfig._get_nicknamecCs|��duS)z7Return true if a nickname has been explicitly assigned.N)rirlrrr�has_explicit_nickname~sz"BranchConfig.has_explicit_nicknamecCs
|�d�S)Nr�rbrlrrrri�sz#BranchConfig._get_explicit_nicknamecCs
|�d�S)rr�rbrlrrrr��szBranchConfig._log_formatcCs
|�d�S)rr�rbrlrrrr��sz(BranchConfig._validate_signatures_in_logcCs
|�d�S)rrrbrlrrrr�szBranchConfig._acceptable_keys)N)N)N)rrr r�rr8rXrWrYr`rar�rprzr{r�r�r�rdr)rr�r�rkrir�r�rrjrrr^rrR�s4


�

rRcCs0t�d|�}|dur|dfS|�d�|�d�fS)z9Parse e-mail username and return a (name, address) tuple.z(.*?)\s*<?([\w+.-]+@[\w+.-]+)>?Nr�rr)r�r?�group)r6r?rrr�parse_username�srmcCst|�\}}|st|��|S)a(Return just the address part of an email string.

    That is just the user@domain part, nothing else.
    This part is required to contain only ascii characters.
    If it can't be extracted, raises an error.

    >>> extract_email_address('Jane Tester <jane@test.com>')
    "jane@test.com"
    )rmr5)r-r#r�rrrr��s
r�c@s@eZdZdZdd�Zd
dd�Zddd�Zdd	d
�Zddd�ZdS)r\zDBranch configuration data associated with its contents, not locationcCs|��|_||_dSr")�_get_config�_configrVr[rrrr�s
zTreeConfig.__init__NcCs|durt�|�S|j��Sr")r�r�ro�_get_configobj)r�filerrrr��s
zTreeConfig._get_parsercCs>|j��� |j�|||�Wd�S1s00YdSr")rVZ	lock_readro�
get_option)rr#rcr�rrrrr�szTreeConfig.get_optioncCs>|j��� |j�|||�Wd�n1s00YdS)z%Set a per-branch configuration optionN)rVrrore)rr1r#rcrrrre�szTreeConfig.set_optioncCs<|j���|j�||�Wd�n1s.0YdSr")rVrrorgr#rrrrg�szTreeConfig.remove_option)N)NN)N)N)	rrr r�rr�rrrergrrrrr\�s


r\c@sjeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zdd
d�Z	ddd�Z
ddd�Zddd�Zdd�Z
dS)�AuthenticationConfigz�The authentication configuration file based on a ini file.

    Implements the authentication.conf file described in
    doc/developers/authentication-ring.txt.
    NcCs8d|_|dur(t��|_|_|��nd|_||_dSr")rorZauthentication_config_path�_input�	_filename�_check_permissions)rZ_filerrrr�s
zAuthenticationConfig.__init__c
Cs||jdur|jSzt|jdd�|_WnPtjyZ}zt|j|jj��WYd}~n$d}~0t	ytt
|j��Yn0|jS�NrLr�)rorNrtrMr�r)rr�r(�UnicodeErrorr'ru)rr-rrrrn�s
$z AuthenticationConfig._get_configc
Cs�zt�|j�}WnBtyR}z*|jtjkr<t�d|j|�WYd}~dSd}~00t�|j	�}tj
tjBtjBtj
BtjBtjB|@r�|jtvr�t��d�s�t�d|j�t�|j�dS)z<Check permission of auth file are user read/write able only.zUnable to stat %r: %rNZinsecure_permissionsz^The file '%s' has insecure file permissions. Saved passwords may be accessible by other users.)r��statru�OSError�errnoZENOENTr�r��S_IMODE�st_mode�S_IXOTH�S_IWOTH�S_IROTH�S_IXGRP�S_IWGRP�S_IRGRP�(_authentication_config_permission_errorsr$r�r��add)r�str-�moderrrrv�s.���
���z'AuthenticationConfig._check_permissionscCsftj�|j�}t�|�t�|jtjtjBd�}z&t�	|d�}|�
��|�W|��n
|��0dS)z7Save the config file, only tests should use it for now.i��wbN)
r�r�r	rurr
�open�O_RDWR�O_CREAT�fdopenrnr�close)rr�fd�frrr�_saves
zAuthenticationConfig._savecCs>|��}|�|�}|dur*i||<||}|||<|��dS)z*Set an authentication configuration optionN)rnr�r�)rr�r:r1rRrcrrrr's
z AuthenticationConfig._set_optionc
Cs�d}|����D�]�\}}	t|	tj�s2td|��t|	jgd��\}
}}}
z|	�d�}Wn2t	ynd}Ynty�td|��Yn0z|	�
d�}Wn2t	y�d}Ynty�td|��Yn0|
dur�||
kr�q|du�r||k�s|�d	�r|�|��sq|du�r"||k�r"q|
du�rD|du�rD|�|
��sDq|du�rd|du�rd||k�rdq|du�rpqt
|||
|||||	�d
d�|d�	}|�||	�dd��d
tjv�r�t�d|��q�q|du�r�t�||||||�}|S)atReturns the matching credentials from authentication.conf file.

        :param scheme: protocol

        :param host: the server address

        :param port: the associated port (optional)

        :param user: login (optional)

        :param path: the absolute path on the server (optional)

        :param realm: the http authentication realm (optional)

        :return: A dict containing the matching credentials or None.
           This includes:
           - name: the section name of the credentials in the
             authentication.conf file,
           - user: can't be different from the provided user if any,
           - scheme: the server protocol,
           - host: the server address,
           - port: the server port (can be None),
           - path: the absolute server path (can be None),
           - realm: the http specific authentication realm (can be None),
           - password: the decoded password, could be None if the credential
             defines only the user
           - verify_certificates: https specific, True if the server
             certificate should be verified, False otherwise.
        Nz%s defined outside a section)�scheme�host�userr��portz'port' not numeric in %s�verify_certificatesTz''verify_certificates' not boolean in %s�.�password)	r#r�r�r�r�r��realmr�r�Zpassword_encodingZauthz Using authentication section: %r)rnr�rPrM�SectionrB�mapr�Zas_intrhrbr�rPr��decode_password�debug�debug_flagsr�r��credential_store_registry�get_fallback_credentials)rr�r�r�r�r�r��credentialsZ
auth_def_nameZauth_defZa_schemeZa_hostZa_userZa_pathZa_portZa_verify_certificatesrrr�get_credentialss��
��


����

�

�
�z$AuthenticationConfig.get_credentialsc
Cs�||d�}
|dur||
d<|dur*||
d<|dur>d||
d<|durN||
d<|durbt|�|
d<|	durr|	|
d	<|��}|��D]0\}}
d
D]}|
�|�|
�|�kr�q�q�||=q�|�||
i�|��dS)ahSet authentication credentials for a host.

        Any existing credentials with matching scheme, host, port and path
        will be deleted, regardless of name.

        :param name: An arbitrary name to describe this set of credentials.
        :param host: Name of the host that accepts these credentials.
        :param user: The username portion of these credentials.
        :param scheme: The URL scheme (e.g. ssh, http) the credentials apply
            to.
        :param password: Password portion of these credentials.
        :param port: The IP port on the host that these credentials apply to.
        :param path: A filesystem path on the host that these credentials
            apply to.
        :param verify_certificates: On https, verify server certificates if
            True.
        :param realm: The http authentication realm (optional).
        �r�r�Nr�r�z%dr�r�r�r�)r�r�r�r�r�)rQrnr�r��updater�)rr#r�r�r�r�r�r�r�r��valuesr�rcZexisting_valuesrdrrr�set_credentials|s*
z$AuthenticationConfig.set_credentialsFc	Cs�|j|||d||d�}	|	dur(|	d}
nd}
|
dur�|r~|durRd|��fd}|durhd||f}n|}tjj||d�}
n|}
|
S)aGet a user from authentication file.

        :param scheme: protocol

        :param host: the server address

        :param port: the associated port (optional)

        :param realm: the realm sent by the server (optional)

        :param path: the absolute path on the server (optional)

        :param ask: Ask the user if there is no explicitly configured username
                    (optional)

        :param default: The username returned if none is defined (optional).

        :return: The found user.
        N)r�r�r�r��%sz %(host)s username�%s:%d)r�)r��upperr��
ui_factoryZget_username)rr�r�r�r�r��promptZaskr�r�r��prompt_hostrrr�get_user�s �
zAuthenticationConfig.get_usercCs�|�||||||�}|durL|d}	|	durP|dkrPt�d|d�d}	nd}	|	dur�|durpd|��d}|dur�d||f}
n|}
tjj||
|d	�}	|	S)
a�Get a password from authentication file or prompt the user for one.

        :param scheme: protocol

        :param host: the server address

        :param port: the associated port (optional)

        :param user: login

        :param realm: the realm sent by the server (optional)

        :param path: the absolute path on the server (optional)

        :return: The found password or the one entered by the user.
        Nr��sshz:password ignored in section [%s], use an ssh agent insteadr#r�z %(user)s@%(host)s passwordr�r�)r�r�r�r�r�r��get_password)rr�r�r�r�r�r�r�r�r�r�rrrr��s2�����z!AuthenticationConfig.get_passwordcCs@zt�|�}Wnty,td|��Yn0|�|�|d<|S)Nz#%r is not a known password_encodingr�)r��get_credential_storerhrBr�)rr�ra�csrrrr��sz$AuthenticationConfig.decode_password)N)NNNN)NNNNNN)NNNNFN)NNNN)rrr r�rrnrvr�r'r�r�r�r�r�rrrrrs�s(


�
c�
,�
*�
,rscsLeZdZdZddd�Zdd�Zddd�Zd�fd
d�	Zd�fdd
�	Z�Z	S)�CredentialStoreRegistryaA class that registers credential stores.

    A credential store provides access to credentials via the password_encoding
    field in authentication.conf sections.

    Except for stores provided by brz itself, most stores are expected to be
    provided by plugins that will therefore use
    register_lazy(password_encoding, module_name, member_name, help=help,
    fallback=fallback) to install themselves.

    A fallback credential store is one that is queried if no credentials can be
    found via authentication.conf.
    NcCs|�|�}t|�r|�}|Sr")r��callable)rrar�rrrr�s
z,CredentialStoreRegistry.get_credential_storecCs
|�|�S)z@Check if the named credentials store should be used as fallback.)Zget_infor&rrr�is_fallbacksz#CredentialStoreRegistry.is_fallbackc
	CsLd}|��D]:}|�|�sq|�|�}	|	�||||||�}|durqHq|S)z�Request credentials from all fallback credentials stores.

        The first credentials store that can provide credentials wins.
        N)�keysr�r�r�)
rr�r�r�r�r�r�r�r#r�rrrr� s

�z0CredentialStoreRegistry.get_fallback_credentialsFcstt|�j|||||d�S)a�Register a new object to a name.

        :param key: This is the key to use to request the object later.
        :param obj: The object to register.
        :param help: Help text for this entry. This may be a string or
                a callable. If it is a callable, it should take two
                parameters (registry, key): this registry and the key that
                the help was registered under.
        :param override_existing: Raise KeyErorr if False and something has
                already been registered for that key. If True, ignore if there
                is an existing key (always register the new value).
        :param fallback: Whether this credential store should be
                used as fallback.
        ��info�override_existing)r\r��register)rrd�obj�helpr��fallbackr^rrr�2s��z CredentialStoreRegistry.registercstt|�j||||||d�S)a�Register a new credential store to be loaded on request.

        :param module_name: The python path to the module. Such as 'os.path'.
        :param member_name: The member of the module to return.  If empty or
                None, get() will return the module itself.
        :param help: Help text for this entry. This may be a string or
                a callable.
        :param override_existing: If True, replace the existing object
                with the new one. If False, if there is already something
                registered with the same key, raise a KeyError
        :param fallback: Whether this credential store should be
                used as fallback.
        r�)r\r��
register_lazy)rrd�module_name�member_namer�r�r�r^rrr�Fs
�z%CredentialStoreRegistry.register_lazy)N)NNNN)NFF)NFF)
rrr r�r�r�r�r�r�rjrrr^rr�s
�
��r�c@s"eZdZdZdd�Zddd�ZdS)�CredentialStorez6An abstract class to implement storage for credentialscCst|j��dS)z;Returns a clear text password for the provided credentials.N)rmr��rr�rrrr�aszCredentialStore.decode_passwordNcCst|j��dS)z�Return the matching credentials from this credential store.

        This method is only called on fallback credential stores.
        N)rmr�)rr�r�r�r�r�r�rrrr�eszCredentialStore.get_credentials)NNNN)rrr r�r�r�rrrrr�^s
�r�c@seZdZdZdd�ZdS)�PlainTextCredentialStorez<Plain text credential store for the authentication.conf filecCs|dS�z$See CredentialStore.decode_password.r�rr�rrrr�qsz(PlainTextCredentialStore.decode_passwordN�rrr r�r�rrrrr�nsr��plain�r�c@seZdZdZdd�ZdS)�Base64CredentialStorez8Base64 credential store for the authentication.conf filecCst�|d�Sr�)�base64Zstandard_b64decoder�rrrr�~sz%Base64CredentialStore.decode_passwordNr�rrrrr�{sr�r�c@s$eZdZdd�Zdd�Zdd�ZdS)�BzrDirConfigcCs||_|��|_dSr")�_bzrdirrnro�r�bzrdirrrrr�szBzrDirConfig.__init__cCsD|jdurt�d|j��|dur2|j�dd�n|j�|d�dS)z�Set the default stacking location.

        It may be set to a location, or None.

        This policy affects all branches contained by this control dir, except
        for those under repositories.
        NzCannot set configuration in %sr��default_stack_on)rorr3r�rer�rrr�set_default_stack_on�s
�z!BzrDirConfig.set_default_stack_oncCs*|jdurdS|j�d�}|dkr&d}|S)z�Return the default stacking location.

        This will either be a location, or None.

        This policy affects all branches contained by this control dir, except
        for those under repositories.
        Nr�r�)rorrr�rrr�get_default_stack_on�s
z!BzrDirConfig.get_default_stack_onN)rrr rr�r�rrrrr��sr�c@sVeZdZdZdd�Zddd�Zddd�Zdd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�TransportConfiga	A Config that reads/writes a config file on a Transport.

    It is a low-level object that considers config data to be name/value pairs
    that may be associated with a section.  Assigning meaning to these values
    is done at higher levels like TreeConfig.
    cCs||_||_dSr")�
_transportru)rrr(rrrr�szTransportConfig.__init__NcCsd|��}|dur|}n$z||}Wnty8|YS0|�||�}tdD]}||||�qN|S)aReturn the value associated with a named option.

        :param name: The name of the value
        :param section: The section the option is in (if any)
        :param default: The value to return if the value is not set
        :return: The value or default value
        Nr�)rprhr�r�)rr#rcr�rMZsection_objr1r�rrrrr�s
zTransportConfig.get_optioncCsR|��}|dur|||<n||�|i�|<tdD]}||||�q2|�|�dS)z�Set the value associated with a named option.

        :param value: The value to set
        :param name: The name of the value to set
        :param section: The section the option is in (if any)
        Nr�)rpr/r��_set_configobj)rr1r#rcrMr�rrrre�s
zTransportConfig.set_optioncCsH|��}|dur||=n
|||=tdD]}|||�q*|�|�dS)Nr�)rpr�r�)rr:r�rMr�rrrrg�s
zTransportConfig.remove_optioncCs�z.t|j�|j��}tdD]}||�q|WStjyHt�YStjy�t�	dt
�t
�|jj
|j�d��t�YS0dS)Nr�z=Permission denied while trying to open configuration file %s.rL)rr��	get_bytesrur�r�
NoSuchFile�PermissionDeniedr�r�r�Zunescape_for_displayrr])rr�r�rrr�_get_config_file�s 

��z TransportConfig._get_config_filecCst�|j��|j�Sr")r�rr��external_urlrurlrrr�
_external_url�szTransportConfig._external_urlc
Cs�|��}zpzt|dd�}WnRtjyP}zt|j|����WYd}~n&d}~0tylt|����Yn0W|�	�n
|�	�0|Srw)
r�rNrMr�r)rr�r�r'r�)rr�rRr-rrrrp�s$zTransportConfig._get_configobjcCsDt�}|�|�|�d�|j�|j|�tdD]}||�q2dS)Nrr�)rr�seekr�Zput_filerur�)rrMZout_filer�rrrr�s

zTransportConfig._set_configobj)NN)N)N)rrr r�rrrrergr�r�rpr�rrrrr��s




r�c@sPeZdZdZddd�Zedd��Zdd	�Zd
d�Zdd
�Z	dd�Z
ddd�ZdS)�Optiona6An option definition.

    The option *values* are stored in config files and found in sections.

    Here we define various properties about the option itself, its default
    value, how to convert it from stores, what to do when invalid values are
    encoutered, in which config files it can be stored.
    NTc		Cs�|durg}|durg}||_||_|dur4d|_n^t|t�rR|rJtd��d|_n@t|tttt	t
f�rtd|f|_nt|�r�||_ntd|f��||_||_
||_||_|r�|dvr�td|f��||_dS)a�Build an option definition.

        :param name: the name used to refer to the option.

        :param override_from_env: A list of environment variables which can
           provide override any configuration setting.

        :param default: the default value to use when none exist in the config
            stores. This is either a string that ``from_unicode`` will convert
            into the proper type, a callable returning a unicode string so that
            ``from_unicode`` can be used on the return value, or a python
            object that can be stringified (so only the empty list is supported
            for example).

        :param default_from_env: A list of environment variables which can
           provide a default value. 'default' will be used only if none of the
           variables specified here are set in the environment.

        :param help: a doc string to explain the option to the user.

        :param from_unicode: a callable to convert the unicode string
            representing the option value in a store or its default value.

        :param invalid: the action to be taken when an invalid value is
            encountered in a store. This is called only when from_unicode is
            invoked to convert a string and returns None or raise ValueError or
            TypeError. Accepted values are: None (ignore invalid values),
            'warning' (emit a warning), 'error' (emit an error message and
            terminates).

        :param unquote: should the unicode value be unquoted before conversion.
           This should be used only when the store providing the values cannot
           safely unquote them (see http://pad.lv/906897). It is provided so
           daughter classes can handle the quoting themselves.
        Nz0Only empty lists are supported as default values�,r�z&%r is not supported as a default value)r��errorz%s not supported for 'invalid')r#�override_from_envr�rPr�r�rr�bool�int�floatr��default_from_env�_help�from_unicode�unquote�invalid)	rr#r�r�r�r�r�r�r�rrrrs8&
��zOption.__init__cCs|jSr")r�rlrrrr�eszOption.helpc	Cs�|jr |dur |dur |�|�}|jdus2|dur6|Sz|�|�}Wnttfy^d}Yn0|dur�|jdur�|jdkr�t�d||j�n|jdkr�t|j|��|S)Nr�z Value "%s" is not valid for "%s"r�)	r�r�rB�	TypeErrorr�r�r�r#r0)rrQZ
unicode_valueZ	convertedrrr�convert_from_unicodeis 


�
zOption.convert_from_unicodec	CsRd}|jD]B}z&tj|}ts,|�t���}WqNWq
tyJYq
Yq
0q
|Sr")r�r�r�r
rSr�r�rh�rr1�varrrr�get_override}s


zOption.get_overridec	Cs�d}|jD]B}z&tj|}ts,|�t���}WqNWq
tyJYq
Yq
0q
|dur�t|j	�r�|�	�}t
|t�s�td|j
��n|j	}|S)Nz1Callable default value for '%s' should be unicode)r�r�r�r
rSr�r�rhr�r�rPrr�r#r�rrr�get_default�s(




��zOption.get_defaultcCs|jSr"r%rlrrr�get_help_topic�szOption.get_help_topiccCs2|j}ddlm}||�|�7}|r.|�|�}|S)Nr)�help_topics)r�ror�Z_format_see_alsoZhelp_as_plain_text)rZadditional_see_alsor�rTr�rrr�
get_help_text�s
zOption.get_help_text)NNNNNNT)NT)rrr r�r�propertyr�r�r�r�r�r�rrrrr�s	�
G

r�cCs
t�|�Sr")r�r���unicode_strrrr�bool_from_store�sr�cCst|�Sr")r�r�rrr�int_from_store�sr�i�i@Biʚ;)�K�M�GcCs�dd�t�d}t�|tj�}|�|�}d}|dur�|��\}}}t|�}|r�zt|��}Wn$t	y�t
td��|���Yn0||9}|S)aZConvert a human readable size in SI units, e.g 10MB into an integer.

    Accepted suffixes are K,M,G. It is case-insensitive and may be followed
    by a trailing b (i.e. Kb, MB). This is intended to be practical and not
    pedantic.

    :return Integer, expanded to its base-10 value if a proper SI unit is
        found, None otherwise.
    z	^(\d+)(([r�z])b?)?$Nz{0} is not an SI unit.)
r�_unit_suffixesr�r��
IGNORECASEr?�groupsr�r�rhrB�gettext�format)r�Zregexp�p�mr�r�ZunitZcoeffrrr�int_SI_from_store�s 

�
r�cCst|�Sr")r�r�rrr�float_from_store�sr�rLTF)ra�list_valuesr[cs&eZdZd�fdd�	Zdd�Z�ZS)�
ListOptionNc	s$tt|�j||||j||dd�dS)z�A list Option definition.

        This overrides the base class so the conversion from a unicode string
        can take quoting into account.
        F�r�r�r�r�r�r�N)r\rrr�)rr#r�r�r�r�r^rrr�s

�zListOption.__init__cCsTt|t�st�t��t�d|fg�td}t|t�rL|rF|g}qPg}n|}|S)Nzlist=%sr�)rPrr��_list_converter_config�reset�_parse)rr�Z
maybe_listr�rrrr��s

zListOption.from_unicode)NNNN)rrr rr�rjrrr^rr�s�rcs6eZdZdZd	�fdd�	Zdd�Zedd��Z�ZS)
�RegistryOptionz$Option for a choice from a registry.Nc	s2tt|�j|�fdd�||j||dd��|_dS)z�A registry based Option definition.

        This overrides the base class so the conversion from a unicode string
        can take quoting into account.
        cs�jSr")�default_keyr�r
rrr@	r/z)RegistryOption.__init__.<locals>.<lambda>FrN)r\rrr�r
)rr#r
r�r�r�r^rrr	s
�zRegistryOption.__init__cCsFt|t�st�z|j�|�WSty@td||jf��Yn0dS)Nz?Invalid value %s for %s.See help for a list of possible values.)rPrr�r
r�rhrBr#)rr�rrrr�	s
���zRegistryOption.from_unicodecCs>|jdg}|j��D]}|�d||j�|�f�qd�|�S)Nz&

The following values are supported:
z	 %s - %s
r�)r�r
r�r��get_helpr)rZretrdrrrr� 	s
zRegistryOption.help)NNN)	rrr r�rr�r�r�rjrrr^rr	s�rz({[^\d\W](?:\.\w|-\w|\w)*})ccs(d}t�|�D]}||fV|}qdSr)�_option_ref_rers)r�is_refr�rrr�iter_option_refs2	s
rcs>eZdZdZdd�Z�fdd�Z�fdd�Zdd	d
�Z�ZS)�OptionRegistryz�Register config options by their name.

    This overrides ``registry.Registry`` to simplify registration by acquiring
    some information from the option object itself.
    cCst�d|�durt|��dS)z\Ensures an option name is valid.

        :param option_name: The name to validate.
        z{%s}N)r	r?r$r;rrr�_check_option_nameA	sz!OptionRegistry._check_option_namecs*|�|j�tt|�j|j||jd�dS)zxRegister a new option to its name.

        :param option: The option to register. Its name is used as the key.
        r�N)r
r#r\rr�r�)rr(r^rrr�I	s�zOptionRegistry.registercs"|�|�tt|��|||�dS)a�Register a new option to be loaded on request.

        :param key: the key to request the option later. Since the registration
            is lazy, it should be provided and match the option name.

        :param module_name: the python path to the module. Such as 'os.path'.

        :param member_name: the member of the module to return.  If empty or
                None, get() will return the module itself.
        N)r
r\rr�)rrdr�r�r^rrr�R	s
�zOptionRegistry.register_lazyNcCs&|�|�}|j}t|�r"|||�S|S)z/Get the help text associated with the given key)r�r�r�)rrdr(Zthe_helprrrra	s


zOptionRegistry.get_help)N)	rrr r�r
r�r�rrjrrr^rr:	s
	rZappend_revisions_onlyr�z�Whether to only append revisions to the mainline.

If this is set to true, then it is not possible to change the
existing mainline of the branch.
)r�r�r�r�rz@List of GPG key patterns which are acceptable for verification.
)r�r�zadd.maximum_file_sizeZ20MBz�Size above which files should be added manually.

Files below this size are added automatically when using ``bzr add`` without
arguments.

A negative value means disable the size check.
)r�r�r��boundz�Is the branch bound to ``bound_location``.

If set to "True", the branch should act as a checkout, and push each commit to
the bound_location.  This option is normally set by ``bind``/``unbind``.

See also: bound_location.
Zbound_locationz~The location that commits should go to when acting as a checkout.

This option is normally set by ``bind``.

See also: bound.
zbranch.fetch_tagsz:Whether revisions associated with tags should be fetched.
ztransform.orphan_policyzbreezy.transformZopt_transform_orphanz"bzr.workingtree.worth_saving_limit�
a^How many changes before saving the dirstate.

-1 means that we will never rewrite the dirstate file for only
stat-cache changes. Regardless of this setting, we will always rewrite
the dirstate file if a file is added/removed/renamed/etc. This flag only
affects the behavior of updating the dirstate file after we notice that
a file has been touched.
Z
bugtrackerz�Default bug tracker to use.

This bug tracker will be used for example when marking bugs
as fixed using ``bzr commit --fixes``, if no explicit
bug tracker was specified.
Zcalculate_revnosaCalculate revision numbers if they are not known.

Always show revision numbers, even for branch formats that don't store them
natively (such as Git). Calculating the revision number requires traversing
the left hand ancestry of the branch and can be slow on very large branches.
r�z�GPG checking policy.

Possible values: require, ignore, check-available (default)

this option will control whether bzr will require good gpg
signatures, ignore them, or check them if they are
present.
Zchild_submit_formatz3The preferred format of submissions to this branch.Zchild_submit_toz/Where submissions to this branch are mailed to.r�z�GPG Signing policy.

Possible values: always, never, when-required (default)

This option controls whether bzr will always create
gpg signatures or not on commits.
zdirstate.fdatasyncaFlush dirstate changes onto physical disk?

If true (default), working tree metadata changes are flushed through the
OS buffers to physical disk.  This is somewhat slower, but means data
should not be lost if the machine crashes.  See also repository.fdatasync.
r�zDebug flags to activate.Zdefault_formatZ2az#Format used when creating branches.Zeditorz:The command called to launch an editor to enter a message.r�r�r�zThe users identity)r�r�r�Zgpg_signing_keyz]GPG key to use for signing.

This defaults to the first key associated with the users email.
Zlanguagez$Language to translate messages into.zlocks.steal_deada�Steal locks that appears to be dead.

If set to True, bzr will check if a lock is supposed to be held by an
active process from the same user on the same machine. If the user and
machine match, but no process with the given PID is active, then bzr
will automatically break the stale lock, and create a new lock for
this process.
Otherwise, bzr will prompt as normal to break the lock.
rZlongz�Log format to use when displaying revisions.

Standard log formats are ``long``, ``short`` and ``line``. Additional formats
may be provided by plugins.
Zmail_clientzbreezy.mail_clientZopt_mail_clientZoutput_encodingzAUnicode encoding for output (terminal encoding if not specified).Zparent_locationz�The location of the default branch for pull or merge.

This option is normally set when creating a branch, the first ``pull`` or by
``pull --remember``.
rz�Post commit functions.

An ordered list of python functions to call, separated by spaces.

Each function takes branch, rev_id as parameters.
Zprogress_barzbreezy.ui.textZopt_progress_barZ
public_branchz�A publically-accessible version of this branch.

This implies that the branch setting this option is not publically-accessible.
Used and set by ``bzr send``.
Z
push_locationzxThe location of the default branch for push.

This option is normally set by the first ``push`` or ``push --remember``.
Zpush_strictz�The default value for ``push --strict``.

If present, defines the ``--strict`` option default value for checking
uncommitted changes before sending a merge directive.
zrepository.fdatasyncz�Flush repository changes onto physical disk?

If true (default), repository changes are flushed through the OS buffers
to physical disk.  This is somewhat slower, but means data should not be
lost if the machine crashes.  See also dirstate.fdatasync.
Zsmtp_serverzbreezy.smtp_connectionZ
smtp_passwordZ
smtp_usernamezselftest.timeoutZ600z>Abort selftest if one test takes longer than this many secondsZsend_strictz�The default value for ``send --strict``.

If present, defines the ``--strict`` option default value for checking
uncommitted changes before sending a bundle.
zserve.client_timeoutg�r@ziIf we wait for a new request from a client for more than X seconds, consider the client idle, and hangup.r�ZBRZ_SSHzSSH vendor to use.)r�r�r�Zstacked_on_locationz-The location where this branch is stacked on.Z
submit_branchz�The branch you intend to submit your current work to.

This is automatically set by ``bzr send`` and ``bzr merge``, and is also used
by the ``submit:`` revision spec.
Z	submit_toz1Where submissions from this branch are mailed to.r�z$List of warning classes to suppress.r�z*Whether to validate signatures in brz log.zssl.ca_certszbreezy.transport.httpZopt_ssl_ca_certsz
ssl.cert_reqsZopt_ssl_cert_reqsc@s2eZdZdZdd�Zddd�Zdd	�Zd
d�ZdS)
r�z�A section defines a dict of option name => value.

    This is merely a read-only dict which can add some knowledge about the
    options. It is *not* a python dict object though and doesn't try to mimic
    its API.
    cCs||_||_dSr")�id�options�r�
section_idrrrrr�
szSection.__init__NTcCs|j�||�Sr")rr�)rr#r�r�rrrr��
szSection.getccs|j��D]
}|Vq
dSr")rr�)r�krrr�iter_option_names�
szSection.iter_option_namescCsd|jj|jfS)Nz<config.%s id=%s>�r_rrrlrrr�__repr__�
szSection.__repr__)NT)rrr r�rr�rrrrrrr��
s

r�cs@eZdZdZ�fdd�Zdd�Zdd�Zdd	�Zd
d�Z�Z	S)�MutableSectionzDA section allowing changes and keeping track of the original values.cstt|��||�|��dSr")r\rr�
reset_changesrr^rrr�
szMutableSection.__init__cCs@||jvrt|j|<n||jvr2|�|d�|j|<||j|<dSr")r�_NewlyCreatedOption�origr�r4rrrr��
s


zMutableSection.setcCs2||jvr&||jvr&|�|d�|j|<|j|=dSr")rrr�r&rrrr��
szMutableSection.removecCs
i|_dSr")rrlrrrr�
szMutableSection.reset_changescCs�|j��D]�\}}|�|t�}|�|t�}|turH||jvrT|�|�n|�||�||kr
|turhd}|turtd}|tur�d}t�	t
d�||j|�
�|||���q
|��dS)a(Apply option value changes.

        ``self`` has been reloaded from the persistent storage. ``dirty``
        contains the changes made since the previous loading.

        :param dirty: the mutable section containing the changes.

        :param store: the store containing the section
        z	<DELETED>z	<CREATED>zZOption {0} in section {1} of {2} was changed from {3} to {4}. The {5} value will be saved.N)r�itemsr��_DeletedOptionrrr�r�r�r�r�r�rr�r)r�dirtyrQrZexpectedZactualZreloadedrrr�
apply_changes�
s*

��zMutableSection.apply_changes)
rrr r�rr�r�rrrjrrr^rr�
src@s�eZdZdZeZeZdd�Zdd�Z	dd�Z
dd	�Zd
d�Zdd
�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd!dd�Zdd �ZdS)"�StorezCAbstract interface to persistent storage for configuration options.cCs
i|_dSr")�dirty_sectionsrlrrrr�
szStore.__init__cCst|j��dS)z�Returns True if the Store has been loaded.

        This is used to implement lazy loading and ensure the persistent
        storage is queried only when needed.
        N)rm�	is_loadedrlrrrr"�
szStore.is_loadedcCst|j��dS)z(Loads the Store from persistent storage.N)rmr�rlrrrr�sz
Store.loadcCst|j��dS)zyCreate a store from a string in configobj syntax.

        :param bytes: A string representing the file content.
        N)rm�_load_from_string)r�bytesrrrr#szStore._load_from_stringcCst|j��dS)z�Unloads the Store.

        This should make is_loaded() return False. This is used when the caller
        knows that the persistent storage has changed or may have change since
        the last load.
        N)rm�unloadrlrrrr%szStore.unloadcCs|S)z�Quote a configuration option value for storing purposes.

        This allows Stacks to present values as they will be stored.
        rr�rrrrXszStore.quotecCs|S)zlUnquote a configuration option value into unicode.

        The received value is quoted as stored.
        rr�rrrr�sz
Store.unquotecCst|j��dS)z&Saves the Store to persistent storage.N)rmr�rlrrrr�&sz
Store.savecCs |j��D]}|jr
dSq
dS�NTF)r!r�r)rr�rrr�_need_saving*szStore._need_savingcCs:|��|��D]\}}|�|�}|�||�qi|_dS)a)Apply changes from dirty sections while checking for coherency.

        The Store content is discarded and reloaded from persistent storage to
        acquire up-to-date values.

        Dirty sections are MutableSection which kept track of the value they
        are expected to update.
        N)r%r�get_mutable_sectionrr!)rr!rrZcleanrrrr1s

zStore.apply_changescCst|j��dS)z�Saves the Store to persistent storage if changes occurred.

        Apply the changes recorded in the mutable sections to a store content
        refreshed from persistent storage.
        N)rm�save_changesrlrrrr)EszStore.save_changescCst|j��dSr")rmr�rlrrrr�MszStore.external_urlcCst|j��dS)znReturns an ordered iterable of existing sections.

        :returns: An iterable of (store, section).
        N)rm�get_sectionsrlrrrr*PszStore.get_sectionsNcCst|j��dS)zbReturns the specified mutable section.

        :param section_id: The section identifier
        N)rmr()rrrrrr(WszStore.get_mutable_sectioncCsd|jj|��fS�Nz<config.%s(%s)>)r_rr�rlrrrr^s�zStore.__repr__)N)rrr r�r��readonly_section_classr�mutable_section_classrr"r�r#r%rXr�r�r'rr)r�r*r(rrrrrr �
s$	
r csBeZdZdZd
�fdd�	Zdd�Zdd�Zd	d
�Zdd�Z�Z	S)�CommandLineStorez?A store to carry command line overrides for the config options.Ncs*tt|���|duri}i|_d|_dS�Nrr)r\r.rrr)rZoptsr^rrrgs
zCommandLineStore.__init__cCs|j��dSr")r�clearrlrrr�_resetnszCommandLineStore._resetc	Cs\|��|D]J}z|�dd�\}}Wn&tyJt�td�|f��Yn0||j|<qdS)N�=rz0Invalid '%s', should be of the form 'name=value')r1rsrBr�BzrCommandErrorr�r)rZ	overridesZoverr#r1rrr�
_from_cmdliners��
zCommandLineStore._from_cmdlinecCsdSr/rrlrrrr�~szCommandLineStore.external_urlccs||�d|j�fVdSr")r,rrlrrrr*�szCommandLineStore.get_sections)N)
rrr r�rr1r4r�r*rjrrr^rr.dsr.cs�eZdZdZ�fdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
ddd�Zdd�Zdd�Zdd�Z�ZS) �IniFileStorez�A config Store using ConfigObj for storage.

    :ivar _config_obj: Private member to hold the ConfigObj instance used to
        serialize/deserialize the config file.
    cstt|���d|_dS)z4A config Store using ConfigObj for storage.
        N)r\r5r�_config_objrlr^rrr�szIniFileStore.__init__cCs
|jduSr")r6rlrrrr"�szIniFileStore.is_loadedcCsd|_i|_dSr")r6r!rlrrrr%�szIniFileStore.unloadcCst|j��dS)zqLoad the config file bytes.

        This should be provided by subclasses

        :return: Byte string
        N)rm�
_load_contentrlrrrr7�szIniFileStore._load_contentcCst|j��dS)z�Save the config file bytes.

        This should be provided by subclasses

        :param content: Config file bytes to write
        N)rm�
_save_content�r�contentrrrr8�szIniFileStore._save_contentcCs8|��rdS|��}|�|�tdD]}||�q&dS)z(Load the store from the associated file.Nr�)r"r7r#r�)rr:r�rrrr��s
zIniFileStore.loadc
Cs�|��rtd|jf��t|�}zt|ddd�|_WnXtjyp}z"d|_t|j|�	���WYd}~n&d}~0t
y�t|�	���Yn0dS)zlCreate a config store from a string.

        :param bytes: A string representing the file content.
        zAlready loaded: %rrLF)rar�N)r"r�r6rrNrMr�r)rr�r�r')rr$r�r-rrrr#�s�$zIniFileStore._load_from_stringcCs8|��sdS|��sdS|j��}|�|�|��dSr")r"r'r!�copyrr�)rr!rrrr)�s

zIniFileStore.save_changescCsF|��sdSt�}|j�|�|�|���tdD]}||�q4dS)Nr�)r"rr6rr8�getvaluer�)r�outr�rrrr��szIniFileStore.savec	csnz|��Wntjtjfy(YdS0|j}|jrH||�d|�fV|jD]}||�|||�fVqNdS)ziGet the configobj section in the file order.

        :returns: An iterable of (store, section).
        N)r�rr�r�r6Zscalarsr,r�)rZcobjr�rrrr*�s
��zIniFileStore.get_sectionsNcCsxz|��Wntjy*|�d�Yn0||jvr@|j|S|durP|j}n|j�|i�}|�||�}||j|<|S)Nr/)r�rr�r#r!r6r/r-)rrrcZmutable_sectionrrrr(�s


z IniFileStore.get_mutable_sectioncCs.zd|j_|j�|�Wd|j_Sd|j_0dSr&)r6r�r�r�rrrrXs�zIniFileStore.quotecCs|rt|t�r|j�|�}|Sr")rPrr6Z_unquoter�rrrr�szIniFileStore.unquotecCsdS)NzIn-Process Store, no URLrrlrrrr�szIniFileStore.external_url)N)rrr r�rr"r%r7r8r�r#r)r�r*r(rXr�r�rjrrr^rr5�s			

r5cs8eZdZdZ�fdd�Zdd�Zdd�Zdd	�Z�ZS)
�TransportIniFileStorez�IniFileStore that loads files from a transport.

    :ivar transport: The transport object where the config file is located.

    :ivar file_name: The config file basename in the transport directory.
    cstt|���||_||_dS)z�A Store using a ini file on a Transport

        :param transport: The transport object where the config file is located.
        :param file_name: The config file basename in the transport directory.
        N)r\r>rrr�)rrr�r^rrr#szTransportIniFileStore.__init__cCs<z|j�|j�WStjy6t�d|����Yn0dS)Nz>Permission denied while trying to load configuration store %s.)rr�r�rr�r�r�r�rlrrrr7-s�z#TransportIniFileStore._load_contentcCs|j�|j|�dSr")rZ	put_bytesr�r9rrrr85sz#TransportIniFileStore._save_contentcCst�|j��t�|j��Sr")r�rrr��escaper�rlrrrr�8s�z"TransportIniFileStore.external_url)	rrr r�rr7r8r�rjrrr^rr>s

r>csPeZdZdZd�fdd�	Zddd�Zdd�Zd	d
�Zdd�Z�fd
d�Z	�Z
S)�LockableIniFileStorez?A ConfigObjStore using locks on save to ensure store integrity.Ncs:|durd}||_tt|��||�t�|j|j�|_dS)z�A config Store using ConfigObj for storage.

        :param transport: The transport object where the config file is located.

        :param file_name: The config file basename in the transport directory.
        Nr)�
lock_dir_namer\r@rrrrr)rrr�rAr^rrrKs
zLockableIniFileStore.__init__cCs$|j��|j�|�}t�|j|�Sr)rZ
create_prefixrrrrrrrrrrXs
zLockableIniFileStore.lock_writecCs|j��dSr"rrlrrrrdszLockableIniFileStore.unlockcCs|j��dSr"r rlrrrr!gszLockableIniFileStore.break_lockcCs4|���|��Wd�n1s&0YdSr")r�save_without_lockingrlrrrr�js
zLockableIniFileStore.savecstt|���dSr")r\r@r�rlr^rrrBosz)LockableIniFileStore.save_without_locking)N)N)rrr r�rrrr!r�rBrjrrr^rr@Hs
r@cs"eZdZdZd�fdd�	Z�ZS)�GlobalStorez_A config store for global options.

    There is a single GlobalStore for a given process.
    Ncs:t��\}}tj||d�}tt|��||d�d|_dS)N��possible_transportsz.confro)rZ_config_dirrrr\rCrr)rrEr��kind�tr^rrr�s�zGlobalStore.__init__)Nr�rrr^rrC{srCcs"eZdZdZd�fdd�	Z�ZS)�
LocationStorezqA config store for options specific to a location.

    There is a single LocationStore for a given process.
    Ncs.tjt��|d�}tt|��|d�d|_dS)NrDzlocations.confr=)rrrZ
config_dirr\rHrr)rrErGr^rrr�s
�zLocationStore.__init__)Nr�rrr^rrH�srHcs eZdZdZ�fdd�Z�ZS)�BranchStorez^A config store for branch options.

    There is a single BranchStore for a given branch.
    cs$tt|��|jd�||_d|_dS)Nzbranch.confrV)r\rIrZcontrol_transportrVrr[r^rrr�s
�zBranchStore.__init__r�rrr^rrI�srIcseZdZ�fdd�Z�ZS)�ControlStorecs"tt|�j|jddd�d|_dS)Nzcontrol.confZbranch_lock)rAZcontrol)r\rJrrrr�r^rrr�s
�zControlStore.__init__)rrr rrjrrr^rrJ�srJc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�SectionMatcherz�Select sections into a given Store.

    This is intended to be used to postpone getting an iterable of sections
    from a store.
    cCs
||_dSr")rQ)rrQrrrr�szSectionMatcher.__init__ccs0|j��}|D]\}}|�|�r||fVqdSr")rQr*r?)rr�rQr�rrrr*�s

zSectionMatcher.get_sectionscCst|j��dS)z�Does the proposed section match.

        :param section: A Section object.

        :returns: True if the section matches, False otherwise.
        N)rmr?r�rrrr?�szSectionMatcher.matchN)rrr r�rr*r?rrrrrK�s	rKcs$eZdZ�fdd�Zdd�Z�ZS)�NameMatchercstt|��|�||_dSr")r\rLrr)rrQrr^rrr�szNameMatcher.__init__cCs|j|jkSr")rrr�rrrr?�szNameMatcher.match)rrr rr?rjrrr^rrL�srLcs,eZdZd�fdd�	Zd�fdd�	Z�ZS)	�LocationSectionNcs@tt|��|j|j�||_|dur(d}|t�|�|d�|_dS)Nr�)�relpath�basenameZ
branchname)	r\rMrrrr�r�rO�locals)rrcr��branch_namer^rrr�s�zLocationSection.__init__Tcs�tt|��||�}|dur�|r�|�|dd�}t�|t�}|tkrPt�||j�}g}t	|�D]J\}}	|st|�
|	�q\|	dd�}
|
|jvr�|�
|j|
�q\|�
|	�q\d�|�}|S)NrGrr�r�)r\rMr�rHr�r�r�rr�rr�rP)rr#r�r�r1rJr�r�r
r��refr^rrr��s 

zLocationSection.get)N)NT)rrr rr�rjrrr^rrM�s	rMcs(eZdZdZ�fdd�Zdd�Z�ZS)�StartingPathMatcherz@Select sections for a given location respecting the Store order.cs.tt|��|�|�d�r$t�|�}||_dS)Nr2)r\rSrr�r�r4r7)rrQr7r^rrr
s

zStartingPathMatcher.__init__ccs�|j�d��d�}|j}tt|����D]�\}}|jdurN|t||j�fVq(|j}|�	d�rht
�|�}|j�	|�s�t�|j|�r(|�d��d�}d�
|t|�d��}|t||�fVq(dS)aGGet all sections matching ``location`` in the store.

        The most generic sections are described first in the store, then more
        specific ones can be provided for reduced scopes.

        The returned section are therefore returned in the reversed order so
        the most specific ones can be found first.
        r1Nr2)r7r3rsrQ�reversedr�r*rrMr�r�r4r6rr�)rr8rQr�rcr9r:r�rrrr*
s	


�z StartingPathMatcher.get_sections)rrr r�rr*rjrrr^rrS�s
rScs,eZdZ�fdd�Zdd�Zdd�Z�ZS)�LocationMatchercsjtt|��|�t�|�\}}|�d�r2t�|�}||_|�d�}|durZt�	|j�|_
nt�|�|_
dS)Nr2rV)r\rUrr�Zsplit_segment_parametersr�r4r7r�rOrQrj)rrQr7�url�paramsrQr^rrr%
s


zLocationMatcher.__init__cCs�d}g}|j��D]"\}}|jdur*|}q|�|�qtdd�|D�|j�}t|�}g}|durv|�dt||j�f�|D]<\}}	}
t|�}||jkr�t||	|j	�}|�|
|f�qzq�qz|S)z'Get all sections matching ``location``.NcSsg|]
}|j�qSr�r)r,r�rrr�
<listcomp>A
r/z:LocationMatcher._get_matching_sections.<locals>.<listcomp>r)
rQr*rr�r;r7�iterrM�nextrQ)rZno_name_sectionZall_sectionsr�rcZfiltered_sectionsZiter_all_sectionsZmatching_sectionsrr�rErrrr�1
s0
��
�z&LocationMatcher._get_matching_sectionsccsZt|��dd�dd�}|D]:\}}|�dd�}|dur@t�|�}|rHqV|j|fVqdS)NcSs|d|djfS)NrrrXr>rrrr@Y
r/z.LocationMatcher.get_sections.<locals>.<lambda>TrArC)rDr�r�r�r�rQ)rr�r�rcr=rrrr*U
s�
zLocationMatcher.get_sections)rrr rr�r*rjrrr^rrU#
s$rUc@szeZdZdZddd�Zdd�Zddd	�Zdd
d�Zddd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zd dd�ZdS)!�Stackz8A stack of configurations where an option can be definedNcCs||_||_||_dS)aNCreates a stack of sections with an optional store for changes.

        :param sections_def: A list of Section or callables that returns an
            iterable of Section. This defines the Sections for the Stack and
            can be called repeatedly if needed.

        :param store: The optional Store where modifications will be
            recorded. If none is specified, no modifications can be done.

        :param mutable_section_id: The id of the MutableSection where changes
            are recorded. This requires the ``store`` parameter to be
            specified.
        N)�sections_defrQ�mutable_section_id)rr]rQr^rrrrp
szStack.__init__ccs*|jD]}|�D]\}}||fVqqdS)z!Iterate all the defined sections.N)r])rr�rQrcrrr�
iter_sections�
s
zStack.iter_sectionsTc	s�d}d�zt����Wnty,d�Yn0������fdd�}�durb�jrb���}||�}|dur����D]"\}}|���}|durr|�q�qr||�}�dur�|dur����}||�}tdD]}|��|�q�|S)a�Return the *first* option value found in the sections.

        This is where we guarantee that sections coming from Store are loaded
        lazily: the loading is delayed until we need to either check that an
        option exists or get its value, which in turn may require to discover
        in which sections it can be defined. Both of these (section and option
        existence) require loading the store (even partially).

        :param name: The queried option.

        :param expand: Whether options references should be expanded.

        :param convert: Whether the option value should be converted from
            unicode (do nothing for non-registered options).

        :returns: The value of the option.
        Ncs`|dur\�r8t|t�r"��|�}nt�d�t|�f��durL��|�}n�r\���|�}|S)Nz8Cannot expand "%s": %s does not support option expansion)rPrr}r�r��typer�r�)r���convertr�Zfound_storer#Zoptrrr�expand_and_convert�
s

�z%Stack.get.<locals>.expand_and_convertr�)�option_registryr�rhr�r�r_r�r�)	rr#r�rbr1rcrQrcr�rrarr��
s.

z	Stack.getcCs|�||�S)a/Expand option references in the string in the configuration context.

        :param string: The string containing option(s) to expand.

        :param env: An option dict defining additional configuration options or
            overriding existing ones.

        :returns: The expanded string.
        r|r~rrrr��
s
zStack.expand_optionscCs�|durdS|durg}|}d}|r�d}g}t|�D]v\}}|sL|�|�q4d}|dd�}	|	|vrnt||��|�|	�|�|	||�}
|
dur�t|	|��|�|
�|��q4d�|�}q |S)a�Expand options in the string in the configuration context.

        :param string: The string to be expanded.

        :param env: An option dict defining additional configuration options or
            overriding existing ones.

        :param _refs: Private list (FIFO) containing the options being expanded
            to detect loops.

        :returns: The expanded string.
        NTFrr�r�)rr�rr�r!r�r)rrr�_refsrTZexpandedr�r
r�r#r1rrrr}�
s0





zStack._expand_options_in_stringcCs<|dur||vr||}n|j|ddd�}|�|||�}|S)NF�r�rb)r�r})rr#rrer1rrrr�s

zStack._expand_optioncCs|j}|�|j�}||fS)aPGet the MutableSection for the Stack.

        This is where we guarantee that the mutable section is lazily loaded:
        this means we won't load the corresponding store before setting a value
        or deleting an option. In practice the store will often be loaded but
        this helps catching some programming errors.
        )rQr(r^)rrQrcrrr�_get_mutable_sectionszStack._get_mutable_sectioncCs<|��\}}|�||�|��tdD]}||||�q&dS)zSet a new value for the option.r�N)rgr�rXr�)rr#r1rQrcr�rrrr�sz	Stack.setcCs2|��\}}|�|�tdD]}|||�qdS)zRemove an existing option.r�N)rgr�r�)rr#r�rcr�rrrr�"s
zStack.removecCsd|jjt|�fSr+rrlrrrr)szStack.__repr__cCstjdurtjj��SgSr")ro�
_global_stateZcmdline_overridesr*rlrrr�_get_overrides-s
zStack._get_overridescs~|durtj}|durBt��fdd�}tsHddl}|�|�dan|j�|��}z
�|WStyx|�|<|YS0dS)a}Get a known shared store.

        Store urls uniquely identify them and are used to ensure a single copy
        is shared across all users.

        :param store: The store known to the caller.

        :param state: The library state where the known stores are kept.

        :returns: The store received if it's not a known one, an already known
            otherwise.
        Ncs���D]\}}|��qdSr")rr))rrQ�Zstoresrr�save_config_changesGsz3Stack.get_shared_store.<locals>.save_config_changesrT)	rorh�_shared_stores� _shared_stores_at_exit_installed�atexitr�Z
config_storesr�rh)rrQ�staterkrnrVrrjr�get_shared_store3s 


zStack.get_shared_store)NN)TT)N)NN)N)rrr r�rr_r�r�r}r�rgr�r�rrirprrrrr\m
s


B

+
r\cs"eZdZdZd�fdd�	Z�ZS)�MemoryStackzxA configuration stack defined from a string.

    This is mainly intended for tests and requires no disk resources.
    Ncs2t�}|dur|�|�tt|��|jg|�dS)aLCreate an in-memory stack from a given content.

        It uses a single store based on configobj and support reading and
        writing options.

        :param content: The initial content of the store. If None, the store is
            not loaded and ``_load_from_string`` can and should be used if
            needed.
        N)r5r#r\rqrr*)rr:rQr^rrr`s


�zMemoryStack.__init__)Nr�rrr^rrqZsrqcs,eZdZdZ�fdd�Z�fdd�Z�ZS)�_CompatibleStackaNPlace holder for compatibility with previous design.

    This is intended to ease the transition from the Config-based design to the
    Stack-based design and should not be used nor relied upon by plugins.

    One assumption made here is that the daughter classes will all use Stores
    derived from LockableIniFileStore).

    It implements set() and remove () by re-loading the store before applying
    the modification and saving it.

    The long term plan being to implement a single write by store to save
    all modifications, this class should not be used in the interim.
    cs*|j��tt|��||�|j��dSr")rQr%r\rrr�r�r4r^rrr��s
z_CompatibleStack.setcs(|j��tt|��|�|j��dSr")rQr%r\rrr�r�r&r^rrr��s
z_CompatibleStack.remove)rrr r�r�r�rjrrr^rrrqsrrcs eZdZdZ�fdd�Z�ZS)�GlobalStackz�Global options only stack.

    The following sections are queried:

    * command-line overrides,

    * the 'DEFAULT' section in bazaar.conf

    This stack will use the ``DEFAULT`` section in bazaar.conf as its
    MutableSection.
    cs4|�t��}tt|�j|jt|d�jg|dd�dS)Nrg�r^)rprCr\rsrrirLr*)r�gstorer^rrr�s

��zGlobalStack.__init__r�rrr^rrs�srscs eZdZdZ�fdd�Z�ZS)�
LocationStacka�Per-location options falling back to global options stack.


    The following sections are queried:

    * command-line overrides,

    * the sections matching ``location`` in ``locations.conf``, the order being
      defined by the number of path components in the section glob, higher
      numbers first (from most specific section to most generic).

    * the 'DEFAULT' section in bazaar.conf

    This stack will use the ``location`` section in locations.conf as its
    MutableSection.
    cs^|�t��}|�d�r t�|�}|�t��}tt|�j|j	t
||�jt|d�jg||d�dS)zdMake a new stack for a location and global configuration.

        :param location: A URL prefix to r2rgrtN)
rprHr�r�r4rCr\rvrrirUr*rL)rr7�lstorerur^rrr�s




��zLocationStack.__init__r�rrr^rrv�srvcsJeZdZdZ�fdd�Zd
dd�Zdd�Z�fd	d
�Z�fdd�Z�Z	S)�BranchStacka*Per-location options falling back to branch then global options stack.

    The following sections are queried:

    * command-line overrides,

    * the sections matching ``location`` in ``locations.conf``, the order being
      defined by the number of path components in the section glob, higher
      numbers first (from most specific section to most generic),

    * the no-name section in branch.conf,

    * the ``DEFAULT`` section in ``bazaar.conf``.

    This stack will use the no-name section in ``branch.conf`` as its
    MutableSection.
    cs`|�t��}|��}|�t��}tt|��|jt||j	�j
t|d�j
t|d�j
g|�||_dSrf)
rprH�_get_config_storerCr\rxrrirUr]r*rLrV)rrVrw�bstorerur^rrr�s


��zBranchStack.__init__NcCs|j�|�Sr"�rVrrrrrr�szBranchStack.lock_writecCs
|j��Sr"�rVrrlrrrr�szBranchStack.unlockcs>|���"tt|��||�Wd�n1s00YdSr")rr\rxr�r4r^rrr��s
zBranchStack.setcs<|��� tt|��|�Wd�n1s.0YdSr")rr\rxr�r&r^rrr��s
zBranchStack.remove)N�
rrr r�rrrr�r�rjrrr^rrx�s
rxcs eZdZdZ�fdd�Z�ZS)�RemoteControlStackz"Remote control-only options stack.cs.|��}tt|��t|d�jg|�||_dSr")ryr\r~rrLr*�
controldir)rr�Zcstorer^rrr�s
�zRemoteControlStack.__init__r�rrr^rr~�sr~csJeZdZdZ�fdd�Zd
dd�Zdd�Z�fd	d
�Z�fdd�Z�Z	S)�BranchOnlyStackzBranch-only options stack.cs.|��}tt|��t|d�jg|�||_dSr")ryr\r�rrLr*rV)rrVrzr^rrrs
�zBranchOnlyStack.__init__NcCs|j�|�Sr"r{rrrrrszBranchOnlyStack.lock_writecCs
|j��Sr"r|rlrrrrszBranchOnlyStack.unlockcsH|���,tt|��||�|j��Wd�n1s:0YdSr")rr\r�r�rQr)r4r^rrr�s
zBranchOnlyStack.setcsF|���*tt|��|�|j��Wd�n1s80YdSr")rr\r�r�rQr)r&r^rrr�!s
zBranchOnlyStack.remove)Nr}rrr^rr�s
r�c@s�eZdZdZdgZdejdded�ejddd	�ejd
dd	�gZdgZ	ej
ddd��Zddd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zd
S)�
cmd_configa�Display, set or remove a configuration option.

    Display the active value for option NAME.

    If --all is specified, NAME is interpreted as a regular expression and all
    matching options are displayed mentioning their scope and without resolving
    option references in the value). The active value that bzr will take into
    account is the first one displayed for each option.

    If NAME is not given, --all .* is implied (all options are displayed for the
    current scope).

    Setting a value is achieved by using NAME=value without spaces. The value
    is set in the most relevant scope and can be checked by displaying the
    option again.

    Removing a value is achieved by using --remove NAME.
    zname?�	directory�scopez5Reduce the scope to the specified configuration file.)r�r`�allz8Display all the defined values for the matching options.r�r�z.Remove the option from the configuration file.Z
configurationNFcCs�|durd}tj�|�}t�|�}|r6|r6t�d��n�|rJ|�|||�n�|durb|�d||�nhz|�	dd�\}}Wn4t
y�|r�|�|||�n|�|||�Yn 0|r�t�d��|�||||�dS)Nr�z*--all and --remove are mutually exclusive.z.*r2rzOnly one option can be set.)
Zdirectory_serviceZdirectoriesZdereferencer�Z
normalize_urlrr3�_remove_config_option�_show_matching_optionsrsrB�_show_value�_set_config_option)rr#r�r�r�r�r1rrr�runOs.
��zcmd_config.runcCs�|durf|dkrt�S|dkr&t|�S|dkr\tj�|�\}}}|rT|�|��j�|��St	|��nNz0tj�|�\}}}|r�|�|��j�|��WSt
jy�t|�YS0dS)a-Get the configuration stack specified by ``directory`` and ``scope``.

        :param directory: Where the configurations are derived from.

        :param scope: A specific config to start from.

        :param write_access: Whether a write access to the stack will be
            attempted.
        Nror=rV)rsrvrZ
ControlDirZopen_containing_tree_or_branchZadd_cleanuprrZget_config_stackr7rZNotBranchError)rr�r��write_accessr��brrrr�
_get_stackos0
��
��
zcmd_config._get_stackcCsd|vrd|d}|S)Nr*rWrr�rrr�_quote_multiline�szcmd_config._quote_multilinecCsN|�||�}|j|ddd�}|durB|�|�}|j�d|f�nt|��dS)NTFrfz%s
)r�r�r��outfrr9)rr#r�r�rRr1rrrr��s
zcmd_config._show_valuecCs�t�|�}|��d}d}|�||�}|��D]�\}}|��D]�}	|�|	�r>||jkrt|j�	d|jf�|j}d}|jdur�||jkr�|j�	d|jf�|j}|j
|	dd�}
|�|
�}
|j�	d|	|
f�q>q.dS)Nz%s:
z  [%s]
Fr�z
  %s = %s
)r	�lazy_compileZ_compile_and_collapser�r_r�searchrr�rr�r�)rr#r�r�Zcur_store_idZcur_sectionrRrQrcr�r1rrrr��s$



z!cmd_config._show_matching_optionscCs*|j||dd�}|�||�|j��dS)NT�r�)r�r�rQr))rr#r1r�r�rRrrrr��szcmd_config._set_config_optioncCsZ|durt�d��|j||dd�}z|�|�|j��WntyTt|��Yn0dS)Nz%--remove expects an option to remove.Tr�)rr3r�r�rQr)rhr9)rr#r�r�rRrrrr��s�
z cmd_config._remove_config_option)NFNNF)NF)rrr r�Z
takes_argsrr�rZ
takes_optionsZ	_see_alsoZdisplay_commandr�r�r�r�r�r�r�rrrrr�(s,����
%
r�)�r�Z
__future__rr�rvrMror�globalsr�rrrrr	r
Zsixishrrr
rrr?rAr@rGrIrHr�r�r�rKrHrMrNrOrdrfr3rr!r$r'r)r0r5r7r9rDrJrUrYrN�objectrkZHooksr�r�r�r�r�rr$r;r<rRrmr�r\r�r�rsZRegistryr�r�r�r�r�rr�r�r�r�r�r�r�r�r�r�rrrr�r	rrrdr�r�r�rrrr r.r5r>r@rCrHrIrJrKrLrMrSrUrlrmr\rqrrrsrvrxr~r�ZCommandr�Ztest_store_builder_registryZtest_stack_builder_registryrrrr�<module>s�: 	��				
	"9"#qKP3l*!;T�
�&e�%$

0��	��������
�������	��
����������
������
���������������	��	���	����	��
�������
��������	��������?s#-3

	
".Fn!2!7