Raise nicer exception in case of checksum mismatch.
authorJelmer Vernooij <jelmer@samba.org>
Mon, 9 Mar 2009 18:12:18 +0000 (18:12 +0000)
committerJelmer Vernooij <jelmer@samba.org>
Mon, 9 Mar 2009 18:12:18 +0000 (18:12 +0000)
dulwich/pack.py

index 533ea531440dbd0a9d4726a35cd9934a35fa8910..fda8874ddd0227b18ac4e103929dc6ea581f74d9 100644 (file)
@@ -818,7 +818,10 @@ class Pack(object):
         if self._data is None:
             self._data = PackData(self._data_path)
             assert len(self.idx) == len(self._data)
-            assert self.idx.get_stored_checksums()[0] == self._data.get_stored_checksum()
+            idx_stored_checksum = self.idx.get_stored_checksums()[0]
+            data_stored_checksum = self._data.get_stored_checksum()
+            if idx_stored_checksum != data_stored_checksum:
+                raise AssertionError("Checksum for index does not match checksum for pack: %s != %s" % (sha_to_hex(idx_stored_checksum), sha_to_hex(data_stored_checksum)))
         return self._data
 
     @property