Show More
@@ -39,6 +39,7 b' def getminsize(ui, assumelfiles, opt, de' | |||
|
39 | 39 | return lfsize |
|
40 | 40 | |
|
41 | 41 | def link(src, dest): |
|
42 | """Try to create hardlink - if that fails, efficiently make a copy.""" | |
|
42 | 43 | util.makedirs(os.path.dirname(dest)) |
|
43 | 44 | try: |
|
44 | 45 | util.oslink(src, dest) |
@@ -86,6 +87,9 b' def inusercache(ui, hash):' | |||
|
86 | 87 | return os.path.exists(path) |
|
87 | 88 | |
|
88 | 89 | def findfile(repo, hash): |
|
90 | '''Return store path of the largefile with the specified hash. | |
|
91 | As a side effect, the file might be linked from user cache. | |
|
92 | Return None if the file can't be found locally.''' | |
|
89 | 93 | path, exists = findstorepath(repo, hash) |
|
90 | 94 | if exists: |
|
91 | 95 | repo.ui.note(_('found %s in store\n') % hash) |
@@ -176,9 +180,13 b' def listlfiles(repo, rev=None, matcher=N' | |||
|
176 | 180 | if rev is not None or repo.dirstate[f] != '?'] |
|
177 | 181 | |
|
178 | 182 | def instore(repo, hash, forcelocal=False): |
|
183 | '''Return true if a largefile with the given hash exists in the user | |
|
184 | cache.''' | |
|
179 | 185 | return os.path.exists(storepath(repo, hash, forcelocal)) |
|
180 | 186 | |
|
181 | 187 | def storepath(repo, hash, forcelocal=False): |
|
188 | '''Return the correct location in the repository largefiles cache for a | |
|
189 | file with the given hash.''' | |
|
182 | 190 | if not forcelocal and repo.shared(): |
|
183 | 191 | return repo.vfs.reljoin(repo.sharedpath, longname, hash) |
|
184 | 192 | return repo.join(longname, hash) |
@@ -257,6 +265,8 b' def copytostoreabsolute(repo, file, hash' | |||
|
257 | 265 | linktousercache(repo, hash) |
|
258 | 266 | |
|
259 | 267 | def linktousercache(repo, hash): |
|
268 | '''Link / copy the largefile with the specified hash from the store | |
|
269 | to the cache.''' | |
|
260 | 270 | path = usercachepath(repo.ui, hash) |
|
261 | 271 | link(storepath(repo, hash), path) |
|
262 | 272 | |
@@ -394,6 +404,7 b' def unixpath(path):' | |||
|
394 | 404 | return util.pconvert(os.path.normpath(path)) |
|
395 | 405 | |
|
396 | 406 | def islfilesrepo(repo): |
|
407 | '''Return true if the repo is a largefile repo.''' | |
|
397 | 408 | if ('largefiles' in repo.requirements and |
|
398 | 409 | any(shortnameslash in f[0] for f in repo.store.datafiles())): |
|
399 | 410 | return True |
@@ -22,8 +22,8 b' ssholdcallstream = None' | |||
|
22 | 22 | httpoldcallstream = None |
|
23 | 23 | |
|
24 | 24 | def putlfile(repo, proto, sha): |
|
25 |
''' |
|
|
26 | user cache.''' | |
|
25 | '''Server command for putting a largefile into a repository's local store | |
|
26 | and into the user cache.''' | |
|
27 | 27 | proto.redirect() |
|
28 | 28 | |
|
29 | 29 | path = lfutil.storepath(repo, sha) |
@@ -47,8 +47,8 b' def putlfile(repo, proto, sha):' | |||
|
47 | 47 | return wireproto.pushres(0) |
|
48 | 48 | |
|
49 | 49 | def getlfile(repo, proto, sha): |
|
50 |
''' |
|
|
51 | cache.''' | |
|
50 | '''Server command for retrieving a largefile from the repository-local | |
|
51 | cache or user cache.''' | |
|
52 | 52 | filename = lfutil.findfile(repo, sha) |
|
53 | 53 | if not filename: |
|
54 | 54 | raise error.Abort(_('requested largefile %s not present in cache') |
@@ -68,8 +68,8 b' def getlfile(repo, proto, sha):' | |||
|
68 | 68 | return wireproto.streamres(generator()) |
|
69 | 69 | |
|
70 | 70 | def statlfile(repo, proto, sha): |
|
71 | '''Return '2\n' if the largefile is missing, '0\n' if it seems to be in | |
|
72 | good condition. | |
|
71 | '''Server command for checking if a largefile is present - returns '2\n' if | |
|
72 | the largefile is missing, '0\n' if it seems to be in good condition. | |
|
73 | 73 | |
|
74 | 74 | The value 1 is reserved for mismatched checksum, but that is too expensive |
|
75 | 75 | to be verified on every stat and must be caught be running 'hg verify' |
@@ -151,9 +151,12 b' def wirereposetup(ui, repo):' | |||
|
151 | 151 | |
|
152 | 152 | # advertise the largefiles=serve capability |
|
153 | 153 | def capabilities(repo, proto): |
|
154 | '''Wrap server command to announce largefile server capability''' | |
|
154 | 155 | return capabilitiesorig(repo, proto) + ' largefiles=serve' |
|
155 | 156 | |
|
156 | 157 | def heads(repo, proto): |
|
158 | '''Wrap server command - largefile capable clients will know to call | |
|
159 | lheads instead''' | |
|
157 | 160 | if lfutil.islfilesrepo(repo): |
|
158 | 161 | return wireproto.ooberror(LARGEFILES_REQUIRED_MSG) |
|
159 | 162 | return wireproto.heads(repo, proto) |
General Comments 0
You need to be logged in to leave comments.
Login now