equal
deleted
inserted
replaced
37 ssholdcallstream = None |
37 ssholdcallstream = None |
38 httpoldcallstream = None |
38 httpoldcallstream = None |
39 |
39 |
40 |
40 |
41 def putlfile(repo, proto, sha): |
41 def putlfile(repo, proto, sha): |
42 '''Server command for putting a largefile into a repository's local store |
42 """Server command for putting a largefile into a repository's local store |
43 and into the user cache.''' |
43 and into the user cache.""" |
44 with proto.mayberedirectstdio() as output: |
44 with proto.mayberedirectstdio() as output: |
45 path = lfutil.storepath(repo, sha) |
45 path = lfutil.storepath(repo, sha) |
46 util.makedirs(os.path.dirname(path)) |
46 util.makedirs(os.path.dirname(path)) |
47 tmpfp = util.atomictempfile(path, createmode=repo.store.createmode) |
47 tmpfp = util.atomictempfile(path, createmode=repo.store.createmode) |
48 |
48 |
67 |
67 |
68 return wireprototypes.pushres(0, output.getvalue() if output else b'') |
68 return wireprototypes.pushres(0, output.getvalue() if output else b'') |
69 |
69 |
70 |
70 |
71 def getlfile(repo, proto, sha): |
71 def getlfile(repo, proto, sha): |
72 '''Server command for retrieving a largefile from the repository-local |
72 """Server command for retrieving a largefile from the repository-local |
73 cache or user cache.''' |
73 cache or user cache.""" |
74 filename = lfutil.findfile(repo, sha) |
74 filename = lfutil.findfile(repo, sha) |
75 if not filename: |
75 if not filename: |
76 raise error.Abort( |
76 raise error.Abort( |
77 _(b'requested largefile %s not present in cache') % sha |
77 _(b'requested largefile %s not present in cache') % sha |
78 ) |
78 ) |
91 |
91 |
92 return wireprototypes.streamreslegacy(gen=generator()) |
92 return wireprototypes.streamreslegacy(gen=generator()) |
93 |
93 |
94 |
94 |
95 def statlfile(repo, proto, sha): |
95 def statlfile(repo, proto, sha): |
96 '''Server command for checking if a largefile is present - returns '2\n' if |
96 """Server command for checking if a largefile is present - returns '2\n' if |
97 the largefile is missing, '0\n' if it seems to be in good condition. |
97 the largefile is missing, '0\n' if it seems to be in good condition. |
98 |
98 |
99 The value 1 is reserved for mismatched checksum, but that is too expensive |
99 The value 1 is reserved for mismatched checksum, but that is too expensive |
100 to be verified on every stat and must be caught be running 'hg verify' |
100 to be verified on every stat and must be caught be running 'hg verify' |
101 server side.''' |
101 server side.""" |
102 filename = lfutil.findfile(repo, sha) |
102 filename = lfutil.findfile(repo, sha) |
103 if not filename: |
103 if not filename: |
104 return wireprototypes.bytesresponse(b'2\n') |
104 return wireprototypes.bytesresponse(b'2\n') |
105 return wireprototypes.bytesresponse(b'0\n') |
105 return wireprototypes.bytesresponse(b'0\n') |
106 |
106 |
192 caps.append(b'largefiles=serve') |
192 caps.append(b'largefiles=serve') |
193 return caps |
193 return caps |
194 |
194 |
195 |
195 |
196 def heads(orig, repo, proto): |
196 def heads(orig, repo, proto): |
197 '''Wrap server command - largefile capable clients will know to call |
197 """Wrap server command - largefile capable clients will know to call |
198 lheads instead''' |
198 lheads instead""" |
199 if lfutil.islfilesrepo(repo): |
199 if lfutil.islfilesrepo(repo): |
200 return wireprototypes.ooberror(LARGEFILES_REQUIRED_MSG) |
200 return wireprototypes.ooberror(LARGEFILES_REQUIRED_MSG) |
201 |
201 |
202 return orig(repo, proto) |
202 return orig(repo, proto) |
203 |
203 |