/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: Robert Collins
  • Date: 2010-05-11 08:44:59 UTC
  • mfrom: (5221 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5223.
  • Revision ID: robertc@robertcollins.net-20100511084459-pb0uinna9zs3wu59
Merge trunk - resolve conflicts.

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
 
 
488
480
 
489
481
class GlobalConfig(IniBasedConfig):
490
482
    """The configuration that should be used for a specific location."""
526
518
        self._get_parser().setdefault(section, {})[option] = value
527
519
        self._write_config_file()
528
520
 
 
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
 
529
528
 
530
529
class LocationConfig(IniBasedConfig):
531
530
    """A configuration object that gives the policy for a location."""
665
664
        self._get_parser()[location][option]=value
666
665
        # the allowed values of store match the config policies
667
666
        self._set_option_policy(location, option, store)
668
 
        self._write_config_file()
 
667
        self._get_parser().write(file(self._get_filename(), 'wb'))
669
668
 
670
669
 
671
670
class BranchConfig(Config):
843
842
                                  ' or HOME set')
844
843
        return osutils.pathjoin(base, 'bazaar', '2.0')
845
844
    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
 
        f = file(self._filename, 'wb')
995
 
        try:
996
 
            self._get_config().write(f)
997
 
        finally:
998
 
            f.close()
 
994
        self._get_config().write(file(self._filename, 'wb'))
999
995
 
1000
996
    def _set_option(self, section_name, option_name, value):
1001
997
        """Set an authentication configuration option"""
1449
1445
            return StringIO()
1450
1446
 
1451
1447
    def _get_configobj(self):
1452
 
        f = self._get_config_file()
1453
 
        try:
1454
 
            return ConfigObj(f, encoding='utf-8')
1455
 
        finally:
1456
 
            f.close()
 
1448
        return ConfigObj(self._get_config_file(), encoding='utf-8')
1457
1449
 
1458
1450
    def _set_configobj(self, configobj):
1459
1451
        out_file = StringIO()