Rev 3826: Merge the lbyl code. in http://bzr.arbash-meinel.com/branches/bzr/brisbane/generic_fetch_ordering

John Arbash Meinel john at arbash-meinel.com
Wed Feb 18 19:07:13 GMT 2009


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

------------------------------------------------------------
revno: 3826
revision-id: john at arbash-meinel.com-20090218190659-bn7g7aaqqzn72q22
parent: john at arbash-meinel.com-20090218190640-8gg8c7fpxfarfhqi
parent: john at arbash-meinel.com-20090218180341-d7arrtdfuhfnm0yy
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: generic_fetch_ordering
timestamp: Wed 2009-02-18 13:06:59 -0600
message:
  Merge the lbyl code.
modified:
  bzrlib/chk_map.py              chk_map.py-20081001014447-ue6kkuhofvdecvxa-1
    ------------------------------------------------------------
    revno: 3822.1.2
    revision-id: john at arbash-meinel.com-20090218180341-d7arrtdfuhfnm0yy
    parent: john at arbash-meinel.com-20090218175014-4meosz28tb6ws5qf
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: look_before_you_leap
    timestamp: Wed 2009-02-18 12:03:41 -0600
    message:
      Add a TODO, something worth evaluating.
    modified:
      bzrlib/chk_map.py              chk_map.py-20081001014447-ue6kkuhofvdecvxa-1
    ------------------------------------------------------------
    revno: 3822.1.1
    revision-id: john at arbash-meinel.com-20090218175014-4meosz28tb6ws5qf
    parent: john at arbash-meinel.com-20090218163618-isb3yg01ygdx3m2n
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: look_before_you_leap
    timestamp: Wed 2009-02-18 11:50:14 -0600
    message:
      Change the chk_map.[Leaf|Internal]Node.serialize to check before insertion.
    modified:
      bzrlib/chk_map.py              chk_map.py-20081001014447-ue6kkuhofvdecvxa-1
-------------- next part --------------
=== modified file 'bzrlib/chk_map.py'
--- a/bzrlib/chk_map.py	2009-02-18 18:30:29 +0000
+++ b/bzrlib/chk_map.py	2009-02-18 19:06:59 +0000
@@ -57,6 +57,7 @@
 # out, it takes 3.1MB to cache the layer.
 _PAGE_CACHE_SIZE = 4*1024*1024
 # We are caching bytes so len(value) is perfectly accurate
+# TODO: Consider making this a cache of chunks, rather than bytes
 _page_cache = lru_cache.LRUSizeCache(_PAGE_CACHE_SIZE)
 
 
@@ -762,8 +763,11 @@
             assert serialized.startswith(self._common_serialised_prefix)
             lines.append(serialized[prefix_len:])
             lines.extend(value_lines)
-        sha1, _, _ = store.add_lines((None,), (), lines)
-        self._key = ("sha1:" + sha1,)
+        sha1 = osutils.sha_strings(lines)
+        key = ('sha1:' + sha1,)
+        if not store.has_key(key):
+            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()
@@ -1088,8 +1092,14 @@
             serialised = "%s\x00%s\n" % (prefix, key)
             assert serialised.startswith(self._search_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):
+            store.add_lines(key, (), lines, random_id=True)
+        # TODO: Do we want to add the bytes to the page cache if they aren't
+        #       new? Or should we only call _page_cache.add when we call
+        #       add_lines()?
+        self._key = key
         _page_cache.add(self._key, ''.join(lines))
         yield self._key
 



More information about the bazaar-commits mailing list