~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/xml5.py

  • Committer: John Arbash Meinel
  • Date: 2007-02-09 17:15:56 UTC
  • mto: This revision was merged to the branch mainline in revision 2294.
  • Revision ID: john@arbash-meinel.com-20070209171556-sxv0wiwdubivwmnn
better comment for why we are decoding

Show diffs side-by-side

added added

removed removed

Lines of Context:
201
201
 
202
202
    def _pack_revision(self, rev):
203
203
        """Revision object -> xml tree"""
 
204
        # For the XML format, we need to write them as Unicode rather than as
 
205
        # utf-8 strings. So that cElementTree can handle properly escaping
 
206
        # them.
204
207
        decode_utf8 = cache_utf8.decode
 
208
        revision_id = rev.revision_id
 
209
        if isinstance(revision_id, str):
 
210
            revision_id = decode_utf8(revision_id)
205
211
        root = Element('revision',
206
212
                       committer = rev.committer,
207
213
                       timestamp = '%.3f' % rev.timestamp,
208
 
                       revision_id = decode_utf8(rev.revision_id),
 
214
                       revision_id = revision_id,
209
215
                       inventory_sha1 = rev.inventory_sha1,
210
216
                       format='5',
211
217
                       )
222
228
                assert isinstance(parent_id, basestring)
223
229
                p = SubElement(pelts, 'revision_ref')
224
230
                p.tail = '\n'
225
 
                p.set('revision_id', decode_utf8(parent_id))
 
231
                if isinstance(parent_id, str):
 
232
                    parent_id = decode_utf8(parent_id)
 
233
                p.set('revision_id', parent_id)
226
234
        if rev.properties:
227
235
            self._pack_revision_properties(rev, root)
228
236
        return root