/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 breezy/bedding.py

  • Committer: Jelmer Vernooij
  • Date: 2020-02-13 23:57:28 UTC
  • mfrom: (7490 work)
  • mto: This revision was merged to the branch mainline in revision 7492.
  • Revision ID: jelmer@jelmer.uk-20200213235728-m6ds0mm3mbs4y182
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
"""Functions for deriving user configuration from system environment."""
19
19
 
 
20
from __future__ import absolute_import
 
21
 
20
22
import os
21
23
import sys
22
24
 
43
45
    if path is None:
44
46
        path = config_dir()
45
47
    if not os.path.isdir(path):
46
 
        parent_dir = os.path.dirname(path)
47
 
        if not os.path.isdir(parent_dir):
48
 
            trace.mutter(
49
 
                'creating config parent directory: %r', parent_dir)
50
 
            os.mkdir(parent_dir)
51
 
            osutils.copy_ownership_from_path(parent_dir)
 
48
        if sys.platform == 'win32':
 
49
            parent_dir = os.path.dirname(path)
 
50
            if not os.path.isdir(parent_dir):
 
51
                trace.mutter(
 
52
                    'creating config parent directory: %r', parent_dir)
 
53
                os.mkdir(parent_dir)
52
54
        trace.mutter('creating config directory: %r', path)
53
55
        os.mkdir(path)
54
56
        osutils.copy_ownership_from_path(path)
63
65
 
64
66
    TODO: Global option --config-dir to override this.
65
67
    """
66
 
    base = os.environ.get('BZR_HOME')
 
68
    base = osutils.path_from_environ('BZR_HOME')
67
69
    if sys.platform == 'win32':
68
70
        if base is None:
69
71
            base = win32utils.get_appdata_location()
71
73
            base = win32utils.get_home_location()
72
74
        return osutils.pathjoin(base, 'bazaar', '2.0')
73
75
    if base is None:
74
 
        xdg_dir = os.environ.get('XDG_CONFIG_HOME')
 
76
        xdg_dir = osutils.path_from_environ('XDG_CONFIG_HOME')
75
77
        if xdg_dir is None:
76
78
            xdg_dir = osutils.pathjoin(osutils._get_home_dir(), ".config")
77
79
        xdg_dir = osutils.pathjoin(xdg_dir, 'bazaar')
91
93
    the bazaar one (see bazaar_config_dir()) does, use that instead.
92
94
    """
93
95
    # TODO: Global option --config-dir to override this.
94
 
    base = os.environ.get('BRZ_HOME')
 
96
    base = osutils.path_from_environ('BRZ_HOME')
95
97
    if sys.platform == 'win32':
96
98
        if base is None:
97
99
            base = win32utils.get_appdata_location()
98
100
        if base is None:
99
101
            base = win32utils.get_home_location()
100
102
    if base is None:
101
 
        base = os.environ.get('XDG_CONFIG_HOME')
 
103
        base = osutils.path_from_environ('XDG_CONFIG_HOME')
102
104
        if base is None:
103
105
            base = osutils.pathjoin(osutils._get_home_dir(), ".config")
104
106
    breezy_dir = osutils.pathjoin(base, 'breezy')
166
168
 
167
169
def cache_dir():
168
170
    """Return the cache directory to use."""
169
 
    base = os.environ.get('BRZ_HOME')
 
171
    base = osutils.path_from_environ('BRZ_HOME')
170
172
    if sys.platform in "win32":
171
173
        if base is None:
172
174
            base = win32utils.get_local_appdata_location()
173
175
        if base is None:
174
176
            base = win32utils.get_home_location()
175
177
    else:
176
 
        base = os.environ.get('XDG_CACHE_HOME')
 
178
        base = osutils.path_from_environ('XDG_CACHE_HOME')
177
179
        if base is None:
178
180
            base = osutils.pathjoin(osutils._get_home_dir(), ".cache")
179
181