~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/config.py

  • Committer: John Arbash Meinel
  • Date: 2010-02-17 17:11:16 UTC
  • mfrom: (4797.2.17 2.1)
  • mto: (4797.2.18 2.1)
  • mto: This revision was merged to the branch mainline in revision 5055.
  • Revision ID: john@arbash-meinel.com-20100217171116-h7t9223ystbnx5h8
merge bzr.2.1 in preparation for NEWS entry.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2007, 2008 Canonical Ltd
 
1
# Copyright (C) 2005-2010 Canonical Ltd
2
2
#   Authors: Robert Collins <robert.collins@canonical.com>
3
3
#            and others
4
4
#
153
153
        """Get the users pop up editor."""
154
154
        raise NotImplementedError
155
155
 
 
156
    def get_change_editor(self, old_tree, new_tree):
 
157
        from bzrlib import diff
 
158
        cmd = self._get_change_editor()
 
159
        if cmd is None:
 
160
            return None
 
161
        return diff.DiffFromTool.from_string(cmd, old_tree, new_tree,
 
162
                                             sys.stdout)
 
163
 
 
164
 
156
165
    def get_mail_client(self):
157
166
        """Get a mail client to use"""
158
167
        selected_client = self.get_user_option('mail_client')
181
190
        """Get a generic option as a boolean - no special process, no default.
182
191
 
183
192
        :return None if the option doesn't exist or its value can't be
184
 
            interpreted as a boolean. Returns True or False ortherwise.
 
193
            interpreted as a boolean. Returns True or False otherwise.
185
194
        """
186
195
        s = self._get_user_option(option_name)
187
196
        return ui.bool_from_string(s)
188
197
 
 
198
    def get_user_option_as_list(self, option_name):
 
199
        """Get a generic option as a list - no special process, no default.
 
200
 
 
201
        :return None if the option doesn't exist. Returns the value as a list
 
202
            otherwise.
 
203
        """
 
204
        l = self._get_user_option(option_name)
 
205
        if isinstance(l, (str, unicode)):
 
206
            # A single value, most probably the user forgot the final ','
 
207
            l = [l]
 
208
        return l
 
209
 
189
210
    def gpg_signing_command(self):
190
211
        """What program should be used to sign signatures?"""
191
212
        result = self._gpg_signing_command()
304
325
                path = 'bzr'
305
326
            return path
306
327
 
 
328
    def suppress_warning(self, warning):
 
329
        """Should the warning be suppressed or emitted.
 
330
 
 
331
        :param warning: The name of the warning being tested.
 
332
 
 
333
        :returns: True if the warning should be suppressed, False otherwise.
 
334
        """
 
335
        warnings = self.get_user_option_as_list('suppress_warnings')
 
336
        if warnings is None or warning not in warnings:
 
337
            return False
 
338
        else:
 
339
            return True
 
340
 
307
341
 
308
342
class IniBasedConfig(Config):
309
343
    """A configuration policy that draws from ini files."""
346
380
        """Return the policy for the given (section, option_name) pair."""
347
381
        return POLICY_NONE
348
382
 
 
383
    def _get_change_editor(self):
 
384
        return self.get_user_option('change_editor')
 
385
 
349
386
    def _get_signature_checking(self):
350
387
        """See Config._get_signature_checking."""
351
388
        policy = self._get_user_option('check_signatures')
679
716
 
680
717
        return self._get_best_value('_get_user_id')
681
718
 
 
719
    def _get_change_editor(self):
 
720
        return self._get_best_value('_get_change_editor')
 
721
 
682
722
    def _get_signature_checking(self):
683
723
        """See Config._get_signature_checking."""
684
724
        return self._get_best_value('_get_signature_checking')
1457
1497
 
1458
1498
    def _get_config_file(self):
1459
1499
        try:
1460
 
            return self._transport.get(self._filename)
 
1500
            return StringIO(self._transport.get_bytes(self._filename))
1461
1501
        except errors.NoSuchFile:
1462
1502
            return StringIO()
1463
1503