merge with stable
authorMatt Mackall <mpm@selenic.com>
Thu, 15 Dec 2011 16:50:21 -0600
changeset 15660 c7b0bedbb07a
parent 15659 7fba5a245acc (current diff)
parent 15658 971c55ce03b8 (diff)
child 15674 7b7f03502b5a
child 15687 46dffa176096
merge with stable
hgext/largefiles/lfutil.py
--- a/hgext/largefiles/lfutil.py	Thu Dec 15 23:08:09 2011 +0100
+++ b/hgext/largefiles/lfutil.py	Thu Dec 15 16:50:21 2011 -0600
@@ -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'''