/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

  • Committer: Vincent Ladeuil
  • Date: 2009-12-15 20:32:34 UTC
  • mto: (4905.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4906.
  • Revision ID: v.ladeuil+lp@free.fr-20091215203234-d8br6xqfq6pec40z
Move the _warn_if_deprecated call from repo.__init__ to
repo.lock_{read,write} so that branch.lock_{read,write} can call it. This
makes it possible to access locations.conf and branch.conf.

* bzrlib/tests/blackbox/test_exceptions.py:
(TestDeprecationWarning): Test that the suppress_warning
configuration variable is taken into account.

* bzrlib/repository.py:
(Repository.__init__): Delete very old and obsolete
comments. Don't warn about deprecations yet.
(Repository.lock_write, Repository.lock_read): The repo is about
to be locked, check deprecation.
(Repository._warn_if_deprecated): Use the branch config if
available or the global one othewrwise and check for the
suppress_warning variable.

* bzrlib/remote.py:
(RemoteRepository._warn_if_deprecated): Nothing to do here. 

* bzrlib/repofmt/pack_repo.py:
(KnitPackRepository._warn_if_deprecated): Delegate to base class
if needed.

* bzrlib/branch.py:
(BzrBranch.lock_write, BzrBranch.lock_read): Check repo
deprecation.

* bzrlib/help_topics/en/configuration.txt:
Fix the variable name and its description.

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
#
193
193
            interpreted as a boolean. Returns True or False otherwise.
194
194
        """
195
195
        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
 
196
        return ui.bool_from_string(s)
205
197
 
206
198
    def get_user_option_as_list(self, option_name):
207
199
        """Get a generic option as a list - no special process, no default.
518
510
        self._write_config_file()
519
511
 
520
512
    def _write_config_file(self):
521
 
        path = self._get_filename()
522
 
        f = open(path, 'wb')
523
 
        osutils.copy_ownership_from_path(path)
 
513
        f = open(self._get_filename(), 'wb')
524
514
        self._get_parser().write(f)
525
515
        f.close()
526
516
 
820
810
            os.mkdir(parent_dir)
821
811
        trace.mutter('creating config directory: %r', path)
822
812
        os.mkdir(path)
823
 
        osutils.copy_ownership_from_path(path)
824
813
 
825
814
 
826
815
def config_dir():
877
866
 
878
867
    This doesn't implicitly create it.
879
868
 
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.
 
869
    On Windows it's in the config directory; elsewhere in the XDG cache directory.
883
870
    """
884
871
    if sys.platform == 'win32':
885
872
        return osutils.pathjoin(config_dir(), 'Crash')
886
873
    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')
 
874
        return osutils.pathjoin(xdg_cache_dir(), 'crash')
890
875
 
891
876
 
892
877
def xdg_cache_dir():
1417
1402
 
1418
1403
 
1419
1404
class PlainTextCredentialStore(CredentialStore):
1420
 
    __doc__ = """Plain text credential store for the authentication.conf file"""
 
1405
    """Plain text credential store for the authentication.conf file."""
1421
1406
 
1422
1407
    def decode_password(self, credentials):
1423
1408
        """See CredentialStore.decode_password."""
1512
1497
 
1513
1498
    def _get_config_file(self):
1514
1499
        try:
1515
 
            return StringIO(self._transport.get_bytes(self._filename))
 
1500
            return self._transport.get(self._filename)
1516
1501
        except errors.NoSuchFile:
1517
1502
            return StringIO()
1518
1503