~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/xml5.py

Merge from by-reference-trees

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
from bzrlib import (
21
21
    cache_utf8,
 
22
    errors,
22
23
    inventory,
23
24
    )
24
25
from bzrlib.xml_serializer import SubElement, Element, Serializer
148
149
    # This format supports the altered-by hack that reads file ids directly out
149
150
    # of the versionedfile, without doing XML parsing.
150
151
 
 
152
    supported_kinds = set(['file', 'directory', 'symlink'])
 
153
 
151
154
    def write_inventory_to_string(self, inv):
152
155
        """Just call write_inventory with a StringIO and return the value"""
153
156
        sio = cStringIO.StringIO()
190
193
    def _append_entry(self, append, ie):
191
194
        """Convert InventoryEntry to XML element and append to output."""
192
195
        # TODO: should just be a plain assertion
193
 
        assert InventoryEntry.versionable_kind(ie.kind), \
194
 
            'unsupported entry kind %s' % ie.kind
 
196
        if ie.kind not in self.supported_kinds:
 
197
            raise errors.UnsupportedInventoryKind(ie.kind)
195
198
 
196
199
        append("<")
197
200
        append(ie.kind)
217
220
            append('"')
218
221
        if ie.text_size is not None:
219
222
            append(' text_size="%d"' % ie.text_size)
 
223
        if getattr(ie, 'reference_revision', None) is not None:
 
224
            append(' reference_revision="')
 
225
            append(_encode_and_escape(ie.reference_revision))
220
226
        append(" />\n")
221
227
        return
222
228
 
330
336
                                         parent_id)
331
337
            ie.symlink_target = elt.get('symlink_target')
332
338
        else:
333
 
            raise BzrError("unknown kind %r" % kind)
 
339
            raise errors.UnsupportedInventoryKind(kind)
334
340
        revision = elt.get('revision')
335
341
        if revision is not None:
336
342
            revision = get_cached(revision)