##// END OF EJS Templates
bundle2: gracefully handle PushRaced error during unbundle...
Pierre-Yves David -
r21186:9f3652e8 stable
parent child Browse files
Show More
@@ -760,3 +760,9 b' def handlereplycaps(op, inpart):'
760 """Used to transmit unknown part error over the wire"""
760 """Used to transmit unknown part error over the wire"""
761 manargs = dict(inpart.mandatoryparams)
761 manargs = dict(inpart.mandatoryparams)
762 raise UnknownPartError(manargs['parttype'])
762 raise UnknownPartError(manargs['parttype'])
763
764 @parthandler('b2x:error:pushraced')
765 def handlereplycaps(op, inpart):
766 """Used to transmit push race error over the wire"""
767 manargs = dict(inpart.mandatoryparams)
768 raise error.ResponseError(_('push failed:'), manargs['message'])
@@ -134,7 +134,7 b' class localpeer(peer.peerrepository):'
134 ret = bundle2.unbundle20(self.ui, stream)
134 ret = bundle2.unbundle20(self.ui, stream)
135 return ret
135 return ret
136 except error.PushRaced, exc:
136 except error.PushRaced, exc:
137 raise error.ResponseError(_('push failed:'), exc.message)
137 raise error.ResponseError(_('push failed:'), str(exc))
138
138
139 def lock(self):
139 def lock(self):
140 return self._repo.lock()
140 return self._repo.lock()
@@ -827,4 +827,11 b' def unbundle(repo, proto, heads):'
827 sys.stderr.write("abort: %s\n" % inst)
827 sys.stderr.write("abort: %s\n" % inst)
828 return pushres(0)
828 return pushres(0)
829 except error.PushRaced, exc:
829 except error.PushRaced, exc:
830 return pusherr(str(exc))
830 if getattr(exc, 'duringunbundle2', False):
831 bundler = bundle2.bundle20(repo.ui)
832 part = bundle2.bundlepart('B2X:ERROR:PUSHRACED',
833 [('message', str(exc))])
834 bundler.addpart(part)
835 return streamres(bundler.getchunks())
836 else:
837 return pusherr(str(exc))
@@ -927,6 +927,9 b' Setting up'
927 > part = bundle2.bundlepart('test:abort')
927 > part = bundle2.bundlepart('test:abort')
928 > if reason == 'unknown':
928 > if reason == 'unknown':
929 > part = bundle2.bundlepart('TEST:UNKNOWN')
929 > part = bundle2.bundlepart('TEST:UNKNOWN')
930 > if reason == 'race':
931 > # 20 Bytes of crap
932 > part = bundle2.bundlepart('b2x:check:heads', data='01234567890123456789')
930 > if part is not None:
933 > if part is not None:
931 > bundler.addpart(part)
934 > bundler.addpart(part)
932 > return extradata
935 > return extradata
@@ -1012,3 +1015,31 b' Doing the actual push: unknown mandatory'
1012 searching for changes
1015 searching for changes
1013 abort: missing support for "'test:unknown'"
1016 abort: missing support for "'test:unknown'"
1014 [255]
1017 [255]
1018
1019 Doing the actual push: race
1020
1021 $ cat << EOF >> $HGRCPATH
1022 > [failpush]
1023 > reason = race
1024 > EOF
1025
1026 $ hg -R main push other -r e7ec4e813ba6
1027 pushing to other
1028 searching for changes
1029 abort: push failed:
1030 'repository changed while pushing - please try again'
1031 [255]
1032
1033 $ hg -R main push ssh://user@dummy/other -r e7ec4e813ba6
1034 pushing to ssh://user@dummy/other
1035 searching for changes
1036 abort: push failed:
1037 'repository changed while pushing - please try again'
1038 [255]
1039
1040 $ hg -R main push http://localhost:$HGPORT2/ -r e7ec4e813ba6
1041 pushing to http://localhost:$HGPORT2/
1042 searching for changes
1043 abort: push failed:
1044 'repository changed while pushing - please try again'
1045 [255]
General Comments 0
You need to be logged in to leave comments. Login now