Show More
@@ -34,8 +34,7 httpoldcallstream = None | |||||
34 | def putlfile(repo, proto, sha): |
|
34 | def putlfile(repo, proto, sha): | |
35 | '''Server command for putting a largefile into a repository's local store |
|
35 | '''Server command for putting a largefile into a repository's local store | |
36 | and into the user cache.''' |
|
36 | and into the user cache.''' | |
37 | proto.redirect() |
|
37 | with proto.mayberedirectstdio() as output: | |
38 |
|
||||
39 | path = lfutil.storepath(repo, sha) |
|
38 | path = lfutil.storepath(repo, sha) | |
40 | util.makedirs(os.path.dirname(path)) |
|
39 | util.makedirs(os.path.dirname(path)) | |
41 | tmpfp = util.atomictempfile(path, createmode=repo.store.createmode) |
|
40 | tmpfp = util.atomictempfile(path, createmode=repo.store.createmode) | |
@@ -50,11 +49,11 def putlfile(repo, proto, sha): | |||||
50 | except IOError as e: |
|
49 | except IOError as e: | |
51 | repo.ui.warn(_('largefiles: failed to put %s into store: %s\n') % |
|
50 | repo.ui.warn(_('largefiles: failed to put %s into store: %s\n') % | |
52 | (sha, e.strerror)) |
|
51 | (sha, e.strerror)) | |
53 | return wireproto.pushres(1) |
|
52 | return wireproto.pushres(1, output.getvalue() if output else '') | |
54 | finally: |
|
53 | finally: | |
55 | tmpfp.discard() |
|
54 | tmpfp.discard() | |
56 |
|
55 | |||
57 | return wireproto.pushres(0) |
|
56 | return wireproto.pushres(0, output.getvalue() if output else '') | |
58 |
|
57 | |||
59 | def getlfile(repo, proto, sha): |
|
58 | def getlfile(repo, proto, sha): | |
60 | '''Server command for retrieving a largefile from the repository-local |
|
59 | '''Server command for retrieving a largefile from the repository-local |
@@ -510,16 +510,18 class pushres(object): | |||||
510 |
|
510 | |||
511 | The call was successful and returned an integer contained in `self.res`. |
|
511 | The call was successful and returned an integer contained in `self.res`. | |
512 | """ |
|
512 | """ | |
513 | def __init__(self, res): |
|
513 | def __init__(self, res, output): | |
514 | self.res = res |
|
514 | self.res = res | |
|
515 | self.output = output | |||
515 |
|
516 | |||
516 | class pusherr(object): |
|
517 | class pusherr(object): | |
517 | """wireproto reply: failure |
|
518 | """wireproto reply: failure | |
518 |
|
519 | |||
519 | The call failed. The `self.res` attribute contains the error message. |
|
520 | The call failed. The `self.res` attribute contains the error message. | |
520 | """ |
|
521 | """ | |
521 | def __init__(self, res): |
|
522 | def __init__(self, res, output): | |
522 | self.res = res |
|
523 | self.res = res | |
|
524 | self.output = output | |||
523 |
|
525 | |||
524 | class ooberror(object): |
|
526 | class ooberror(object): | |
525 | """wireproto reply: failure of a batch of operation |
|
527 | """wireproto reply: failure of a batch of operation | |
@@ -997,9 +999,8 def stream(repo, proto): | |||||
997 | def unbundle(repo, proto, heads): |
|
999 | def unbundle(repo, proto, heads): | |
998 | their_heads = decodelist(heads) |
|
1000 | their_heads = decodelist(heads) | |
999 |
|
1001 | |||
|
1002 | with proto.mayberedirectstdio() as output: | |||
1000 | try: |
|
1003 | try: | |
1001 | proto.redirect() |
|
|||
1002 |
|
||||
1003 | exchange.check_heads(repo, their_heads, 'preparing changes') |
|
1004 | exchange.check_heads(repo, their_heads, 'preparing changes') | |
1004 |
|
1005 | |||
1005 | # write bundle data to temporary file because it can be big |
|
1006 | # write bundle data to temporary file because it can be big | |
@@ -1014,9 +1015,9 def unbundle(repo, proto, heads): | |||||
1014 | and not bundle1allowed(repo, 'push')): |
|
1015 | and not bundle1allowed(repo, 'push')): | |
1015 | if proto.name == 'http': |
|
1016 | if proto.name == 'http': | |
1016 | # need to special case http because stderr do not get to |
|
1017 | # need to special case http because stderr do not get to | |
1017 |
# the http client on failed push so we need to abuse |
|
1018 | # the http client on failed push so we need to abuse | |
1018 |
# other error type to make sure the message get to |
|
1019 | # some other error type to make sure the message get to | |
1019 | # user. |
|
1020 | # the user. | |
1020 | return ooberror(bundle2required) |
|
1021 | return ooberror(bundle2required) | |
1021 | raise error.Abort(bundle2requiredmain, |
|
1022 | raise error.Abort(bundle2requiredmain, | |
1022 | hint=bundle2requiredhint) |
|
1023 | hint=bundle2requiredhint) | |
@@ -1024,10 +1025,10 def unbundle(repo, proto, heads): | |||||
1024 | r = exchange.unbundle(repo, gen, their_heads, 'serve', |
|
1025 | r = exchange.unbundle(repo, gen, their_heads, 'serve', | |
1025 | proto._client()) |
|
1026 | proto._client()) | |
1026 | if util.safehasattr(r, 'addpart'): |
|
1027 | if util.safehasattr(r, 'addpart'): | |
1027 |
# The return looks streamable, we are in the bundle2 case |
|
1028 | # The return looks streamable, we are in the bundle2 case | |
1028 | # should return a stream. |
|
1029 | # and should return a stream. | |
1029 | return streamres_legacy(gen=r.getchunks()) |
|
1030 | return streamres_legacy(gen=r.getchunks()) | |
1030 | return pushres(r) |
|
1031 | return pushres(r, output.getvalue() if output else '') | |
1031 |
|
1032 | |||
1032 | finally: |
|
1033 | finally: | |
1033 | fp.close() |
|
1034 | fp.close() | |
@@ -1046,9 +1047,10 def unbundle(repo, proto, heads): | |||||
1046 | util.stderr.write("abort: %s\n" % exc) |
|
1047 | util.stderr.write("abort: %s\n" % exc) | |
1047 | if exc.hint is not None: |
|
1048 | if exc.hint is not None: | |
1048 | util.stderr.write("(%s)\n" % exc.hint) |
|
1049 | util.stderr.write("(%s)\n" % exc.hint) | |
1049 | return pushres(0) |
|
1050 | return pushres(0, output.getvalue() if output else '') | |
1050 | except error.PushRaced: |
|
1051 | except error.PushRaced: | |
1051 |
return pusherr(str(exc) |
|
1052 | return pusherr(str(exc), | |
|
1053 | output.getvalue() if output else '') | |||
1052 |
|
1054 | |||
1053 | bundler = bundle2.bundle20(repo.ui) |
|
1055 | bundler = bundle2.bundle20(repo.ui) | |
1054 | for out in getattr(exc, '_bundle2salvagedoutput', ()): |
|
1056 | for out in getattr(exc, '_bundle2salvagedoutput', ()): | |
@@ -1066,7 +1068,8 def unbundle(repo, proto, heads): | |||||
1066 | part = bundler.newpart('error:pushkey') |
|
1068 | part = bundler.newpart('error:pushkey') | |
1067 | part.addparam('in-reply-to', exc.partid) |
|
1069 | part.addparam('in-reply-to', exc.partid) | |
1068 | if exc.namespace is not None: |
|
1070 | if exc.namespace is not None: | |
1069 |
part.addparam('namespace', exc.namespace, |
|
1071 | part.addparam('namespace', exc.namespace, | |
|
1072 | mandatory=False) | |||
1070 | if exc.key is not None: |
|
1073 | if exc.key is not None: | |
1071 | part.addparam('key', exc.key, mandatory=False) |
|
1074 | part.addparam('key', exc.key, mandatory=False) | |
1072 | if exc.new is not None: |
|
1075 | if exc.new is not None: |
@@ -320,15 +320,13 def _callhttp(repo, req, proto, cmd): | |||||
320 | req.respond(HTTP_OK, mediatype) |
|
320 | req.respond(HTTP_OK, mediatype) | |
321 | return gen |
|
321 | return gen | |
322 | elif isinstance(rsp, wireproto.pushres): |
|
322 | elif isinstance(rsp, wireproto.pushres): | |
323 | val = proto.restore() |
|
323 | rsp = '%d\n%s' % (rsp.res, rsp.output) | |
324 | rsp = '%d\n%s' % (rsp.res, val) |
|
|||
325 | req.respond(HTTP_OK, HGTYPE, body=rsp) |
|
324 | req.respond(HTTP_OK, HGTYPE, body=rsp) | |
326 | return [] |
|
325 | return [] | |
327 | elif isinstance(rsp, wireproto.pusherr): |
|
326 | elif isinstance(rsp, wireproto.pusherr): | |
328 | # This is the httplib workaround documented in _handlehttperror(). |
|
327 | # This is the httplib workaround documented in _handlehttperror(). | |
329 | req.drain() |
|
328 | req.drain() | |
330 |
|
329 | |||
331 | proto.restore() |
|
|||
332 | rsp = '0\n%s\n' % rsp.res |
|
330 | rsp = '0\n%s\n' % rsp.res | |
333 | req.respond(HTTP_OK, HGTYPE, body=rsp) |
|
331 | req.respond(HTTP_OK, HGTYPE, body=rsp) | |
334 | return [] |
|
332 | return [] |
General Comments 0
You need to be logged in to leave comments.
Login now