~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/config.py

  • Committer: Vincent Ladeuil
  • Date: 2016-01-21 10:50:35 UTC
  • mfrom: (6609 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6610.
  • Revision ID: v.ladeuil+lp@free.fr-20160121105035-r67vcb49o142g2li
Merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1488
1488
    """Return per-user configuration directory as unicode string
1489
1489
 
1490
1490
    By default this is %APPDATA%/bazaar/2.0 on Windows, ~/.bazaar on Mac OS X
1491
 
    and Linux.  On Linux, if there is a $XDG_CONFIG_HOME/bazaar directory,
 
1491
    and Linux.  On Mac OS X and Linux, if there is a $XDG_CONFIG_HOME/bazaar directory,
1492
1492
    that will be used instead.
1493
1493
 
1494
1494
    TODO: Global option --config-dir to override this.
1503
1503
        #                APPDATA, but hard to move. See bug 348640 for more.
1504
1504
        return osutils.pathjoin(base, 'bazaar', '2.0')
1505
1505
    if base is None:
1506
 
        # GZ 2012-02-01: What should OSX use instead of XDG if anything?
1507
 
        if sys.platform != 'darwin':
1508
 
            xdg_dir = osutils.path_from_environ('XDG_CONFIG_HOME')
1509
 
            if xdg_dir is None:
1510
 
                xdg_dir = osutils.pathjoin(osutils._get_home_dir(), ".config")
1511
 
            xdg_dir = osutils.pathjoin(xdg_dir, 'bazaar')
1512
 
            if osutils.isdir(xdg_dir):
1513
 
                trace.mutter(
1514
 
                    "Using configuration in XDG directory %s." % xdg_dir)
1515
 
                return xdg_dir
 
1506
        xdg_dir = osutils.path_from_environ('XDG_CONFIG_HOME')
 
1507
        if xdg_dir is None:
 
1508
            xdg_dir = osutils.pathjoin(osutils._get_home_dir(), ".config")
 
1509
        xdg_dir = osutils.pathjoin(xdg_dir, 'bazaar')
 
1510
        if osutils.isdir(xdg_dir):
 
1511
            trace.mutter(
 
1512
                "Using configuration in XDG directory %s." % xdg_dir)
 
1513
            return xdg_dir
1516
1514
        base = osutils._get_home_dir()
1517
1515
    return osutils.pathjoin(base, ".bazaar")
1518
1516
 
1557
1555
def xdg_cache_dir():
1558
1556
    # See http://standards.freedesktop.org/basedir-spec/latest/ar01s03.html
1559
1557
    # Possibly this should be different on Windows?
1560
 
    e = os.environ.get('XDG_CACHE_DIR', None)
 
1558
    e = os.environ.get('XDG_CACHE_HOME', None)
1561
1559
    if e:
1562
1560
        return e
1563
1561
    else:
3561
3559
        """
3562
3560
        location_parts = self.location.rstrip('/').split('/')
3563
3561
        store = self.store
3564
 
        sections = []
3565
3562
        # Later sections are more specific, they should be returned first
3566
3563
        for _, section in reversed(list(store.get_sections())):
3567
3564
            if section.id is None:
4248
4245
    def _set_config_option(self, name, value, directory, scope):
4249
4246
        conf = self._get_stack(directory, scope, write_access=True)
4250
4247
        conf.set(name, value)
 
4248
        # Explicitly save the changes
 
4249
        conf.store.save_changes()
4251
4250
 
4252
4251
    def _remove_config_option(self, name, directory, scope):
4253
4252
        if name is None:
4256
4255
        conf = self._get_stack(directory, scope, write_access=True)
4257
4256
        try:
4258
4257
            conf.remove(name)
 
4258
            # Explicitly save the changes
 
4259
            conf.store.save_changes()
4259
4260
        except KeyError:
4260
4261
            raise errors.NoSuchConfigOption(name)
4261
4262