Rev 4552: Down to 2 failing tests. in http://bazaar.launchpad.net/~jameinel/bzr/1.18-bundle-and-stack-393349

John Arbash Meinel john at arbash-meinel.com
Wed Jul 22 22:47:07 BST 2009


At http://bazaar.launchpad.net/~jameinel/bzr/1.18-bundle-and-stack-393349

------------------------------------------------------------
revno: 4552
revision-id: john at arbash-meinel.com-20090722214659-el59kxhpghowg3aa
parent: john at arbash-meinel.com-20090722211249-jam6coxdb7jnm213
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 1.18-bundle-and-stack-393349
timestamp: Wed 2009-07-22 16:46:59 -0500
message:
  Down to 2 failing tests.
  
  Rather than using get_inventory_xml, switch to get_record_stream, but use a helper
  because otherwise it just looks crummy.
  The get_invalid_bundle code seems to be a bit fragile, we might consider doing it
  differently.
-------------- next part --------------
=== modified file 'bzrlib/bundle/serializer/v4.py'
--- a/bzrlib/bundle/serializer/v4.py	2009-07-22 21:12:49 +0000
+++ b/bzrlib/bundle/serializer/v4.py	2009-07-22 21:46:59 +0000
@@ -608,10 +608,22 @@
         for key, metadata, bytes in records:
             revision_id = key[-1]
             parent_ids = metadata['parents']
-            parents = [self._repository.get_inventory(p)
-                       for p in parent_ids]
+            # Note that this assumes the local ghosts are identical to the
+            # ghosts in the source. But the Bundle serialization format doesn't
+            # record any info that would help us figure that stuff out.
+            # We start by going directly to the inventory vf, because the
+            # revisions have not been installed yet
+            parent_keys = [(r,) for r in parent_ids]
+            present_parent_map = self._repository.inventories.get_parent_map(
+                                        parent_keys)
+            present_parent_ids = [p_id for p_id in parent_ids
+                                        if (p_id,) in present_parent_map]
+            # TODO: This doesn't do any sort of caching, etc, so expect it to
+            #       perform rather poorly.
+            parent_invs = list(self._repository.iter_inventories(
+                                present_parent_ids))
             p_texts = [self._source_serializer.write_inventory_to_string(p)
-                       for p in parents]
+                       for p in parent_invs]
             target_lines = multiparent.MultiParent.from_patch(bytes).to_lines(
                 p_texts)
             sha1 = osutils.sha_strings(target_lines)

=== modified file 'bzrlib/tests/test_bundle.py'
--- a/bzrlib/tests/test_bundle.py	2009-07-22 21:12:49 +0000
+++ b/bzrlib/tests/test_bundle.py	2009-07-22 21:46:59 +0000
@@ -50,6 +50,22 @@
 from bzrlib.transform import TreeTransform
 
 
+def get_text(vf, key):
+    """Get the fulltext for a given revision id that is present in the vf"""
+    stream = vf.get_record_stream([key], 'unordered', True)
+    record = stream.next()
+    return record.get_bytes_as('fulltext')
+
+
+def get_inventory_text(repo, revision_id):
+    """Get the fulltext for the inventory at revision id"""
+    repo.lock_read()
+    try:
+        return get_text(repo.inventories, (revision_id,))
+    finally:
+        repo.unlock()
+
+
 class MockTree(object):
     def __init__(self):
         from bzrlib.inventory import InventoryDirectory, ROOT_ID
@@ -647,9 +663,10 @@
                           verbose=False)
         bundle = self.get_valid_bundle('a at cset-0-5', 'a at cset-0-6')
         other = self.get_checkout('a at cset-0-5')
-        tree1_inv = self.tree1.branch.repository.get_inventory_xml(
-            'a at cset-0-5')
-        tree2_inv = other.branch.repository.get_inventory_xml('a at cset-0-5')
+        tree1_inv = get_inventory_text(self.tree1.branch.repository,
+                                       'a at cset-0-5')
+        tree2_inv = get_inventory_text(other.branch.repository,
+                                       'a at cset-0-5')
         self.assertEqualDiff(tree1_inv, tree2_inv)
         other.rename_one('sub/dir/nolastnewline.txt', 'sub/nolastnewline.txt')
         other.commit('rename file', rev_id='a at cset-0-6b')
@@ -1444,9 +1461,12 @@
         from bzrlib.bundle import serializer
         bundle_txt, rev_ids = self.create_bundle_text(base_rev_id, rev_id)
         new_text = self.get_raw(StringIO(''.join(bundle_txt)))
+        # We are going to be replacing some text to set the executable bit on a
+        # file. Make sure the text replacement actually works correctly.
+        self.assertContainsRe(new_text, '(?m)B281\n\ni 1\n<inventory')
         new_text = new_text.replace('<file file_id="exe-1"',
                                     '<file executable="y" file_id="exe-1"')
-        new_text = new_text.replace('B280', 'B295')
+        new_text = new_text.replace('B281', 'B296')
         bundle_txt = StringIO()
         bundle_txt.write(serializer._get_bundle_header('4'))
         bundle_txt.write('\n')



More information about the bazaar-commits mailing list