##// END OF EJS Templates
largefiles: rename functions and methods to match desired behavior...
Benjamin Pollack -
r15316:c65f5b6e stable
parent child Browse files
Show More
@@ -74,13 +74,13 class basestore(object):
74 74 at += 1
75 75 ui.note(_('getting %s:%s\n') % (filename, hash))
76 76
77 cachefilename = lfutil.cachepath(self.repo, hash)
78 cachedir = os.path.dirname(cachefilename)
77 storefilename = lfutil.storepath(self.repo, hash)
78 storedir = os.path.dirname(storefilename)
79 79
80 80 # No need to pass mode='wb' to fdopen(), since mkstemp() already
81 81 # opened the file in binary mode.
82 82 (tmpfd, tmpfilename) = tempfile.mkstemp(
83 dir=cachedir, prefix=os.path.basename(filename))
83 dir=storedir, prefix=os.path.basename(filename))
84 84 tmpfile = os.fdopen(tmpfd, 'w')
85 85
86 86 try:
@@ -98,10 +98,10 class basestore(object):
98 98 missing.append(filename)
99 99 continue
100 100
101 if os.path.exists(cachefilename): # Windows
102 os.remove(cachefilename)
103 os.rename(tmpfilename, cachefilename)
104 lfutil.linktosystemcache(self.repo, hash)
101 if os.path.exists(storefilename): # Windows
102 os.remove(storefilename)
103 os.rename(tmpfilename, storefilename)
104 lfutil.linktousercache(self.repo, hash)
105 105 success.append((filename, hhash))
106 106
107 107 ui.progress(_('getting largefiles'), None)
@@ -80,8 +80,8 def link(src, dest):
80 80 shutil.copyfile(src, dest)
81 81 os.chmod(dest, os.stat(src).st_mode)
82 82
83 def systemcachepath(ui, hash):
84 path = ui.config(longname, 'systemcache', None)
83 def usercachepath(ui, hash):
84 path = ui.config(longname, 'usercache', None)
85 85 if path:
86 86 path = os.path.join(path, hash)
87 87 else:
@@ -94,16 +94,16 def systemcachepath(ui, hash):
94 94 raise util.Abort(_('unknown operating system: %s\n') % os.name)
95 95 return path
96 96
97 def insystemcache(ui, hash):
98 return os.path.exists(systemcachepath(ui, hash))
97 def inusercache(ui, hash):
98 return os.path.exists(usercachepath(ui, hash))
99 99
100 100 def findfile(repo, hash):
101 if incache(repo, hash):
102 repo.ui.note(_('Found %s in cache\n') % hash)
103 return cachepath(repo, hash)
104 if insystemcache(repo.ui, hash):
101 if instore(repo, hash):
102 repo.ui.note(_('Found %s in store\n') % hash)
103 return storepath(repo, hash)
104 if inusercache(repo.ui, hash):
105 105 repo.ui.note(_('Found %s in system cache\n') % hash)
106 return systemcachepath(repo.ui, hash)
106 return usercachepath(repo.ui, hash)
107 107 return None
108 108
109 109 class largefiles_dirstate(dirstate.dirstate):
@@ -188,14 +188,14 def listlfiles(repo, rev=None, matcher=N
188 188 for f in repo[rev].walk(matcher)
189 189 if rev is not None or repo.dirstate[f] != '?']
190 190
191 def incache(repo, hash):
192 return os.path.exists(cachepath(repo, hash))
191 def instore(repo, hash):
192 return os.path.exists(storepath(repo, hash))
193 193
194 194 def createdir(dir):
195 195 if not os.path.exists(dir):
196 196 os.makedirs(dir)
197 197
198 def cachepath(repo, hash):
198 def storepath(repo, hash):
199 199 return repo.join(os.path.join(longname, hash))
200 200
201 201 def copyfromcache(repo, hash, filename):
@@ -211,24 +211,24 def copyfromcache(repo, hash, filename):
211 211 shutil.copy(path, repo.wjoin(filename))
212 212 return True
213 213
214 def copytocache(repo, rev, file, uploaded=False):
214 def copytostore(repo, rev, file, uploaded=False):
215 215 hash = readstandin(repo, file)
216 if incache(repo, hash):
216 if instore(repo, hash):
217 217 return
218 copytocacheabsolute(repo, repo.wjoin(file), hash)
218 copytostoreabsolute(repo, repo.wjoin(file), hash)
219 219
220 def copytocacheabsolute(repo, file, hash):
221 createdir(os.path.dirname(cachepath(repo, hash)))
222 if insystemcache(repo.ui, hash):
223 link(systemcachepath(repo.ui, hash), cachepath(repo, hash))
220 def copytostoreabsolute(repo, file, hash):
221 createdir(os.path.dirname(storepath(repo, hash)))
222 if inusercache(repo.ui, hash):
223 link(usercachepath(repo.ui, hash), storepath(repo, hash))
224 224 else:
225 shutil.copyfile(file, cachepath(repo, hash))
226 os.chmod(cachepath(repo, hash), os.stat(file).st_mode)
227 linktosystemcache(repo, hash)
225 shutil.copyfile(file, storepath(repo, hash))
226 os.chmod(storepath(repo, hash), os.stat(file).st_mode)
227 linktousercache(repo, hash)
228 228
229 def linktosystemcache(repo, hash):
230 createdir(os.path.dirname(systemcachepath(repo.ui, hash)))
231 link(cachepath(repo, hash), systemcachepath(repo.ui, hash))
229 def linktousercache(repo, hash):
230 createdir(os.path.dirname(usercachepath(repo.ui, hash)))
231 link(storepath(repo, hash), usercachepath(repo.ui, hash))
232 232
233 233 def getstandinmatcher(repo, pats=[], opts={}):
234 234 '''Return a match object that applies pats to the standin directory'''
@@ -31,11 +31,11 class localstore(basestore.basestore):
31 31 return
32 32
33 33 def exists(self, hash):
34 return lfutil.insystemcache(self.repo.ui, hash)
34 return lfutil.inusercache(self.repo.ui, hash)
35 35
36 36 def _getfile(self, tmpfile, filename, hash):
37 if lfutil.insystemcache(self.ui, hash):
38 return lfutil.systemcachepath(self.ui, hash)
37 if lfutil.inusercache(self.ui, hash):
38 return lfutil.usercachepath(self.ui, hash)
39 39 raise basestore.StoreError(filename, hash, '',
40 40 _("Can't get file locally"))
41 41
@@ -50,7 +50,7 class localstore(basestore.basestore):
50 50
51 51 expecthash = fctx.data()[0:40]
52 52 verified.add(key)
53 if not lfutil.insystemcache(self.ui, expecthash):
53 if not lfutil.inusercache(self.ui, expecthash):
54 54 self.ui.warn(
55 55 _('changeset %s: %s missing\n'
56 56 ' (looked for hash %s)\n')
@@ -58,7 +58,7 class localstore(basestore.basestore):
58 58 return True # failed
59 59
60 60 if contents:
61 storepath = lfutil.systemcachepath(self.ui, expecthash)
61 storepath = lfutil.usercachepath(self.ui, expecthash)
62 62 actualhash = lfutil.hashfile(storepath)
63 63 if actualhash != expecthash:
64 64 self.ui.warn(
@@ -28,7 +28,7 def putlfile(repo, proto, sha):
28 28 f.seek(0)
29 29 if sha != lfutil.hexsha1(f):
30 30 return wireproto.pushres(1)
31 lfutil.copytocacheabsolute(repo, f.name, sha)
31 lfutil.copytostoreabsolute(repo, f.name, sha)
32 32 except IOError:
33 33 repo.ui.warn(
34 34 _('error: could not put received data into largefile store'))
@@ -228,7 +228,7 def reposetup(ui, repo):
228 228 for filename in ctx.files():
229 229 if lfutil.isstandin(filename) and filename in ctx.manifest():
230 230 realfile = lfutil.splitstandin(filename)
231 lfutil.copytocache(self, ctx.node(), realfile)
231 lfutil.copytostore(self, ctx.node(), realfile)
232 232
233 233 return node
234 234
General Comments 0
You need to be logged in to leave comments. Login now