[PATCH] largefiles: use XDG and OS X-specific cache locations by default (issue3067)
Benjamin Pollack
benjamin at bitquabit.com
Thu Oct 20 16:05:17 CDT 2011
# HG changeset patch
# User Benjamin Pollack <benjamin at bitquabit.com>
# Date 1319144713 14400
# Branch stable
# Node ID b48404c8e6cf7d44c324a3d4d808b316b5fc6736
# Parent ff7c2ca66a3cf2ab787a1bea5807797d668b103c
largefiles: use XDG and OS X-specific cache locations by default (issue3067)
diff --git a/hgext/largefiles/lfutil.py b/hgext/largefiles/lfutil.py
--- a/hgext/largefiles/lfutil.py
+++ b/hgext/largefiles/lfutil.py
@@ -10,6 +10,7 @@
import os
import errno
+import platform
import shutil
import stat
import hashlib
@@ -88,8 +89,14 @@
if os.name == 'nt':
appdata = os.getenv('LOCALAPPDATA', os.getenv('APPDATA'))
path = os.path.join(appdata, longname, hash)
+ elif platform.system() == 'Darwin':
+ path = os.path.join(os.getenv('HOME'), 'Library', 'Caches', longname, hash)
elif os.name == 'posix':
- path = os.path.join(os.getenv('HOME'), '.' + longname, hash)
+ path = os.getenv('XDG_CACHE_HOME')
+ if path:
+ path = os.path.join(path, longname, hash)
+ else:
+ path = os.path.join(os.getenv('HOME'), '.cache', longname, hash)
else:
raise util.Abort(_('unknown operating system: %s\n') % os.name)
return path
More information about the Mercurial-devel
mailing list