89 if path: |
89 if path: |
90 path = os.path.join(path, hash) |
90 path = os.path.join(path, hash) |
91 else: |
91 else: |
92 if os.name == 'nt': |
92 if os.name == 'nt': |
93 appdata = os.getenv('LOCALAPPDATA', os.getenv('APPDATA')) |
93 appdata = os.getenv('LOCALAPPDATA', os.getenv('APPDATA')) |
94 path = os.path.join(appdata, longname, hash) |
94 if appdata: |
|
95 path = os.path.join(appdata, longname, hash) |
95 elif platform.system() == 'Darwin': |
96 elif platform.system() == 'Darwin': |
96 path = os.path.join(os.getenv('HOME'), 'Library', 'Caches', |
97 home = os.getenv('HOME') |
97 longname, hash) |
98 if home: |
|
99 path = os.path.join(home, 'Library', 'Caches', |
|
100 longname, hash) |
98 elif os.name == 'posix': |
101 elif os.name == 'posix': |
99 path = os.getenv('XDG_CACHE_HOME') |
102 path = os.getenv('XDG_CACHE_HOME') |
100 if path: |
103 if path: |
101 path = os.path.join(path, longname, hash) |
104 path = os.path.join(path, longname, hash) |
102 else: |
105 else: |
103 path = os.path.join(os.getenv('HOME'), '.cache', longname, hash) |
106 home = os.getenv('HOME') |
|
107 if home: |
|
108 path = os.path.join(home, '.cache', longname, hash) |
104 else: |
109 else: |
105 raise util.Abort(_('unknown operating system: %s\n') % os.name) |
110 raise util.Abort(_('unknown operating system: %s\n') % os.name) |
106 return path |
111 return path |
107 |
112 |
108 def inusercache(ui, hash): |
113 def inusercache(ui, hash): |
109 return os.path.exists(usercachepath(ui, hash)) |
114 path = usercachepath(ui, hash) |
|
115 return path and os.path.exists(path) |
110 |
116 |
111 def findfile(repo, hash): |
117 def findfile(repo, hash): |
112 if instore(repo, hash): |
118 if instore(repo, hash): |
113 repo.ui.note(_('Found %s in store\n') % hash) |
119 repo.ui.note(_('Found %s in store\n') % hash) |
114 elif inusercache(repo.ui, hash): |
120 elif inusercache(repo.ui, hash): |
237 dst.close() |
243 dst.close() |
238 util.copymode(file, storepath(repo, hash)) |
244 util.copymode(file, storepath(repo, hash)) |
239 linktousercache(repo, hash) |
245 linktousercache(repo, hash) |
240 |
246 |
241 def linktousercache(repo, hash): |
247 def linktousercache(repo, hash): |
242 util.makedirs(os.path.dirname(usercachepath(repo.ui, hash))) |
248 path = usercachepath(repo.ui, hash) |
243 link(storepath(repo, hash), usercachepath(repo.ui, hash)) |
249 if path: |
|
250 util.makedirs(os.path.dirname(path)) |
|
251 link(storepath(repo, hash), path) |
244 |
252 |
245 def getstandinmatcher(repo, pats=[], opts={}): |
253 def getstandinmatcher(repo, pats=[], opts={}): |
246 '''Return a match object that applies pats to the standin directory''' |
254 '''Return a match object that applies pats to the standin directory''' |
247 standindir = repo.pathto(shortname) |
255 standindir = repo.pathto(shortname) |
248 if pats: |
256 if pats: |