hgext/largefiles/lfutil.py
changeset 30820 6a70cf94d1b5
parent 30664 69acfd2ca11e
child 31216 21fa3d3688f3
equal deleted inserted replaced
30819:897726622877 30820:6a70cf94d1b5
    17 
    17 
    18 from mercurial.i18n import _
    18 from mercurial.i18n import _
    19 
    19 
    20 from mercurial import (
    20 from mercurial import (
    21     dirstate,
    21     dirstate,
       
    22     encoding,
    22     error,
    23     error,
    23     httpconnection,
    24     httpconnection,
    24     match as matchmod,
    25     match as matchmod,
    25     node,
    26     node,
    26     pycompat,
    27     pycompat,
    72     '''Return the location of the "global" largefiles cache.'''
    73     '''Return the location of the "global" largefiles cache.'''
    73     path = ui.configpath(longname, 'usercache', None)
    74     path = ui.configpath(longname, 'usercache', None)
    74     if path:
    75     if path:
    75         return path
    76         return path
    76     if pycompat.osname == 'nt':
    77     if pycompat.osname == 'nt':
    77         appdata = pycompat.osgetenv('LOCALAPPDATA',\
    78         appdata = encoding.environ.get('LOCALAPPDATA',\
    78                         pycompat.osgetenv('APPDATA'))
    79                         encoding.environ.get('APPDATA'))
    79         if appdata:
    80         if appdata:
    80             return os.path.join(appdata, longname)
    81             return os.path.join(appdata, longname)
    81     elif platform.system() == 'Darwin':
    82     elif platform.system() == 'Darwin':
    82         home = pycompat.osgetenv('HOME')
    83         home = encoding.environ.get('HOME')
    83         if home:
    84         if home:
    84             return os.path.join(home, 'Library', 'Caches', longname)
    85             return os.path.join(home, 'Library', 'Caches', longname)
    85     elif pycompat.osname == 'posix':
    86     elif pycompat.osname == 'posix':
    86         path = pycompat.osgetenv('XDG_CACHE_HOME')
    87         path = encoding.environ.get('XDG_CACHE_HOME')
    87         if path:
    88         if path:
    88             return os.path.join(path, longname)
    89             return os.path.join(path, longname)
    89         home = pycompat.osgetenv('HOME')
    90         home = encoding.environ.get('HOME')
    90         if home:
    91         if home:
    91             return os.path.join(home, '.cache', longname)
    92             return os.path.join(home, '.cache', longname)
    92     else:
    93     else:
    93         raise error.Abort(_('unknown operating system: %s\n')
    94         raise error.Abort(_('unknown operating system: %s\n')
    94                           % pycompat.osname)
    95                           % pycompat.osname)