##// END OF EJS Templates
bundle2: move exception classes into the error module...
Pierre-Yves David -
r21618:7568f5c1 default
parent child Browse files
Show More
@@ -172,16 +172,6 b' def _makefpartparamsizes(nbparams):'
172 172 """
173 173 return '>'+('BB'*nbparams)
174 174
175 class BundleValueError(ValueError):
176 """error raised when bundle2 cannot be processed
177
178 Current main usecase is unsupported part types."""
179 pass
180
181 class ReadOnlyPartError(RuntimeError):
182 """error raised when code tries to alter a part being generated"""
183 pass
184
185 175 parthandlermapping = {}
186 176
187 177 def parthandler(parttype):
@@ -309,7 +299,7 b' def processbundle(repo, unbundler, trans'
309 299 if key != parttype: # mandatory parts
310 300 # todo:
311 301 # - use a more precise exception
312 raise BundleValueError(key)
302 raise error.BundleValueError(key)
313 303 op.ui.debug('ignoring unknown advisory part %r\n' % key)
314 304 # consuming the part
315 305 part.read()
@@ -589,7 +579,7 b' class bundlepart(object):'
589 579 # methods used to defines the part content
590 580 def __setdata(self, data):
591 581 if self._generated is not None:
592 raise ReadOnlyPartError('part is being generated')
582 raise error.ReadOnlyPartError('part is being generated')
593 583 self._data = data
594 584 def __getdata(self):
595 585 return self._data
@@ -607,7 +597,7 b' class bundlepart(object):'
607 597
608 598 def addparam(self, name, value='', mandatory=True):
609 599 if self._generated is not None:
610 raise ReadOnlyPartError('part is being generated')
600 raise error.ReadOnlyPartError('part is being generated')
611 601 if name in self._seenparams:
612 602 raise ValueError('duplicated params: %s' % name)
613 603 self._seenparams.add(name)
@@ -841,7 +831,7 b' def handlereplycaps(op, inpart):'
841 831 @parthandler('b2x:error:unknownpart')
842 832 def handlereplycaps(op, inpart):
843 833 """Used to transmit unknown part error over the wire"""
844 raise BundleValueError(inpart.params['parttype'])
834 raise error.BundleValueError(inpart.params['parttype'])
845 835
846 836 @parthandler('b2x:error:pushraced')
847 837 def handlereplycaps(op, inpart):
@@ -98,3 +98,14 b' class SignatureError(Exception):'
98 98 class PushRaced(RuntimeError):
99 99 """An exception raised during unbundling that indicate a push race"""
100 100
101 # bundle2 related errors
102 class BundleValueError(ValueError):
103 """error raised when bundle2 cannot be processed
104
105 Current main usecase is unsupported part types."""
106 pass
107
108 class ReadOnlyPartError(RuntimeError):
109 """error raised when code tries to alter a part being generated"""
110 pass
111
@@ -224,11 +224,11 b' def _pushbundle2(pushop):'
224 224 stream = util.chunkbuffer(bundler.getchunks())
225 225 try:
226 226 reply = pushop.remote.unbundle(stream, ['force'], 'push')
227 except bundle2.BundleValueError, exc:
227 except error.BundleValueError, exc:
228 228 raise util.Abort('missing support for %s' % exc)
229 229 try:
230 230 op = bundle2.processbundle(pushop.repo, reply)
231 except bundle2.BundleValueError, exc:
231 except error.BundleValueError, exc:
232 232 raise util.Abort('missing support for %s' % exc)
233 233 cgreplies = op.records.getreplies(cgpart.id)
234 234 assert len(cgreplies['changegroup']) == 1
@@ -554,7 +554,7 b' def _pullbundle2(pullop):'
554 554 bundle = pullop.remote.getbundle('pull', **kwargs)
555 555 try:
556 556 op = bundle2.processbundle(pullop.repo, bundle, pullop.gettransaction)
557 except bundle2.BundleValueError, exc:
557 except error.BundleValueError, exc:
558 558 raise util.Abort('missing support for %s' % exc)
559 559
560 560 if pullop.fetch:
@@ -803,7 +803,7 b' def unbundle(repo, proto, heads):'
803 803 finally:
804 804 fp.close()
805 805 os.unlink(tempname)
806 except bundle2.BundleValueError, exc:
806 except error.BundleValueError, exc:
807 807 bundler = bundle2.bundle20(repo.ui)
808 808 bundler.newpart('B2X:ERROR:UNKNOWNPART', [('parttype', str(exc))])
809 809 return streamres(bundler.getchunks())
@@ -135,7 +135,7 b' Create an extension to test bundle2 API'
135 135 > unbundler = bundle2.unbundle20(ui, sys.stdin)
136 136 > op = bundle2.processbundle(repo, unbundler, lambda: tr)
137 137 > tr.close()
138 > except bundle2.BundleValueError, exc:
138 > except error.BundleValueError, exc:
139 139 > raise util.Abort('missing support for %s' % exc)
140 140 > except error.PushRaced, exc:
141 141 > raise util.Abort('push race: %s' % exc)
General Comments 0
You need to be logged in to leave comments. Login now