changeset 15658:971c55ce03b8 stable

largefiles: don't require a user cache (issue3088) (issue3155) If the user cache path isn't specified in .hgrc, and it can't be constructed from the environment, don't try to use that cache.
author Kevin Gessner <kevin@fogcreek.com>
date Thu, 15 Dec 2011 13:19:43 -0500
parents 7f01ad702405
children c7b0bedbb07a 20ae902c43ec 2c191e9c465b
files hgext/largefiles/lfutil.py
diffstat 1 files changed, 15 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/largefiles/lfutil.py	Mon Dec 12 17:10:19 2011 +0900
+++ b/hgext/largefiles/lfutil.py	Thu Dec 15 13:19:43 2011 -0500
@@ -91,22 +91,28 @@
     else:
         if os.name == 'nt':
             appdata = os.getenv('LOCALAPPDATA', os.getenv('APPDATA'))
-            path = os.path.join(appdata, longname, hash)
+            if appdata:
+                path = os.path.join(appdata, longname, hash)
         elif platform.system() == 'Darwin':
-            path = os.path.join(os.getenv('HOME'), 'Library', 'Caches',
-                                longname, hash)
+            home = os.getenv('HOME')
+            if home:
+                path = os.path.join(home, 'Library', 'Caches',
+                                    longname, hash)
         elif os.name == 'posix':
             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)
+                home = os.getenv('HOME')
+                if home:
+                    path = os.path.join(home, '.cache', longname, hash)
         else:
             raise util.Abort(_('unknown operating system: %s\n') % os.name)
     return path
 
 def inusercache(ui, hash):
-    return os.path.exists(usercachepath(ui, hash))
+    path = usercachepath(ui, hash)
+    return path and os.path.exists(path)
 
 def findfile(repo, hash):
     if instore(repo, hash):
@@ -239,8 +245,10 @@
         linktousercache(repo, hash)
 
 def linktousercache(repo, hash):
-    util.makedirs(os.path.dirname(usercachepath(repo.ui, hash)))
-    link(storepath(repo, hash), usercachepath(repo.ui, hash))
+    path = usercachepath(repo.ui, hash)
+    if path:
+        util.makedirs(os.path.dirname(path))
+        link(storepath(repo, hash), path)
 
 def getstandinmatcher(repo, pats=[], opts={}):
     '''Return a match object that applies pats to the standin directory'''