Rev 3906: (slightly broken) don't sha1 unless we will actually use it. in http://bzr.arbash-meinel.com/branches/bzr/brisbane/gc_delta_index_room

John Arbash Meinel john at arbash-meinel.com
Thu Mar 19 14:51:59 GMT 2009


At http://bzr.arbash-meinel.com/branches/bzr/brisbane/gc_delta_index_room

------------------------------------------------------------
revno: 3906
revision-id: john at arbash-meinel.com-20090319145150-743y6ek9rcfok2wn
parent: john at arbash-meinel.com-20090319145132-e7eu3p75btuidhu2
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: gc_delta_index_room
timestamp: Thu 2009-03-19 09:51:50 -0500
message:
  (slightly broken) don't sha1 unless we will actually use it.
-------------- next part --------------
=== modified file 'bzrlib/groupcompress.py'
--- a/bzrlib/groupcompress.py	2009-03-16 21:35:44 +0000
+++ b/bzrlib/groupcompress.py	2009-03-19 14:51:50 +0000
@@ -264,8 +264,8 @@
             bytes = content
         elif c == 'd':
             bytes = _groupcompress_pyx.apply_delta(self._content, content)
-        if entry.sha1 is None:
-            entry.sha1 = sha_string(bytes)
+        # if entry.sha1 is None:
+        #     entry.sha1 = sha_string(bytes)
         return entry, bytes
 
     def add_entry(self, key, type, sha1, start, length):
@@ -389,13 +389,18 @@
             the group output so far.
         :seealso VersionedFiles.add_lines:
         """
-        if not _FAST or expected_sha is None:
-            sha1 = sha_string(bytes)
-        else:
+        sha1 = None
+        # we assume someone knew what they were doing when they passed it in
+        if expected_sha is not None:
             sha1 = expected_sha
-        if sha1 == nostore_sha:
-            raise errors.ExistingContent()
+        if nostore_sha is not None:
+            if sha1 is None:
+                sha1 = osutils.sha_string(bytes)
+            if sha1 == nostore_sha:
+                raise errors.ExistingContent()
         if key[-1] is None:
+            if sha1 is None:
+                sha1 = osutils.sha_string(bytes)
             key = key[:-1] + ('sha1:' + sha1,)
         input_len = len(bytes)
         # By having action/label/sha1/len, we can parse the group if the index
@@ -910,10 +915,6 @@
                         block = self._get_block(index_memo)
                         entry, bytes = block.extract(key, index_memo)
                         sha1 = entry.sha1
-                        # TODO: If we don't have labels, then the sha1 here is computed
-                        #       from the data, so we don't want to re-sha the string.
-                        if not _FAST and sha_string(bytes) != sha1:
-                            raise AssertionError('sha1 sum did not match')
                     yield FulltextContentFactory(key, parents, sha1, bytes)
             else:
                 for record in source.get_record_stream(keys, ordering,



More information about the bazaar-commits mailing list