~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/config.py

  • Committer: Andrew Bennetts
  • Date: 2010-12-14 23:14:44 UTC
  • mfrom: (5569 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5570.
  • Revision ID: andrew.bennetts@canonical.com-20101214231444-uubf7zjbg8q92ocs
MergeĀ lp:bzr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1123
1123
def config_dir():
1124
1124
    """Return per-user configuration directory.
1125
1125
 
1126
 
    By default this is ~/.bazaar/
 
1126
    By default this is %APPDATA%/bazaar/2.0 on Windows, ~/.bazaar on Mac OS X
 
1127
    and Linux.  On Linux, if there is a $XDG_CONFIG_HOME/bazaar directory,
 
1128
    that will be used instead.
1127
1129
 
1128
1130
    TODO: Global option --config-dir to override this.
1129
1131
    """
1137
1139
            raise errors.BzrError('You must have one of BZR_HOME, APPDATA,'
1138
1140
                                  ' or HOME set')
1139
1141
        return osutils.pathjoin(base, 'bazaar', '2.0')
 
1142
    elif sys.platform == 'darwin':
 
1143
        if base is None:
 
1144
            # this takes into account $HOME
 
1145
            base = os.path.expanduser("~")
 
1146
        return osutils.pathjoin(base, '.bazaar')
1140
1147
    else:
1141
1148
        if base is None:
 
1149
 
 
1150
            xdg_dir = os.environ.get('XDG_CONFIG_HOME', None)
 
1151
            if xdg_dir is None:
 
1152
                xdg_dir = osutils.pathjoin(os.path.expanduser("~"), ".config")
 
1153
            xdg_dir = osutils.pathjoin(xdg_dir, 'bazaar')
 
1154
            if osutils.isdir(xdg_dir):
 
1155
                trace.mutter(
 
1156
                    "Using configuration in XDG directory %s." % xdg_dir)
 
1157
                return xdg_dir
 
1158
 
1142
1159
            base = os.path.expanduser("~")
1143
1160
        return osutils.pathjoin(base, ".bazaar")
1144
1161