Mercurial > hg > mercurial-source
changeset 33379:19df975eb555
obsolete: raise richer exception on unknown version
We raise a more precise subclass of Abort with details about the faulty
version. This will be used to detect this case and display some information
in debugbundle.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 25 May 2017 16:50:23 +0200 |
parents | 9e46627baa3c |
children | 9df4c2613fca |
files | mercurial/error.py mercurial/obsolete.py |
diffstat | 2 files changed, 10 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/error.py +++ b/mercurial/error.py @@ -138,6 +138,14 @@ hint=_('see https://mercurial-scm.org/wiki/MergeStateRecords for ' 'more information')) +class UnknownVersion(Abort): + """generic exception for aborting from an encounter with an unknown version + """ + + def __init__(self, msg, hint=None, version=None): + self.version = version + super(UnknownVersion, self).__init__(msg, hint=hint) + class LockError(IOError): def __init__(self, errno, strerror, filename, desc): IOError.__init__(self, errno, strerror, filename)
--- a/mercurial/obsolete.py +++ b/mercurial/obsolete.py @@ -446,8 +446,8 @@ diskversion = _unpack('>B', data[off:off + 1])[0] off += 1 if diskversion not in formats: - raise error.Abort(_('parsing obsolete marker: unknown version %r') - % diskversion) + msg = _('parsing obsolete marker: unknown version %r') % diskversion + raise error.UnknownVersion(msg, version=diskversion) return diskversion, formats[diskversion][0](data, off) def encodemarkers(markers, addheader=False, version=_fm0version):