~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/xml_serializer.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-12-19 17:14:59 UTC
  • mfrom: (3882.6.23 xml_cache)
  • Revision ID: pqm@pqm.ubuntu.com-20081219171459-521qbou7ho7g297f
(jam) Add a cache for deserializing inventory entries from XML.

Show diffs side-by-side

added added

removed removed

Lines of Context:
59
59
    def write_inventory_to_string(self, inv):
60
60
        raise NotImplementedError(self.write_inventory_to_string)
61
61
 
62
 
    def read_inventory_from_string(self, xml_string, revision_id=None):
 
62
    def read_inventory_from_string(self, xml_string, revision_id=None,
 
63
                                   entry_cache=None):
63
64
        """Read xml_string into an inventory object.
64
65
 
65
66
        :param xml_string: The xml to read.
70
71
            serialised without a revision identifier can be given the right
71
72
            revision id (but not for working tree inventories where users can
72
73
            edit the data without triggering checksum errors or anything).
 
74
        :param entry_cache: An optional cache of InventoryEntry objects. If
 
75
            supplied we will look up entries via (file_id, revision_id) which
 
76
            should map to a valid InventoryEntry (File/Directory/etc) object.
73
77
        """
74
78
        try:
75
 
            return self._unpack_inventory(fromstring(xml_string), revision_id)
 
79
            return self._unpack_inventory(fromstring(xml_string), revision_id,
 
80
                                          entry_cache=entry_cache)
76
81
        except ParseError, e:
77
82
            raise errors.UnexpectedInventoryFormat(e)
78
83