~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/config.py

  • Committer: John Arbash Meinel
  • Date: 2009-07-31 17:42:29 UTC
  • mto: This revision was merged to the branch mainline in revision 4611.
  • Revision ID: john@arbash-meinel.com-20090731174229-w2zdsdlfpeddk8gl
Now we got to the per-workingtree tests, etc.

The main causes seem to break down into:
  bzrdir.clone() is known to be broken wrt locking, this effects
  everything that tries to 'push'

  shelf code is not compatible with strict locking

  merge code seems to have an issue. This might actually be the
  root cause of the clone() problems.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2010 Canonical Ltd
 
1
# Copyright (C) 2005, 2007, 2008 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
 
 
165
156
    def get_mail_client(self):
166
157
        """Get a mail client to use"""
167
158
        selected_client = self.get_user_option('mail_client')
190
181
        """Get a generic option as a boolean - no special process, no default.
191
182
 
192
183
        :return None if the option doesn't exist or its value can't be
193
 
            interpreted as a boolean. Returns True or False otherwise.
 
184
            interpreted as a boolean. Returns True or False ortherwise.
194
185
        """
195
186
        s = self._get_user_option(option_name)
196
 
        if s is None:
197
 
            # The option doesn't exist
198
 
            return None
199
 
        val = ui.bool_from_string(s)
200
 
        if val is None:
201
 
            # The value can't be interpreted as a boolean
202
 
            trace.warning('Value "%s" is not a boolean for "%s"',
203
 
                          s, option_name)
204
 
        return val
205
 
 
206
 
    def get_user_option_as_list(self, option_name):
207
 
        """Get a generic option as a list - no special process, no default.
208
 
 
209
 
        :return None if the option doesn't exist. Returns the value as a list
210
 
            otherwise.
211
 
        """
212
 
        l = self._get_user_option(option_name)
213
 
        if isinstance(l, (str, unicode)):
214
 
            # A single value, most probably the user forgot the final ','
215
 
            l = [l]
216
 
        return l
 
187
        return ui.bool_from_string(s)
217
188
 
218
189
    def gpg_signing_command(self):
219
190
        """What program should be used to sign signatures?"""
333
304
                path = 'bzr'
334
305
            return path
335
306
 
336
 
    def suppress_warning(self, warning):
337
 
        """Should the warning be suppressed or emitted.
338
 
 
339
 
        :param warning: The name of the warning being tested.
340
 
 
341
 
        :returns: True if the warning should be suppressed, False otherwise.
342
 
        """
343
 
        warnings = self.get_user_option_as_list('suppress_warnings')
344
 
        if warnings is None or warning not in warnings:
345
 
            return False
346
 
        else:
347
 
            return True
348
 
 
349
307
 
350
308
class IniBasedConfig(Config):
351
309
    """A configuration policy that draws from ini files."""
388
346
        """Return the policy for the given (section, option_name) pair."""
389
347
        return POLICY_NONE
390
348
 
391
 
    def _get_change_editor(self):
392
 
        return self.get_user_option('change_editor')
393
 
 
394
349
    def _get_signature_checking(self):
395
350
        """See Config._get_signature_checking."""
396
351
        policy = self._get_user_option('check_signatures')
518
473
        self._write_config_file()
519
474
 
520
475
    def _write_config_file(self):
521
 
        path = self._get_filename()
522
 
        f = open(path, 'wb')
523
 
        osutils.copy_ownership_from_path(path)
 
476
        f = open(self._get_filename(), 'wb')
524
477
        self._get_parser().write(f)
525
478
        f.close()
526
479
 
726
679
 
727
680
        return self._get_best_value('_get_user_id')
728
681
 
729
 
    def _get_change_editor(self):
730
 
        return self._get_best_value('_get_change_editor')
731
 
 
732
682
    def _get_signature_checking(self):
733
683
        """See Config._get_signature_checking."""
734
684
        return self._get_best_value('_get_signature_checking')
820
770
            os.mkdir(parent_dir)
821
771
        trace.mutter('creating config directory: %r', path)
822
772
        os.mkdir(path)
823
 
        osutils.copy_ownership_from_path(path)
824
773
 
825
774
 
826
775
def config_dir():
872
821
    return osutils.pathjoin(config_dir(), 'ignore')
873
822
 
874
823
 
875
 
def crash_dir():
876
 
    """Return the directory name to store crash files.
877
 
 
878
 
    This doesn't implicitly create it.
879
 
 
880
 
    On Windows it's in the config directory; elsewhere it's /var/crash
881
 
    which may be monitored by apport.  It can be overridden by
882
 
    $APPORT_CRASH_DIR.
883
 
    """
884
 
    if sys.platform == 'win32':
885
 
        return osutils.pathjoin(config_dir(), 'Crash')
886
 
    else:
887
 
        # XXX: hardcoded in apport_python_hook.py; therefore here too -- mbp
888
 
        # 2010-01-31
889
 
        return os.environ.get('APPORT_CRASH_DIR', '/var/crash')
890
 
 
891
 
 
892
 
def xdg_cache_dir():
893
 
    # See http://standards.freedesktop.org/basedir-spec/latest/ar01s03.html
894
 
    # Possibly this should be different on Windows?
895
 
    e = os.environ.get('XDG_CACHE_DIR', None)
896
 
    if e:
897
 
        return e
898
 
    else:
899
 
        return os.path.expanduser('~/.cache')
900
 
 
901
 
 
902
824
def _auto_user_id():
903
825
    """Calculate automatic user identification.
904
826
 
1417
1339
 
1418
1340
 
1419
1341
class PlainTextCredentialStore(CredentialStore):
1420
 
    __doc__ = """Plain text credential store for the authentication.conf file"""
 
1342
    """Plain text credential store for the authentication.conf file."""
1421
1343
 
1422
1344
    def decode_password(self, credentials):
1423
1345
        """See CredentialStore.decode_password."""
1512
1434
 
1513
1435
    def _get_config_file(self):
1514
1436
        try:
1515
 
            return StringIO(self._transport.get_bytes(self._filename))
 
1437
            return self._transport.get(self._filename)
1516
1438
        except errors.NoSuchFile:
1517
1439
            return StringIO()
1518
1440