Rev 4623: (robertc) Support iter_inventory_xml on CHKRepository. (Robert in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Tue Aug 18 04:42:54 BST 2009


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 4623 [merge]
revision-id: pqm at pqm.ubuntu.com-20090818034251-w2biu3woo8y7bcf8
parent: pqm at pqm.ubuntu.com-20090818013856-vezgd3arfawq9x2l
parent: robertc at robertcollins.net-20090818021938-l32d8whr7tjuqjoh
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Tue 2009-08-18 04:42:51 +0100
message:
  (robertc) Support iter_inventory_xml on CHKRepository. (Robert
  	Collins)
modified:
  bzrlib/repofmt/groupcompress_repo.py repofmt.py-20080715094215-wp1qfvoo7093c8qr-1
  bzrlib/workingtree.py          workingtree.py-20050511021032-29b6ec0a681e02e3
=== modified file 'bzrlib/repofmt/groupcompress_repo.py'
--- a/bzrlib/repofmt/groupcompress_repo.py	2009-08-14 09:37:57 +0000
+++ b/bzrlib/repofmt/groupcompress_repo.py	2009-08-18 02:19:38 +0000
@@ -810,9 +810,15 @@
             yield inventory.CHKInventory.deserialise(self.chk_bytes, texts[key], key)
 
     def _iter_inventory_xmls(self, revision_ids, ordering):
-        # Without a native 'xml' inventory, this method doesn't make sense, so
-        # make it raise to trap naughty direct users.
-        raise NotImplementedError(self._iter_inventory_xmls)
+        # Without a native 'xml' inventory, this method doesn't make sense.
+        # However older working trees, and older bundles want it - so we supply
+        # it allowing get_inventory_xml to work. Bundles currently use the
+        # serializer directly; this also isn't ideal, but there isn't an xml
+        # iteration interface offered at all for repositories. We could make
+        # _iter_inventory_xmls be part of the contract, even if kept private.
+        inv_to_str = self._serializer.write_inventory_to_string
+        for inv in self.iter_inventories(revision_ids, ordering=ordering):
+            yield inv_to_str(inv), inv.revision_id
 
     def _find_present_inventory_keys(self, revision_keys):
         parent_map = self.inventories.get_parent_map(revision_keys)

=== modified file 'bzrlib/workingtree.py'
--- a/bzrlib/workingtree.py	2009-08-04 04:36:34 +0000
+++ b/bzrlib/workingtree.py	2009-08-14 02:35:01 +0000
@@ -1893,8 +1893,8 @@
             firstline = xml.split('\n', 1)[0]
             if (not 'revision_id="' in firstline or
                 'format="7"' not in firstline):
-                inv = self.branch.repository.deserialise_inventory(
-                    new_revision, xml)
+                inv = self.branch.repository._serializer.read_inventory_from_string(
+                    xml, new_revision)
                 xml = self._create_basis_xml_from_inventory(new_revision, inv)
             self._write_basis_inventory(xml)
         except (errors.NoSuchRevision, errors.RevisionNotPresent):




More information about the bazaar-commits mailing list