/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/xml5.py

  • Committer: Daniel Watkins
  • Date: 2007-11-06 09:33:05 UTC
  • mfrom: (2967 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2993.
  • Revision ID: d.m.watkins@warwick.ac.uk-20071106093305-zfef3c0jbcvunnuz
Merged bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
154
154
    supported_kinds = set(['file', 'directory', 'symlink'])
155
155
    format_num = '5'
156
156
 
 
157
    def _check_revisions(self, inv):
 
158
        """Extension point for subclasses to check during serialisation.
 
159
 
 
160
        By default no checking is done.
 
161
 
 
162
        :param inv: An inventory about to be serialised, to be checked.
 
163
        :raises: AssertionError if an error has occured.
 
164
        """
 
165
 
157
166
    def write_inventory_to_lines(self, inv):
158
167
        """Return a list of lines with the encoded inventory."""
159
168
        return self.write_inventory(inv, None)
179
188
        :return: The inventory as a list of lines.
180
189
        """
181
190
        _ensure_utf8_re()
 
191
        self._check_revisions(inv)
182
192
        output = []
183
193
        append = output.append
184
194
        self._append_inventory_root(append, inv)
326
336
            prop_elt.tail = '\n'
327
337
        top_elt.tail = '\n'
328
338
 
329
 
    def _unpack_inventory(self, elt):
 
339
    def _unpack_inventory(self, elt, revision_id):
330
340
        """Construct from XML Element
331
341
        """
332
342
        assert elt.tag == 'inventory'
338
348
            if format != '5':
339
349
                raise BzrError("invalid format version %r on inventory"
340
350
                                % format)
341
 
        revision_id = elt.get('revision_id')
342
 
        if revision_id is not None:
343
 
            revision_id = cache_utf8.encode(revision_id)
 
351
        data_revision_id = elt.get('revision_id')
 
352
        if data_revision_id is not None:
 
353
            revision_id = cache_utf8.encode(data_revision_id)
344
354
        inv = Inventory(root_id, revision_id=revision_id)
345
355
        for e in elt:
346
356
            ie = self._unpack_entry(e)
347
357
            if ie.parent_id is None:
348
358
                ie.parent_id = root_id
349
359
            inv.add(ie)
 
360
        if revision_id is not None:
 
361
            inv.root.revision = revision_id
350
362
        return inv
351
363
 
352
364
    def _unpack_entry(self, elt):