~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/config.py

  • Committer: Aaron Bentley
  • Date: 2006-02-22 14:39:42 UTC
  • mto: (2027.1.2 revert-subpath-56549)
  • mto: This revision was merged to the branch mainline in revision 1570.
  • Revision ID: abentley@panoramicfeedback.com-20060222143942-ae72299f2de66767
Fixed build_tree with symlinks

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
check_signatures=require|ignore|check-available(default)
28
28
create_signatures=always|never|when-required(default)
29
29
gpg_signing_command=name-of-program
 
30
log_format=name-of-format
30
31
 
31
32
in branches.conf, you specify the url of a branch and options for it.
32
33
Wildcards may be used - * and ? as normal in shell completion. Options
49
50
                    gpg signatures, never create them, or create them if the
50
51
                    branch is configured to require them.
51
52
                    NB: This option is planned, but not implemented yet.
 
53
log_format - This options set the default log format.  Options are long, 
 
54
             short, line, or a plugin can register new formats
52
55
"""
53
56
 
54
57
 
120
123
        """See gpg_signing_command()."""
121
124
        return None
122
125
 
 
126
    def log_format(self):
 
127
        """What log format should be used"""
 
128
        result = self._log_format()
 
129
        if result is None:
 
130
            result = "long"
 
131
        return result
 
132
 
 
133
    def _log_format(self):
 
134
        """See log_format()."""
 
135
        return None
 
136
 
123
137
    def __init__(self):
124
138
        super(Config, self).__init__()
125
139
 
226
240
        """See Config.gpg_signing_command."""
227
241
        return self._get_user_option('gpg_signing_command')
228
242
 
 
243
    def _log_format(self):
 
244
        """See Config.log_format."""
 
245
        return self._get_user_option('log_format')
 
246
 
229
247
    def __init__(self, get_filename):
230
248
        super(IniBasedConfig, self).__init__()
231
249
        self._get_filename = get_filename
318
336
            return command
319
337
        return self._get_global_config()._gpg_signing_command()
320
338
 
 
339
    def _log_format(self):
 
340
        """See Config.log_format."""
 
341
        command = super(LocationConfig, self)._log_format()
 
342
        if command is not None:
 
343
            return command
 
344
        return self._get_global_config()._log_format()
 
345
 
321
346
    def _get_user_id(self):
322
347
        user_id = super(LocationConfig, self)._get_user_id()
323
348
        if user_id is not None:
379
404
        This is looked up in the email controlfile for the branch.
380
405
        """
381
406
        try:
382
 
            return (self.branch.controlfile("email", "r") 
 
407
            return (self.branch.control_files.get_utf8("email") 
383
408
                    .read()
384
409
                    .decode(bzrlib.user_encoding)
385
410
                    .rstrip("\r\n"))
409
434
        """See Config.post_commit."""
410
435
        return self._get_location_config()._post_commit()
411
436
 
 
437
    def _log_format(self):
 
438
        """See Config.log_format."""
 
439
        return self._get_location_config()._log_format()
412
440
 
413
441
def ensure_config_dir_exists(path=None):
414
442
    """Make sure a configuration directory exists.
520
548
 
521
549
    def _get_config(self):
522
550
        try:
523
 
            obj = ConfigObj(self.branch.controlfile('branch.conf',
524
 
                                                    'rb').readlines())
 
551
            obj = ConfigObj(self.branch.control_files.get('branch.conf'
 
552
                        ).readlines())
525
553
            obj.decode('UTF-8')
526
554
        except errors.NoSuchFile:
527
555
            obj = ConfigObj()
558
586
            cfg_obj.encode('UTF-8')
559
587
            out_file = StringIO(''.join([l+'\n' for l in cfg_obj.write()]))
560
588
            out_file.seek(0)
561
 
            self.branch.put_controlfile('branch.conf', out_file, encode=False)
 
589
            self.branch.control_files.put('branch.conf', out_file)
562
590
        finally:
563
591
            self.branch.unlock()