/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/config.py

Merge bzr.dev and resolve conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
593
593
 
594
594
    def set_user_option(self, option, value, store=STORE_LOCATION):
595
595
        """Save option and its value in the configuration."""
596
 
        assert store in [STORE_LOCATION,
 
596
        if store not in [STORE_LOCATION,
597
597
                         STORE_LOCATION_NORECURSE,
598
 
                         STORE_LOCATION_APPENDPATH], 'bad storage policy'
 
598
                         STORE_LOCATION_APPENDPATH]:
 
599
            raise ValueError('bad storage policy %r for %r' %
 
600
                (store, option))
599
601
        # FIXME: RBC 20051029 This should refresh the parser and also take a
600
602
        # file lock on locations.conf.
601
603
        conf_dir = os.path.dirname(self._get_filename())
662
664
    def _get_user_id(self):
663
665
        """Return the full user id for the branch.
664
666
    
665
 
        e.g. "John Hacker <jhacker@foo.org>"
 
667
        e.g. "John Hacker <jhacker@example.com>"
666
668
        This is looked up in the email controlfile for the branch.
667
669
        """
668
670
        try:
669
 
            return (self.branch.control_files.get_utf8("email") 
670
 
                    .read()
 
671
            return (self.branch._transport.get_bytes("email")
671
672
                    .decode(bzrlib.user_encoding)
672
673
                    .rstrip("\r\n"))
673
674
        except errors.NoSuchFile, e:
914
915
class TreeConfig(IniBasedConfig):
915
916
    """Branch configuration data associated with its contents, not location"""
916
917
 
 
918
    # XXX: Really needs a better name, as this is not part of the tree! -- mbp 20080507
 
919
 
917
920
    def __init__(self, branch):
918
 
        transport = branch.control_files._transport
919
 
        self._config = TransportConfig(transport, 'branch.conf')
 
921
        # XXX: Really this should be asking the branch for its configuration
 
922
        # data, rather than relying on a Transport, so that it can work 
 
923
        # more cleanly with a RemoteBranch that has no transport.
 
924
        self._config = TransportConfig(branch._transport, 'branch.conf')
920
925
        self.branch = branch
921
926
 
922
927
    def _get_parser(self, file=None):
1014
1019
        """
1015
1020
        credentials = None
1016
1021
        for auth_def_name, auth_def in self._get_config().items():
 
1022
            if type(auth_def) is not configobj.Section:
 
1023
                raise ValueError("%s defined outside a section" % auth_def_name)
 
1024
 
1017
1025
            a_scheme, a_host, a_user, a_path = map(
1018
1026
                auth_def.get, ['scheme', 'host', 'user', 'path'])
1019
1027
 
1051
1059
                # Can't find a user
1052
1060
                continue
1053
1061
            credentials = dict(name=auth_def_name,
1054
 
                               user=a_user, password=auth_def['password'],
 
1062
                               user=a_user,
 
1063
                               password=auth_def.get('password', None),
1055
1064
                               verify_certificates=a_verify_certificates)
1056
1065
            self.decode_password(credentials,
1057
1066
                                 auth_def.get('password_encoding', None))
1106
1115
        credentials = self.get_credentials(scheme, host, port, user, path)
1107
1116
        if credentials is not None:
1108
1117
            password = credentials['password']
 
1118
            if password is not None and scheme is 'ssh':
 
1119
                trace.warning('password ignored in section [%s],'
 
1120
                              ' use an ssh agent instead'
 
1121
                              % credentials['name'])
 
1122
                password = None
1109
1123
        else:
1110
1124
            password = None
1111
1125
        # Prompt user only if we could't find a password
1112
1126
        if password is None:
1113
1127
            if prompt is None:
1114
 
                # Create a default prompt suitable for most of the cases
 
1128
                # Create a default prompt suitable for most cases
1115
1129
                prompt = '%s' % scheme.upper() + ' %(user)s@%(host)s password'
1116
1130
            # Special handling for optional fields in the prompt
1117
1131
            if port is not None: