/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

Merge 2.0 into 2.1 resolving conflicts

Show diffs side-by-side

added added

removed removed

Lines of Context:
74
74
 
75
75
import bzrlib
76
76
from bzrlib import (
 
77
    atomicfile,
77
78
    debug,
78
79
    errors,
79
80
    mail_client,
193
194
            interpreted as a boolean. Returns True or False otherwise.
194
195
        """
195
196
        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
 
197
        return ui.bool_from_string(s)
205
198
 
206
199
    def get_user_option_as_list(self, option_name):
207
200
        """Get a generic option as a list - no special process, no default.
518
511
        self._write_config_file()
519
512
 
520
513
    def _write_config_file(self):
521
 
        path = self._get_filename()
522
 
        f = open(path, 'wb')
523
 
        osutils.copy_ownership_from_path(path)
524
 
        self._get_parser().write(f)
525
 
        f.close()
 
514
        atomic_file = atomicfile.AtomicFile(self._get_filename())
 
515
        self._get_parser().write(atomic_file)
 
516
        atomic_file.commit()
 
517
        atomic_file.close()
526
518
 
527
519
 
528
520
class LocationConfig(IniBasedConfig):
663
655
        self._get_parser()[location][option]=value
664
656
        # the allowed values of store match the config policies
665
657
        self._set_option_policy(location, option, store)
666
 
        self._get_parser().write(file(self._get_filename(), 'wb'))
 
658
        atomic_file = atomicfile.AtomicFile(self._get_filename())
 
659
        self._get_parser().write(atomic_file)
 
660
        atomic_file.commit()
 
661
        atomic_file.close()
667
662
 
668
663
 
669
664
class BranchConfig(Config):
820
815
            os.mkdir(parent_dir)
821
816
        trace.mutter('creating config directory: %r', path)
822
817
        os.mkdir(path)
823
 
        osutils.copy_ownership_from_path(path)
824
818
 
825
819
 
826
820
def config_dir():
877
871
 
878
872
    This doesn't implicitly create it.
879
873
 
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.
 
874
    On Windows it's in the config directory; elsewhere in the XDG cache directory.
883
875
    """
884
876
    if sys.platform == 'win32':
885
877
        return osutils.pathjoin(config_dir(), 'Crash')
886
878
    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')
 
879
        return osutils.pathjoin(xdg_cache_dir(), 'crash')
890
880
 
891
881
 
892
882
def xdg_cache_dir():
1417
1407
 
1418
1408
 
1419
1409
class PlainTextCredentialStore(CredentialStore):
1420
 
    __doc__ = """Plain text credential store for the authentication.conf file"""
 
1410
    """Plain text credential store for the authentication.conf file."""
1421
1411
 
1422
1412
    def decode_password(self, credentials):
1423
1413
        """See CredentialStore.decode_password."""