Rev 2912: Better messages when problems are detected inside a knit in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Wed Oct 17 06:20:33 BST 2007


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 2912
revision-id: pqm at pqm.ubuntu.com-20071017052031-xesht1ei7y0nn2ea
parent: pqm at pqm.ubuntu.com-20071016112750-1q8brfaq6metpfn8
parent: mbp at sourcefrog.net-20071017044140-goj9t2oul3r4y0dd
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2007-10-17 06:20:31 +0100
message:
  Better messages when problems are detected inside a knit
modified:
  bzrlib/knit.py                 knit.py-20051212171256-f056ac8f0fbe1bd9
    ------------------------------------------------------------
    revno: 2911.1.1
    merged: mbp at sourcefrog.net-20071017044140-goj9t2oul3r4y0dd
    parent: pqm at pqm.ubuntu.com-20071016112750-1q8brfaq6metpfn8
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: knit-exceptions
    timestamp: Wed 2007-10-17 14:41:40 +1000
    message:
      Better messages when problems are detected inside a knit
=== modified file 'bzrlib/knit.py'
--- a/bzrlib/knit.py	2007-10-12 05:26:46 +0000
+++ b/bzrlib/knit.py	2007-10-17 04:41:40 +0000
@@ -194,7 +194,15 @@
         self._lines[-1] = (self._lines[-1][0], line)
 
     def text(self):
-        return [text for origin, text in self._lines]
+        try:
+            return [text for origin, text in self._lines]
+        except ValueError, e:
+            # most commonly (only?) caused by the internal form of the knit
+            # missing annotation information because of a bug - see thread
+            # around 20071015
+            raise KnitCorrupt(self,
+                "line in annotated knit missing annotation information: %s"
+                % (e,))
 
     def copy(self):
         return AnnotatedKnitContent(self._lines[:])
@@ -265,7 +273,7 @@
         (start, end, count, [1..count tuples (revid, newline)])
 
         :param plain: If True, the lines are returned as a plain
-            list, not as a list of tuples, i.e.
+            list without annotations, not as a list of (origin, content) tuples, i.e.
             (start, end, count, [1..count newline])
         """
         result = []
@@ -1033,10 +1041,14 @@
 
             # digest here is the digest from the last applied component.
             text = content.text()
-            if sha_strings(text) != digest:
+            actual_sha = sha_strings(text)
+            if actual_sha != digest:
                 raise KnitCorrupt(self.filename,
-                                  'sha-1 does not match %s' % version_id)
-
+                    '\n  sha-1 %s'
+                    '\n  of reconstructed text does not match'
+                    '\n  expected %s'
+                    '\n  for version %s' %
+                    (actual_sha, digest, version_id))
             text_map[version_id] = text
         return text_map, final_content
 




More information about the bazaar-commits mailing list