~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/xml5.py

  • Committer: Aaron Bentley
  • Date: 2006-10-29 18:30:57 UTC
  • mto: (2255.6.1 dirstate)
  • mto: This revision was merged to the branch mainline in revision 2322.
  • Revision ID: aaron.bentley@utoronto.ca-20061029183057-af9d71b62956a668
Start roundtripping tree-reference entries

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
101
102
    # This format supports the altered-by hack that reads file ids directly out
102
103
    # of the versionedfile, without doing XML parsing.
103
104
 
 
105
    supported_kinds = set(['file', 'directory', 'symlink'])
 
106
 
104
107
    def write_inventory_to_string(self, inv):
105
108
        """Just call write_inventory with a StringIO and return the value"""
106
109
        sio = cStringIO.StringIO()
143
146
    def _append_entry(self, append, ie):
144
147
        """Convert InventoryEntry to XML element and append to output."""
145
148
        # TODO: should just be a plain assertion
146
 
        assert InventoryEntry.versionable_kind(ie.kind), \
147
 
            'unsupported entry kind %s' % ie.kind
 
149
        if ie.kind not in self.supported_kinds:
 
150
            raise errors.UnsupportedInventoryKind(ie.kind)
148
151
 
149
152
        append("<")
150
153
        append(ie.kind)
170
173
            append('"')
171
174
        if ie.text_size is not None:
172
175
            append(' text_size="%d"' % ie.text_size)
 
176
        if getattr(ie, 'reference_revision', None) is not None:
 
177
            append(' reference_revision="')
 
178
            append(_encode_and_escape(ie.reference_revision))
173
179
        append(" />\n")
174
180
        return
175
181
 
274
280
                                         parent_id)
275
281
            ie.symlink_target = elt.get('symlink_target')
276
282
        else:
277
 
            raise BzrError("unknown kind %r" % kind)
 
283
            raise errors.UnsupportedInventoryKind(kind)
278
284
        revision = elt.get('revision')
279
285
        if revision is not None:
280
286
            revision = get_cached(revision)