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

------------------------------------------------------------
revno: 3816
revision-id: [email protected]
parent: [email protected]
parent: [email protected]
committer: John Arbash Meinel <[email protected]>
branch nick: hack
timestamp: Tue 2008-12-23 15:20:37 -0600
message:
  Merge in the look-before-you-leap resolve conflicts.
modified:
  bzrlib/chk_map.py              chk_map.py-20081001014447-ue6kkuhofvdecvxa-1
    ------------------------------------------------------------
    revno: 3802.1.4
    revision-id: [email protected]
    parent: [email protected]
    committer: John Arbash Meinel <[email protected]>
    branch nick: look_before_you_leap
    timestamp: Tue 2008-12-23 11:40:50 -0600
    message:
      Change the code to check before adding the new lines to the store.
    modified:
      bzrlib/chk_map.py              
chk_map.py-20081001014447-ue6kkuhofvdecvxa-1
=== modified file 'bzrlib/chk_map.py'
--- a/bzrlib/chk_map.py 2008-12-23 17:02:14 +0000
+++ b/bzrlib/chk_map.py 2008-12-23 21:20:37 +0000
@@ -45,6 +45,7 @@
 lazy_import.lazy_import(globals(), """
 from bzrlib import versionedfile
 """)
+from bzrlib import osutils
 from bzrlib.lru_cache import LRUCache
 
 # approx 2MB
@@ -671,8 +672,12 @@
             serialized = "%s\x00%s\n" % (self._serialise_key(key), value)
             assert serialized.startswith(self._common_serialised_prefix)
             lines.append(serialized[prefix_len:])
-        sha1, _, _ = store.add_lines((None,), (), lines)
-        self._key = ("sha1:" + sha1,)
+        sha1 = osutils.sha_strings(lines)
+        key = ('sha1:' + sha1,)
+        if not store.has_key(key):
+            # We know the key doesn't exist, because we just checked
+            store.add_lines(key, (), lines, random_id=True)
+        self._key = key
         bytes = ''.join(lines)
         if len(bytes) != self._current_size():
             import pdb; pdb.set_trace()
@@ -980,8 +985,12 @@
             serialised = "%s\x00%s\n" % (prefix, key)
             assert serialised.startswith(self._lookup_prefix)
             lines.append(serialised[prefix_len:])
-        sha1, _, _ = store.add_lines((None,), (), lines)
-        self._key = ("sha1:" + sha1,)
+        sha1 = osutils.sha_strings(lines)
+        key = ('sha1:' + sha1,)
+        if not store.has_key(key):
+            # We know the key doesn't exist, because we just checked
+            store.add_lines(key, (), lines, random_id=True)
+        self._key = key
         _page_cache.add(self._key, ''.join(lines))
         yield self._key
 

-- 
bazaar-commits mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/bazaar-commits

Reply via email to