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