/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-04-05 19:11:34 UTC
  • mto: (7490.7.16 work)
  • mto: This revision was merged to the branch mainline in revision 7501.
  • Revision ID: jelmer@jelmer.uk-20200405191134-0aebh8ikiwygxma5
Populate the .gitignore file.

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
 
31
33
from . import (
32
34
    errors,
33
35
    )
 
36
from .sixish import (
 
37
    PY3,
 
38
    )
34
39
 
35
40
 
36
41
def ensure_config_dir_exists(path=None):
43
48
    if path is None:
44
49
        path = config_dir()
45
50
    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)
 
51
        if sys.platform == 'win32':
 
52
            parent_dir = os.path.dirname(path)
 
53
            if not os.path.isdir(parent_dir):
 
54
                trace.mutter(
 
55
                    'creating config parent directory: %r', parent_dir)
 
56
                os.mkdir(parent_dir)
52
57
        trace.mutter('creating config directory: %r', path)
53
58
        os.mkdir(path)
54
59
        osutils.copy_ownership_from_path(path)
63
68
 
64
69
    TODO: Global option --config-dir to override this.
65
70
    """
66
 
    base = os.environ.get('BZR_HOME')
 
71
    base = osutils.path_from_environ('BZR_HOME')
67
72
    if sys.platform == 'win32':
68
73
        if base is None:
69
74
            base = win32utils.get_appdata_location()
71
76
            base = win32utils.get_home_location()
72
77
        return osutils.pathjoin(base, 'bazaar', '2.0')
73
78
    if base is None:
74
 
        xdg_dir = os.environ.get('XDG_CONFIG_HOME')
 
79
        xdg_dir = osutils.path_from_environ('XDG_CONFIG_HOME')
75
80
        if xdg_dir is None:
76
81
            xdg_dir = osutils.pathjoin(osutils._get_home_dir(), ".config")
77
82
        xdg_dir = osutils.pathjoin(xdg_dir, 'bazaar')
91
96
    the bazaar one (see bazaar_config_dir()) does, use that instead.
92
97
    """
93
98
    # TODO: Global option --config-dir to override this.
94
 
    base = os.environ.get('BRZ_HOME')
 
99
    base = osutils.path_from_environ('BRZ_HOME')
95
100
    if sys.platform == 'win32':
96
101
        if base is None:
97
102
            base = win32utils.get_appdata_location()
98
103
        if base is None:
99
104
            base = win32utils.get_home_location()
100
105
    if base is None:
101
 
        base = os.environ.get('XDG_CONFIG_HOME')
 
106
        base = osutils.path_from_environ('XDG_CONFIG_HOME')
102
107
        if base is None:
103
108
            base = osutils.pathjoin(osutils._get_home_dir(), ".config")
104
109
    breezy_dir = osutils.pathjoin(base, 'breezy')
166
171
 
167
172
def cache_dir():
168
173
    """Return the cache directory to use."""
169
 
    base = os.environ.get('BRZ_HOME')
 
174
    base = osutils.path_from_environ('BRZ_HOME')
170
175
    if sys.platform in "win32":
171
176
        if base is None:
172
177
            base = win32utils.get_local_appdata_location()
173
178
        if base is None:
174
179
            base = win32utils.get_home_location()
175
180
    else:
176
 
        base = os.environ.get('XDG_CACHE_HOME')
 
181
        base = osutils.path_from_environ('XDG_CACHE_HOME')
177
182
        if base is None:
178
183
            base = osutils.pathjoin(osutils._get_home_dir(), ".cache")
179
184
 
208
213
def default_email():
209
214
    v = os.environ.get('BRZ_EMAIL')
210
215
    if v:
 
216
        if not PY3:
 
217
            v = v.decode(osutils.get_user_encoding())
211
218
        return v
212
219
    v = os.environ.get('EMAIL')
213
220
    if v:
 
221
        if not PY3:
 
222
            v = v.decode(osutils.get_user_encoding())
214
223
        return v
215
224
    name, email = _auto_user_id()
216
225
    if name and email: