25 try: |
25 try: |
26 try: |
26 try: |
27 proto.getfile(tmpfp) |
27 proto.getfile(tmpfp) |
28 tmpfp.seek(0) |
28 tmpfp.seek(0) |
29 if sha != lfutil.hexsha1(tmpfp): |
29 if sha != lfutil.hexsha1(tmpfp): |
30 return wireproto.pushres(1) |
30 raise IOError(0, _('largefile contents do not match hash')) |
31 tmpfp.close() |
31 tmpfp.close() |
32 lfutil.copytostoreabsolute(repo, tmpname, sha) |
32 lfutil.copytostoreabsolute(repo, tmpname, sha) |
33 except IOError, e: |
33 except IOError, e: |
34 repo.ui.warn(_('largefiles: failed to put %s (%s) into store: %s') % |
34 repo.ui.warn(_('largefiles: failed to put %s into store: %s') % |
35 (sha, tmpname, e.strerror)) |
35 (sha, e.strerror)) |
36 return wireproto.pushres(1) |
36 return wireproto.pushres(1) |
37 finally: |
37 finally: |
38 tmpfp.close() |
38 tmpfp.close() |
39 os.unlink(tmpname) |
39 os.unlink(tmpname) |
40 |
40 |
79 def putlfile(self, sha, fd): |
79 def putlfile(self, sha, fd): |
80 # unfortunately, httprepository._callpush tries to convert its |
80 # unfortunately, httprepository._callpush tries to convert its |
81 # input file-like into a bundle before sending it, so we can't use |
81 # input file-like into a bundle before sending it, so we can't use |
82 # it ... |
82 # it ... |
83 if issubclass(self.__class__, httprepo.httprepository): |
83 if issubclass(self.__class__, httprepo.httprepository): |
|
84 res = None |
84 try: |
85 try: |
85 return int(self._call('putlfile', data=fd, sha=sha, |
86 res = self._call('putlfile', data=fd, sha=sha, |
86 headers={'content-type':'application/mercurial-0.1'})) |
87 headers={'content-type':'application/mercurial-0.1'}) |
|
88 d, output = res.split('\n', 1) |
|
89 for l in output.splitlines(True): |
|
90 self.ui.warn(_('remote: '), l, '\n') |
|
91 return int(d) |
87 except (ValueError, urllib2.HTTPError): |
92 except (ValueError, urllib2.HTTPError): |
|
93 self.ui.warn(_('unexpected putlfile response: %s') % res) |
88 return 1 |
94 return 1 |
89 # ... but we can't use sshrepository._call because the data= |
95 # ... but we can't use sshrepository._call because the data= |
90 # argument won't get sent, and _callpush does exactly what we want |
96 # argument won't get sent, and _callpush does exactly what we want |
91 # in this case: send the data straight through |
97 # in this case: send the data straight through |
92 else: |
98 else: |