~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/config.py

Merge up bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
570
570
 
571
571
    def set_user_option(self, option, value, store=STORE_LOCATION):
572
572
        """Save option and its value in the configuration."""
573
 
        assert store in [STORE_LOCATION,
 
573
        if store not in [STORE_LOCATION,
574
574
                         STORE_LOCATION_NORECURSE,
575
 
                         STORE_LOCATION_APPENDPATH], 'bad storage policy'
 
575
                         STORE_LOCATION_APPENDPATH]:
 
576
            raise ValueError('bad storage policy %r for %r' %
 
577
                (store, option))
576
578
        # FIXME: RBC 20051029 This should refresh the parser and also take a
577
579
        # file lock on locations.conf.
578
580
        conf_dir = os.path.dirname(self._get_filename())
643
645
        This is looked up in the email controlfile for the branch.
644
646
        """
645
647
        try:
646
 
            return (self.branch.control_files.get_utf8("email") 
647
 
                    .read()
 
648
            return (self.branch.control_files._transport.get_bytes("email")
648
649
                    .decode(bzrlib.user_encoding)
649
650
                    .rstrip("\r\n"))
650
651
        except errors.NoSuchFile, e:
891
892
class TreeConfig(IniBasedConfig):
892
893
    """Branch configuration data associated with its contents, not location"""
893
894
 
 
895
    # XXX: Really needs a better name, as this is not part of the tree! -- mbp 20080507
 
896
 
894
897
    def __init__(self, branch):
895
898
        transport = branch.control_files._transport
896
899
        self._config = TransportConfig(transport, 'branch.conf')
991
994
        """
992
995
        credentials = None
993
996
        for auth_def_name, auth_def in self._get_config().items():
 
997
            if type(auth_def) is not configobj.Section:
 
998
                raise ValueError("%s defined outside a section" % auth_def_name)
 
999
 
994
1000
            a_scheme, a_host, a_user, a_path = map(
995
1001
                auth_def.get, ['scheme', 'host', 'user', 'path'])
996
1002
 
1028
1034
                # Can't find a user
1029
1035
                continue
1030
1036
            credentials = dict(name=auth_def_name,
1031
 
                               user=a_user, password=auth_def['password'],
 
1037
                               user=a_user,
 
1038
                               password=auth_def.get('password', None),
1032
1039
                               verify_certificates=a_verify_certificates)
1033
1040
            self.decode_password(credentials,
1034
1041
                                 auth_def.get('password_encoding', None))