/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: Marius Kruger
  • Date: 2010-07-10 21:28:56 UTC
  • mto: (5384.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 5385.
  • Revision ID: marius.kruger@enerweb.co.za-20100710212856-uq4ji3go0u5se7hx
* Update documentation
* add NEWS

Show diffs side-by-side

added added

removed removed

Lines of Context:
477
477
    def _get_nickname(self):
478
478
        return self.get_user_option('nickname')
479
479
 
 
480
    def _write_config_file(self):
 
481
        f = file(self._get_filename(), "wb")
 
482
        try:
 
483
            osutils.copy_ownership_from_path(f.name)
 
484
            self._get_parser().write(f)
 
485
        finally:
 
486
            f.close()
 
487
 
480
488
 
481
489
class GlobalConfig(IniBasedConfig):
482
490
    """The configuration that should be used for a specific location."""
518
526
        self._get_parser().setdefault(section, {})[option] = value
519
527
        self._write_config_file()
520
528
 
521
 
    def _write_config_file(self):
522
 
        path = self._get_filename()
523
 
        f = open(path, 'wb')
524
 
        osutils.copy_ownership_from_path(path)
525
 
        self._get_parser().write(f)
526
 
        f.close()
527
 
 
528
529
 
529
530
class LocationConfig(IniBasedConfig):
530
531
    """A configuration object that gives the policy for a location."""
664
665
        self._get_parser()[location][option]=value
665
666
        # the allowed values of store match the config policies
666
667
        self._set_option_policy(location, option, store)
667
 
        self._get_parser().write(file(self._get_filename(), 'wb'))
 
668
        self._write_config_file()
668
669
 
669
670
 
670
671
class BranchConfig(Config):
842
843
                                  ' or HOME set')
843
844
        return osutils.pathjoin(base, 'bazaar', '2.0')
844
845
    else:
845
 
        # cygwin, linux, and darwin all have a $HOME directory
846
846
        if base is None:
847
847
            base = os.path.expanduser("~")
848
848
        return osutils.pathjoin(base, ".bazaar")
991
991
        """Save the config file, only tests should use it for now."""
992
992
        conf_dir = os.path.dirname(self._filename)
993
993
        ensure_config_dir_exists(conf_dir)
994
 
        self._get_config().write(file(self._filename, 'wb'))
 
994
        f = file(self._filename, 'wb')
 
995
        try:
 
996
            self._get_config().write(f)
 
997
        finally:
 
998
            f.close()
995
999
 
996
1000
    def _set_option(self, section_name, option_name, value):
997
1001
        """Set an authentication configuration option"""
1445
1449
            return StringIO()
1446
1450
 
1447
1451
    def _get_configobj(self):
1448
 
        return ConfigObj(self._get_config_file(), encoding='utf-8')
 
1452
        f = self._get_config_file()
 
1453
        try:
 
1454
            return ConfigObj(f, encoding='utf-8')
 
1455
        finally:
 
1456
            f.close()
1449
1457
 
1450
1458
    def _set_configobj(self, configobj):
1451
1459
        out_file = StringIO()