comparison hgext/largefiles/lfutil.py @ 15320:681267a5f491 stable

largefiles: use XDG and OS X-specific cache locations by default (issue3067)
author Benjamin Pollack <benjamin@bitquabit.com>
date Thu, 20 Oct 2011 17:05:13 -0400
parents 9da7e96cd5c2
children f37b71fec602
comparison
equal deleted inserted replaced
15319:9da7e96cd5c2 15320:681267a5f491
8 8
9 '''largefiles utility code: must not import other modules in this package.''' 9 '''largefiles utility code: must not import other modules in this package.'''
10 10
11 import os 11 import os
12 import errno 12 import errno
13 import platform
13 import shutil 14 import shutil
14 import stat 15 import stat
15 import hashlib 16 import hashlib
16 17
17 from mercurial import dirstate, httpconnection, match as match_, util, scmutil 18 from mercurial import dirstate, httpconnection, match as match_, util, scmutil
86 path = os.path.join(path, hash) 87 path = os.path.join(path, hash)
87 else: 88 else:
88 if os.name == 'nt': 89 if os.name == 'nt':
89 appdata = os.getenv('LOCALAPPDATA', os.getenv('APPDATA')) 90 appdata = os.getenv('LOCALAPPDATA', os.getenv('APPDATA'))
90 path = os.path.join(appdata, longname, hash) 91 path = os.path.join(appdata, longname, hash)
92 elif platform.system() == 'Darwin':
93 path = os.path.join(os.getenv('HOME'), 'Library', 'Caches',
94 longname, hash)
91 elif os.name == 'posix': 95 elif os.name == 'posix':
92 path = os.path.join(os.getenv('HOME'), '.' + longname, hash) 96 path = os.getenv('XDG_CACHE_HOME')
97 if path:
98 path = os.path.join(path, longname, hash)
99 else:
100 path = os.path.join(os.getenv('HOME'), '.cache', longname, hash)
93 else: 101 else:
94 raise util.Abort(_('unknown operating system: %s\n') % os.name) 102 raise util.Abort(_('unknown operating system: %s\n') % os.name)
95 return path 103 return path
96 104
97 def inusercache(ui, hash): 105 def inusercache(ui, hash):