##// END OF EJS Templates
bundle2: rename UnknownPartError to BundleValueError...
Pierre-Yves David -
r21617:0cfda08a default
parent child Browse files
Show More
@@ -172,8 +172,10 b' def _makefpartparamsizes(nbparams):'
172 """
172 """
173 return '>'+('BB'*nbparams)
173 return '>'+('BB'*nbparams)
174
174
175 class UnknownPartError(KeyError):
175 class BundleValueError(ValueError):
176 """error raised when no handler is found for a Mandatory part"""
176 """error raised when bundle2 cannot be processed
177
178 Current main usecase is unsupported part types."""
177 pass
179 pass
178
180
179 class ReadOnlyPartError(RuntimeError):
181 class ReadOnlyPartError(RuntimeError):
@@ -307,7 +309,7 b' def processbundle(repo, unbundler, trans'
307 if key != parttype: # mandatory parts
309 if key != parttype: # mandatory parts
308 # todo:
310 # todo:
309 # - use a more precise exception
311 # - use a more precise exception
310 raise UnknownPartError(key)
312 raise BundleValueError(key)
311 op.ui.debug('ignoring unknown advisory part %r\n' % key)
313 op.ui.debug('ignoring unknown advisory part %r\n' % key)
312 # consuming the part
314 # consuming the part
313 part.read()
315 part.read()
@@ -839,7 +841,7 b' def handlereplycaps(op, inpart):'
839 @parthandler('b2x:error:unknownpart')
841 @parthandler('b2x:error:unknownpart')
840 def handlereplycaps(op, inpart):
842 def handlereplycaps(op, inpart):
841 """Used to transmit unknown part error over the wire"""
843 """Used to transmit unknown part error over the wire"""
842 raise UnknownPartError(inpart.params['parttype'])
844 raise BundleValueError(inpart.params['parttype'])
843
845
844 @parthandler('b2x:error:pushraced')
846 @parthandler('b2x:error:pushraced')
845 def handlereplycaps(op, inpart):
847 def handlereplycaps(op, inpart):
@@ -224,11 +224,11 b' def _pushbundle2(pushop):'
224 stream = util.chunkbuffer(bundler.getchunks())
224 stream = util.chunkbuffer(bundler.getchunks())
225 try:
225 try:
226 reply = pushop.remote.unbundle(stream, ['force'], 'push')
226 reply = pushop.remote.unbundle(stream, ['force'], 'push')
227 except bundle2.UnknownPartError, exc:
227 except bundle2.BundleValueError, exc:
228 raise util.Abort('missing support for %s' % exc)
228 raise util.Abort('missing support for %s' % exc)
229 try:
229 try:
230 op = bundle2.processbundle(pushop.repo, reply)
230 op = bundle2.processbundle(pushop.repo, reply)
231 except bundle2.UnknownPartError, exc:
231 except bundle2.BundleValueError, exc:
232 raise util.Abort('missing support for %s' % exc)
232 raise util.Abort('missing support for %s' % exc)
233 cgreplies = op.records.getreplies(cgpart.id)
233 cgreplies = op.records.getreplies(cgpart.id)
234 assert len(cgreplies['changegroup']) == 1
234 assert len(cgreplies['changegroup']) == 1
@@ -554,7 +554,7 b' def _pullbundle2(pullop):'
554 bundle = pullop.remote.getbundle('pull', **kwargs)
554 bundle = pullop.remote.getbundle('pull', **kwargs)
555 try:
555 try:
556 op = bundle2.processbundle(pullop.repo, bundle, pullop.gettransaction)
556 op = bundle2.processbundle(pullop.repo, bundle, pullop.gettransaction)
557 except bundle2.UnknownPartError, exc:
557 except bundle2.BundleValueError, exc:
558 raise util.Abort('missing support for %s' % exc)
558 raise util.Abort('missing support for %s' % exc)
559
559
560 if pullop.fetch:
560 if pullop.fetch:
@@ -803,7 +803,7 b' def unbundle(repo, proto, heads):'
803 finally:
803 finally:
804 fp.close()
804 fp.close()
805 os.unlink(tempname)
805 os.unlink(tempname)
806 except bundle2.UnknownPartError, exc:
806 except bundle2.BundleValueError, exc:
807 bundler = bundle2.bundle20(repo.ui)
807 bundler = bundle2.bundle20(repo.ui)
808 bundler.newpart('B2X:ERROR:UNKNOWNPART', [('parttype', str(exc))])
808 bundler.newpart('B2X:ERROR:UNKNOWNPART', [('parttype', str(exc))])
809 return streamres(bundler.getchunks())
809 return streamres(bundler.getchunks())
@@ -135,7 +135,7 b' Create an extension to test bundle2 API'
135 > unbundler = bundle2.unbundle20(ui, sys.stdin)
135 > unbundler = bundle2.unbundle20(ui, sys.stdin)
136 > op = bundle2.processbundle(repo, unbundler, lambda: tr)
136 > op = bundle2.processbundle(repo, unbundler, lambda: tr)
137 > tr.close()
137 > tr.close()
138 > except KeyError, exc:
138 > except bundle2.BundleValueError, exc:
139 > raise util.Abort('missing support for %s' % exc)
139 > raise util.Abort('missing support for %s' % exc)
140 > except error.PushRaced, exc:
140 > except error.PushRaced, exc:
141 > raise util.Abort('push race: %s' % exc)
141 > raise util.Abort('push race: %s' % exc)
@@ -537,7 +537,7 b' Unbundle with an unknown mandatory part'
537 Emana Karassoli, Loucra Loucra Ponponto, Pata Pata, Ko Ko Ko.
537 Emana Karassoli, Loucra Loucra Ponponto, Pata Pata, Ko Ko Ko.
538 debugreply: no reply
538 debugreply: no reply
539 0 unread bytes
539 0 unread bytes
540 abort: missing support for 'test:unknown'
540 abort: missing support for test:unknown
541 [255]
541 [255]
542
542
543 unbundle with a reply
543 unbundle with a reply
@@ -1004,19 +1004,19 b' Doing the actual push: unknown mandatory'
1004 $ hg -R main push other -r e7ec4e813ba6
1004 $ hg -R main push other -r e7ec4e813ba6
1005 pushing to other
1005 pushing to other
1006 searching for changes
1006 searching for changes
1007 abort: missing support for 'test:unknown'
1007 abort: missing support for test:unknown
1008 [255]
1008 [255]
1009
1009
1010 $ hg -R main push ssh://user@dummy/other -r e7ec4e813ba6
1010 $ hg -R main push ssh://user@dummy/other -r e7ec4e813ba6
1011 pushing to ssh://user@dummy/other
1011 pushing to ssh://user@dummy/other
1012 searching for changes
1012 searching for changes
1013 abort: missing support for "'test:unknown'"
1013 abort: missing support for test:unknown
1014 [255]
1014 [255]
1015
1015
1016 $ hg -R main push http://localhost:$HGPORT2/ -r e7ec4e813ba6
1016 $ hg -R main push http://localhost:$HGPORT2/ -r e7ec4e813ba6
1017 pushing to http://localhost:$HGPORT2/
1017 pushing to http://localhost:$HGPORT2/
1018 searching for changes
1018 searching for changes
1019 abort: missing support for "'test:unknown'"
1019 abort: missing support for test:unknown
1020 [255]
1020 [255]
1021
1021
1022 Doing the actual push: race
1022 Doing the actual push: race
General Comments 0
You need to be logged in to leave comments. Login now