Rev 3816: Merge in the look-before-you-leap resolve conflicts. in http://bzr.arbash-meinel.com/branches/bzr/brisbane/hack

John Arbash Meinel john at arbash-meinel.com
Tue Dec 23 21:20:59 GMT 2008


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

------------------------------------------------------------
revno: 3816
revision-id: john at arbash-meinel.com-20081223212037-ntp3edz1rqg4wm6y
parent: john at arbash-meinel.com-20081223211826-lkia2y1fjvs6vsrx
parent: john at arbash-meinel.com-20081223174050-5s6el1nhg8mx63r3
committer: John Arbash Meinel <john at arbash-meinel.com>
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: john at arbash-meinel.com-20081223174050-5s6el1nhg8mx63r3
    parent: john at arbash-meinel.com-20081219230732-ri1i1tujtrh2d3sl
    committer: John Arbash Meinel <john at arbash-meinel.com>
    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
-------------- next part --------------
=== 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
 



More information about the bazaar-commits mailing list