Rev 5954: (jr) Display error when zlib corruption occurs rather than a backtrace in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Thu Jun 2 16:57:13 UTC 2011
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 5954 [merge]
revision-id: pqm at pqm.ubuntu.com-20110602165709-ry228rc95pgnj3g9
parent: pqm at pqm.ubuntu.com-20110602100856-l5yozjq1kir6qw44
parent: jriddell at canonical.com-20110602081147-r13j784jul5s302h
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2011-06-02 16:57:09 +0000
message:
(jr) Display error when zlib corruption occurs rather than a backtrace
(Jonathan Riddell)
modified:
bzrlib/errors.py errors.py-20050309040759-20512168c4e14fbd
bzrlib/groupcompress.py groupcompress.py-20080705181503-ccbxd6xuy1bdnrpu-8
bzrlib/tests/blackbox/test_branch.py test_branch.py-20060524161337-noms9gmcwqqrfi8y-1
=== modified file 'bzrlib/errors.py'
--- a/bzrlib/errors.py 2011-06-01 13:43:12 +0000
+++ b/bzrlib/errors.py 2011-06-02 16:57:09 +0000
@@ -3081,6 +3081,18 @@
_fmt = "Shelf corrupt."
+class DecompressCorruption(BzrError):
+
+ _fmt = "Corruption while decompressing repository file%(orig_error)s"
+
+ def __init__(self, orig_error=None):
+ if orig_error is not None:
+ self.orig_error = ", %s" % (orig_error,)
+ else:
+ self.orig_error = ""
+ BzrError.__init__(self)
+
+
class NoSuchShelfId(BzrError):
_fmt = 'No changes are shelved with id "%(shelf_id)d".'
=== modified file 'bzrlib/groupcompress.py'
--- a/bzrlib/groupcompress.py 2011-05-18 16:42:48 +0000
+++ b/bzrlib/groupcompress.py 2011-05-31 13:52:18 +0000
@@ -466,7 +466,10 @@
# Grab and cache the raw bytes for this entry
# and break the ref-cycle with _manager since we don't need it
# anymore
- self._manager._prepare_for_extract()
+ try:
+ self._manager._prepare_for_extract()
+ except zlib.error as value:
+ raise errors.DecompressCorruption("zlib: " + str(value))
block = self._manager._block
self._bytes = block.extract(self.key, self._start, self._end)
# There are code paths that first extract as fulltext, and then
=== modified file 'bzrlib/tests/blackbox/test_branch.py'
--- a/bzrlib/tests/blackbox/test_branch.py 2011-05-13 12:51:05 +0000
+++ b/bzrlib/tests/blackbox/test_branch.py 2011-06-02 08:11:47 +0000
@@ -61,6 +61,17 @@
self.assertFalse(b._transport.has('branch-name'))
b.bzrdir.open_workingtree().commit(message='foo', allow_pointless=True)
+ def test_branch_broken_pack(self):
+ """branching with a corrupted pack file."""
+ self.example_branch('a')
+ #now add some random corruption
+ fname = 'a/.bzr/repository/packs/' + os.listdir('a/.bzr/repository/packs')[0]
+ with open(fname, 'rb+') as f:
+ f.seek(750)
+ f.write("\xff")
+ self.run_bzr_error(['Corruption while decompressing repository file'],
+ 'branch a b', retcode=3)
+
def test_branch_switch_no_branch(self):
# No branch in the current directory:
# => new branch will be created, but switch fails
More information about the bazaar-commits
mailing list