Mercurial > public > mercurial-scm > hg-stable
diff mercurial/bundle2.py @ 21618:7568f5c1c801
bundle2: move exception classes into the error module
Exceptions should have known their place.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Wed, 28 May 2014 15:31:05 -0700 |
parents | 0cfda08afd24 |
children | 292331e906d7 |
line wrap: on
line diff
--- a/mercurial/bundle2.py Wed May 28 14:22:24 2014 -0700 +++ b/mercurial/bundle2.py Wed May 28 15:31:05 2014 -0700 @@ -172,16 +172,6 @@ """ return '>'+('BB'*nbparams) -class BundleValueError(ValueError): - """error raised when bundle2 cannot be processed - - Current main usecase is unsupported part types.""" - pass - -class ReadOnlyPartError(RuntimeError): - """error raised when code tries to alter a part being generated""" - pass - parthandlermapping = {} def parthandler(parttype): @@ -309,7 +299,7 @@ if key != parttype: # mandatory parts # todo: # - use a more precise exception - raise BundleValueError(key) + raise error.BundleValueError(key) op.ui.debug('ignoring unknown advisory part %r\n' % key) # consuming the part part.read() @@ -589,7 +579,7 @@ # methods used to defines the part content def __setdata(self, data): if self._generated is not None: - raise ReadOnlyPartError('part is being generated') + raise error.ReadOnlyPartError('part is being generated') self._data = data def __getdata(self): return self._data @@ -607,7 +597,7 @@ def addparam(self, name, value='', mandatory=True): if self._generated is not None: - raise ReadOnlyPartError('part is being generated') + raise error.ReadOnlyPartError('part is being generated') if name in self._seenparams: raise ValueError('duplicated params: %s' % name) self._seenparams.add(name) @@ -841,7 +831,7 @@ @parthandler('b2x:error:unknownpart') def handlereplycaps(op, inpart): """Used to transmit unknown part error over the wire""" - raise BundleValueError(inpart.params['parttype']) + raise error.BundleValueError(inpart.params['parttype']) @parthandler('b2x:error:pushraced') def handlereplycaps(op, inpart):