45
45
editor - this option sets the pop up editor to use during commits.
46
46
email - this option sets the user id bzr will use when committing.
47
47
check_signatures - this option controls whether bzr will require good gpg
48
signatures, ignore them, or check them if they are
48
signatures, ignore them, or check them if they are
50
create_signatures - this option controls whether bzr will always create
50
create_signatures - this option controls whether bzr will always create
51
51
gpg signatures, never create them, or create them if the
52
52
branch is configured to require them.
53
53
log_format - this option sets the default log format. Possible values are
216
217
def username(self):
217
218
"""Return email-style username.
219
220
Something similar to 'Martin Pool <mbp@sourcefrog.net>'
221
222
$BZR_EMAIL can be set to override this (as well as the
222
223
deprecated $BZREMAIL), then
223
224
the concrete policy type is checked, and finally
224
225
$EMAIL is examined.
225
226
If none is found, a reasonable default is (hopefully)
228
229
TODO: Check it's reasonably well-formed.
230
231
v = os.environ.get('BZR_EMAIL')
384
385
super(IniBasedConfig, self).__init__()
385
386
self._get_filename = get_filename
386
387
self._parser = None
388
389
def _post_commit(self):
389
390
"""See Config.post_commit."""
390
391
return self._get_user_option('post_commit')
414
415
def _get_alias(self, value):
416
return self._get_parser().get_value("ALIASES",
417
return self._get_parser().get_value("ALIASES",
642
643
def _get_safe_value(self, option_name):
643
644
"""This variant of get_best_value never returns untrusted values.
645
646
It does not return values from the branch data, because the branch may
646
647
not be controlled by the user.
712
713
def _gpg_signing_command(self):
713
714
"""See Config.gpg_signing_command."""
714
715
return self._get_safe_value('_gpg_signing_command')
716
717
def __init__(self, branch):
717
718
super(BranchConfig, self).__init__()
718
719
self._location_config = None
719
720
self._branch_data_config = None
720
721
self._global_config = None
721
722
self.branch = branch
722
self.option_sources = (self._get_location_config,
723
self.option_sources = (self._get_location_config,
723
724
self._get_branch_data_config,
724
725
self._get_global_config)
767
768
"""Return per-user configuration directory.
769
770
By default this is ~/.bazaar/
771
772
TODO: Global option --config-dir to override this.
773
774
base = os.environ.get('BZR_HOME', None)
897
898
def extract_email_address(e):
898
899
"""Return just the address part of an email string.
900
That is just the user@domain part, nothing else.
901
That is just the user@domain part, nothing else.
901
902
This part is required to contain only ascii characters.
902
903
If it can't be extracted, raises an error.
918
919
def __init__(self, branch):
919
920
# XXX: Really this should be asking the branch for its configuration
920
# data, rather than relying on a Transport, so that it can work
921
# data, rather than relying on a Transport, so that it can work
921
922
# more cleanly with a RemoteBranch that has no transport.
922
923
self._config = TransportConfig(branch._transport, 'branch.conf')
923
924
self.branch = branch
1176
1177
return password
1178
1179
def decode_password(self, credentials, encoding):
1181
cs = credential_store_registry.get_credential_store(encoding)
1183
raise ValueError('%r is not a known password_encoding' % encoding)
1184
credentials['password'] = cs.decode_password(credentials)
1179
1185
return credentials
1188
class CredentialStoreRegistry(registry.Registry):
1189
"""A class that registers credential stores.
1191
A credential store provides access to credentials via the password_encoding
1192
field in authentication.conf sections.
1194
Except for stores provided by bzr itself,most stores are expected to be
1195
provided by plugins that will therefore use
1196
register_lazy(password_encoding, module_name, member_name, help=help,
1197
info=info) to install themselves.
1200
def get_credential_store(self, encoding=None):
1201
cs = self.get(encoding)
1207
credential_store_registry = CredentialStoreRegistry()
1210
class CredentialStore(object):
1211
"""An abstract class to implement storage for credentials"""
1213
def decode_password(self, credentials):
1214
"""Returns a password for the provided credentials in clear text."""
1215
raise NotImplementedError(self.decode_password)
1218
class PlainTextCredentialStore(CredentialStore):
1219
"""Plain text credential store for the authentication.conf file."""
1221
def decode_password(self, credentials):
1222
"""See CredentialStore.decode_password."""
1223
return credentials['password']
1226
credential_store_registry.register('plain', PlainTextCredentialStore,
1227
help=PlainTextCredentialStore.__doc__)
1228
credential_store_registry.default_key = 'plain'
1182
1231
class BzrDirConfig(object):
1184
1233
def __init__(self, transport):