# Bazaar revision bundle v0.8 # # message: # Detect wrong eol markers. # # committer: Hermann Kraus # date: Mon 2006-08-07 01:06:44.392999887 +0200 === modified file bzrlib/bundle/serializer/__init__.py --- bzrlib/bundle/serializer/__init__.py +++ bzrlib/bundle/serializer/__init__.py @@ -27,8 +27,10 @@ # New bundles should try to use this header format BUNDLE_HEADER = '# Bazaar revision bundle v' -BUNDLE_HEADER_RE = re.compile(r'^# Bazaar revision bundle v(?P\d+[\w.]*)\n$') -CHANGESET_OLD_HEADER_RE = re.compile(r'^# Bazaar-NG changeset v(?P\d+[\w.]*)\n$') +BUNDLE_HEADER_RE = re.compile( + r'^# Bazaar revision bundle v(?P\d+[\w.]*)(?P\r?)\n$') +CHANGESET_OLD_HEADER_RE = re.compile( + r'^# Bazaar-NG changeset v(?P\d+[\w.]*)(?P\r?)\n$') _serializers = {} @@ -50,21 +52,26 @@ for line in f: m = BUNDLE_HEADER_RE.match(line) if m: + if m.group('lineending') != '': + raise errors.UnsupportedEOLMarker() version = m.group('version') break elif line.startswith(BUNDLE_HEADER): - raise errors.MalformedHeader() + raise errors.MalformedHeader( + 'Extra characters after version number') m = CHANGESET_OLD_HEADER_RE.match(line) if m: version = m.group('version') - raise errors.BundleNotSupported(version, 'old format bundles not supported') + raise errors.BundleNotSupported(version, + 'old format bundles not supported') if version is None: raise errors.NotABundle('Did not find an opening header') # Now we have a version, to figure out how to read the bundle if not _serializers.has_key(version): - raise errors.BundleNotSupported(version, 'version not listed in known versions') + raise errors.BundleNotSupported(version, + 'version not listed in known versions') serializer = _serializers[version](version) @@ -185,7 +192,8 @@ # parse it dot_loc = date.find('.') if dot_loc == -1: - raise ValueError('Date string does not contain high-precision seconds: %r' % date) + raise ValueError( + 'Date string does not contain high-precision seconds: %r' % date) base_time = time.strptime(date[:dot_loc], "%a %Y-%m-%d %H:%M:%S") fract_seconds, offset = date[dot_loc:].split() fract_seconds = float(fract_seconds) === modified file bzrlib/errors.py --- bzrlib/errors.py +++ bzrlib/errors.py @@ -1045,16 +1045,43 @@ """Not a bzr revision-bundle: %(text)r""" def __init__(self, text): - self.text = text - - -class BadBundle(Exception): pass - - -class MalformedHeader(BadBundle): pass - - -class MalformedPatches(BadBundle): pass - - -class MalformedFooter(BadBundle): pass + BzrNewError.__init__(self) + self.text = text + + +class BadBundle(BzrNewError): + """Bad bzr revision-bundle: %(text)r""" + + def __init__(self, text): + BzrNewError.__init__(self) + self.text = text + + +class MalformedHeader(BadBundle): + """Malformed bzr revision-bundle header: %(text)r""" + + def __init__(self, text): + BzrNewError.__init__(self) + self.text = text + + +class MalformedPatches(BadBundle): + """Malformed patches in bzr revision-bundle: %(text)r""" + + def __init__(self, text): + BzrNewError.__init__(self) + self.text = text + + +class MalformedFooter(BadBundle): + """Malformed footer in bzr revision-bundle: %(text)r""" + + def __init__(self, text): + BzrNewError.__init__(self) + self.text = text + +class UnsupportedEOLMarker(BadBundle): + """End of line marker was not \\n in bzr revision-bundle""" + + def __init__(self): + BzrNewError.__init__(self) # revision id: hermann@physiklaborant.de-20060806230644-2ed4719df86b8bd1 # sha1: 0c11ae17ccb1103e7e6bbf67037696cc4433409f # inventory sha1: 240f863498d4176a4ad8d1b16b4ea35b4c715d11 # parent ids: # hermann@physiklaborant.de-20060806155007-9d2d684d8f04c084 # base id: pqm@pqm.ubuntu.com-20060802020654-9d81db40bba14f69 # properties: # branch-nick: bzr.dev # message: # Convert bundle errors from Exception to BzrNewError. # # committer: Hermann Kraus # date: Sun 2006-08-06 17:50:07.993999958 +0200 === modified file bzrlib/bundle/serializer/__init__.py // encoding:base64 LS0tIGJ6cmxpYi9idW5kbGUvc2VyaWFsaXplci9fX2luaXRfXy5weQorKysgYnpybGliL2J1bmRs ZS9zZXJpYWxpemVyL19faW5pdF9fLnB5CkBAIC01MywxOCArNTMsMjEgQEAKICAgICAgICAgICAg IHZlcnNpb24gPSBtLmdyb3VwKCd2ZXJzaW9uJykKICAgICAgICAgICAgIGJyZWFrCiAgICAgICAg IGVsaWYgbGluZS5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gICAgICAgICAgICAndmVyc2lv biBub3QgbGlzdGVkIGluIGtub3duIHZlcnNpb25zJykKIAogICAgIHNlcmlhbGl6ZXIgPSBfc2Vy aWFsaXplcnNbdmVyc2lvbl0odmVyc2lvbikKIApAQCAtMTg1LDcgKzE4OCw4IEBACiAgICAgIyBw YXJzZSBpdAogICAgIGRvdF9sb2MgPSBkYXRlLmZpbmQoJy4nKQogICAgIGlmIGRvdF9sb2MgPT0g LTE6Ci0gICAgICAgIHJhaXNlIFZhbHVlRXJyb3IoJ0RhdGUgc3RyaW5nIGRvZXMgbm90IGNvbnRh aW4gaGlnaC1wcmVjaXNpb24gc2Vjb25kczogJXInICUgZGF0ZSkKKyAgICAgICAgcmFpc2UgVmFs dWVFcnJvcigKKyAgICAgICAgICAgICdEYXRlIHN0cmluZyBkb2VzIG5vdCBjb250YWluIGhpZ2gt cHJlY2lzaW9uIHNlY29uZHM6ICVyJyAlIGRhdGUpCiAgICAgYmFzZV90aW1lID0gdGltZS5zdHJw dGltZShkYXRlWzpkb3RfbG9jXSwgIiVhICVZLSVtLSVkICVIOiVNOiVTIikKICAgICBmcmFjdF9z ZWNvbmRzLCBvZmZzZXQgPSBkYXRlW2RvdF9sb2M6XS5zcGxpdCgpCiAgICAgZnJhY3Rfc2Vjb25k cyA9IGZsb2F0KGZyYWN0X3NlY29uZHMpCgo= === modified file bzrlib/errors.py // encoding:base64 LS0tIGJ6cmxpYi9lcnJvcnMucHkKKysrIGJ6cmxpYi9lcnJvcnMucHkKQEAgLTEwNDUsMTYgKzEw NDUsMzcgQEAKICAgICAiIiJOb3QgYSBienIgcmV2aXNpb24tYnVuZGxlOiAlKHRleHQpciIiIgog CiAgICAgZGVmIF9faW5pdF9fKHNlbGYsIHRleHQpOgotICAgICAgICBzZWxmLnRleHQgPSB0ZXh0 Ci0KLQotY2xhc3MgQmFkQnVuZGxlKEV4Y2VwdGlvbik6IHBhc3MKLQotCi1jbGFzcyBNYWxmb3Jt ZWRIZWFkZXIoQmFk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RleHQpciIiIgorCisgICAgZGVm IF9faW5pdF9fKHNlbGYsIHRleHQpOgorICAgICAgICBCenJOZXdFcnJvci5fX2luaXRfXyhzZWxm KQorICAgICAgICBzZWxmLnRleHQgPSB0ZXh0ClwgTm8gbmV3bGluZSBhdCBlbmQgb2YgZmlsZQoK # revision id: hermann@physiklaborant.de-20060806155007-9d2d684d8f04c084 # sha1: 7c4d0a5670af70eda566c035eccef43671fa5325 # inventory sha1: e89dc397058d9aeaed4c9e3d5da5ba4d6e944370 # parent ids: # pqm@pqm.ubuntu.com-20060802020654-9d81db40bba14f69 # properties: # branch-nick: bzr.dev