瀏覽代碼

Raise nicer exception in case of checksum mismatch.

Jelmer Vernooij 16 年之前
父節點
當前提交
91219a6b9e
共有 1 個文件被更改,包括 4 次插入1 次删除
  1. 4 1
      dulwich/pack.py

+ 4 - 1
dulwich/pack.py

@@ -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