Rev 22: Add support for the new chk hash formats. in http://bazaar.launchpad.net/%7Ebzr/bzr-repodetails/trunk

John Arbash Meinel john at arbash-meinel.com
Thu Feb 12 20:27:44 GMT 2009


At http://bazaar.launchpad.net/%7Ebzr/bzr-repodetails/trunk

------------------------------------------------------------
revno: 22
revision-id: john at arbash-meinel.com-20090212202705-rcemxbllzpf30obk
parent: robertc at robertcollins.net-20090210053525-kyvoo33bzx1dk12t
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: trunk
timestamp: Thu 2009-02-12 14:27:05 -0600
message:
  Add support for the new chk hash formats.
-------------- next part --------------
=== modified file 'gather_stats.py'
--- a/gather_stats.py	2009-02-10 05:35:25 +0000
+++ b/gather_stats.py	2009-02-12 20:27:05 +0000
@@ -41,6 +41,16 @@
     chk_support = True
 except ImportError:
     chk_support = False
+    chk_hash_support = False
+else:
+    try:
+        from bzrlib.repofmt.pack_repo import (
+            RepositoryFormatPackDevelopment4Hash16,
+            RepositoryFormatPackDevelopment4Hash255,
+            )
+        chk_hash_support = True
+    except:
+        chk_hash_support = False
 try:
     from bzrlib.plugins.groupcompress.groupcompress import GroupCompressVersionedFiles
     gc_support = True
@@ -126,6 +136,23 @@
         RepositoryFormatPackDevelopment4,
         RepositoryFormatPackDevelopment4Subtree,
         )
+if chk_hash_support:
+    pack_rev_types = pack_rev_types + (
+        RepositoryFormatPackDevelopment4Hash16,
+        RepositoryFormatPackDevelopment4Hash255,
+        )
+    pack_signature_types = pack_signature_types + (
+        RepositoryFormatPackDevelopment4Hash16,
+        RepositoryFormatPackDevelopment4Hash255,
+        )
+    pack_text_types = pack_text_types + (
+        RepositoryFormatPackDevelopment4Hash16,
+        RepositoryFormatPackDevelopment4Hash255,
+        )
+    pack_chk_inv_types = pack_chk_inv_types + (
+        RepositoryFormatPackDevelopment4Hash16,
+        RepositoryFormatPackDevelopment4Hash255,
+        )
 
 
 class ObjectStats(object):
@@ -245,7 +272,7 @@
 
 
 def _gather_chk_map(objectstats, chk_bytes, pending, internal_counter,
-                    leaf_counter, depth_counter, name):
+                    leaf_counter, depth_counter, name, search_key_func):
     done = set()
     depth = 0
     while pending:
@@ -257,7 +284,10 @@
         kind = '%s %d' % (name, depth,)
         for bytes, key in _gather_and_iter_object_vf_texts(objectstats,
                             chk_bytes, next, kind=kind):
-            node = chk_map._deserialise(bytes, key)
+            if search_key_func is None: # Non-hash trie bzrlib
+                node = chk_map._deserialise(bytes, key)
+            else:
+                node = chk_map._deserialise(bytes, key, search_key_func)
             refs = node.refs()
             pending.update(refs)
             if isinstance(node, chk_map.InternalNode):
@@ -281,12 +311,17 @@
         pending.add(inv.id_to_entry._root_node)
         if inv.parent_id_basename_to_file_id is not None:
             pending_parent_id.add(inv.parent_id_basename_to_file_id._root_node)
+    if chk_hash_support:
+        search_key_name = repo._serializer.search_key_name
+        search_key_func = chk_map.search_key_registry.get(search_key_name)
+    else:
+        search_key_func = None
     _gather_chk_map(objectstats, repo.chk_bytes, pending,
                     'internal node refs', 'leaf node items', 'inv depth',
-                    'chk inv')
+                    'chk inv', search_key_func)
     _gather_chk_map(objectstats, repo.chk_bytes, pending_parent_id,
                     'internal p_id refs', 'leaf p_id items', 'p_id depth',
-                    'chk p_id')
+                    'chk p_id', search_key_func)
 
 
 def _gather_stats_locked(repo):



More information about the bazaar-commits mailing list