~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/config.py

  • Committer: Robert Collins
  • Date: 2005-10-16 02:25:11 UTC
  • mto: This revision was merged to the branch mainline in revision 1459.
  • Revision ID: robertc@lifelesslap.robertcollins.net-20051016022511-0bd5ebf69bd26bd2
Pull up _relpath with gz suffix for CompressedTextStore into TransportStore

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
Currently this configuration resides in ~/.bazaar/bazaar.conf
21
21
and ~/.bazaar/branches.conf, which is written to by bzr.
22
22
 
23
 
In bazaar.conf the following options may be set:
 
23
In bazaar.config the following options may be set:
24
24
[DEFAULT]
25
25
editor=name-of-program
26
26
email=Your Name <your@email.address>
27
27
check_signatures=require|ignore|check-available(default)
28
28
create_signatures=always|never|when-required(default)
29
 
gpg_signing_command=name-of-program
30
29
 
31
30
in branches.conf, you specify the url of a branch and options for it.
32
31
Wildcards may be used - * and ? as normal in shell completion. Options
76
75
    def _get_signature_checking(self):
77
76
        """Template method to override signature checking policy."""
78
77
 
79
 
    def _get_user_option(self, option_name):
80
 
        """Template method to provide a user option."""
81
 
        return None
82
 
 
83
 
    def get_user_option(self, option_name):
84
 
        """Get a generic option - no special process, no default."""
85
 
        return self._get_user_option(option_name)
86
 
 
87
 
    def gpg_signing_command(self):
88
 
        """What program should be used to sign signatures?"""
89
 
        result = self._gpg_signing_command()
90
 
        if result is None:
91
 
            result = "gpg"
92
 
        return result
93
 
 
94
 
    def _gpg_signing_command(self):
95
 
        """See gpg_signing_command()."""
96
 
        return None
97
 
 
98
78
    def __init__(self):
99
79
        super(Config, self).__init__()
100
80
 
187
167
            if self._get_parser().has_option(section, 'email'):
188
168
                return self._get_parser().get(section, 'email')
189
169
 
190
 
    def _get_user_option(self, option_name):
191
 
        """See Config._get_user_option."""
192
 
        section = self._get_section()
193
 
        if section is not None:
194
 
            if self._get_parser().has_option(section, option_name):
195
 
                return self._get_parser().get(section, option_name)
196
 
 
197
 
    def _gpg_signing_command(self):
198
 
        """See Config.gpg_signing_command."""
199
 
        section = self._get_section()
200
 
        if section is not None:
201
 
            if self._get_parser().has_option(section, 'gpg_signing_command'):
202
 
                return self._get_parser().get(section, 'gpg_signing_command')
203
 
 
204
170
    def __init__(self, get_filename):
205
171
        super(IniBasedConfig, self).__init__()
206
172
        self._get_filename = get_filename
281
247
        matches.sort(reverse=True)
282
248
        return matches[0][1]
283
249
 
284
 
    def _gpg_signing_command(self):
285
 
        """See Config.gpg_signing_command."""
286
 
        command = super(LocationConfig, self)._gpg_signing_command()
287
 
        if command is not None:
288
 
            return command
289
 
        return self._get_global_config()._gpg_signing_command()
290
 
 
291
250
    def _get_user_id(self):
292
251
        user_id = super(LocationConfig, self)._get_user_id()
293
252
        if user_id is not None:
294
253
            return user_id
295
254
        return self._get_global_config()._get_user_id()
296
255
 
297
 
    def _get_user_option(self, option_name):
298
 
        """See Config._get_user_option."""
299
 
        option_value = super(LocationConfig, 
300
 
                             self)._get_user_option(option_name)
301
 
        if option_value is not None:
302
 
            return option_value
303
 
        return self._get_global_config()._get_user_option(option_name)
304
 
 
305
256
    def _get_signature_checking(self):
306
257
        """See Config._get_signature_checking."""
307
258
        check = super(LocationConfig, self)._get_signature_checking()
338
289
        """See Config._get_signature_checking."""
339
290
        return self._get_location_config()._get_signature_checking()
340
291
 
341
 
    def _get_user_option(self, option_name):
342
 
        """See Config._get_user_option."""
343
 
        return self._get_location_config()._get_user_option(option_name)
344
 
 
345
 
    def _gpg_signing_command(self):
346
 
        """See Config.gpg_signing_command."""
347
 
        return self._get_location_config()._gpg_signing_command()
348
 
        
349
292
    def __init__(self, branch):
350
293
        super(BranchConfig, self).__init__()
351
294
        self._location_config = None
408
351
    return realname, (username + '@' + socket.gethostname())
409
352
 
410
353
 
411
 
def extract_email_address(e):
412
 
    """Return just the address part of an email string.
413
 
    
414
 
    That is just the user@domain part, nothing else. 
415
 
    This part is required to contain only ascii characters.
416
 
    If it can't be extracted, raises an error.
417
 
    
418
 
    >>> extract_email_address('Jane Tester <jane@test.com>')
419
 
    "jane@test.com"
420
 
    """
421
 
    m = re.search(r'[\w+.-]+@[\w+.-]+', e)
422
 
    if not m:
423
 
        raise BzrError("%r doesn't seem to contain "
424
 
                       "a reasonable email address" % e)
425
 
    return m.group(0)