~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/xml5.py

[merge] bzr.dev 2298 (broken)

Show diffs side-by-side

added added

removed removed

Lines of Context:
275
275
        """
276
276
        assert elt.tag == 'inventory'
277
277
        root_id = elt.get('file_id') or ROOT_ID
 
278
        root_id = _get_utf8_or_ascii(root_id)
 
279
 
278
280
        format = elt.get('format')
279
281
        if format is not None:
280
282
            if format != '5':
286
288
        inv = Inventory(root_id, revision_id=revision_id)
287
289
        for e in elt:
288
290
            ie = self._unpack_entry(e)
289
 
            if ie.parent_id == ROOT_ID:
 
291
            if ie.parent_id is None:
290
292
                ie.parent_id = root_id
291
293
            inv.add(ie)
292
294
        return inv
293
295
 
294
 
    def _unpack_entry(self, elt, none_parents=False):
 
296
    def _unpack_entry(self, elt):
295
297
        kind = elt.tag
296
298
        if not InventoryEntry.versionable_kind(kind):
297
299
            raise AssertionError('unsupported entry kind %s' % kind)
299
301
        get_cached = _get_utf8_or_ascii
300
302
 
301
303
        parent_id = elt.get('parent_id')
302
 
        if parent_id is None and not none_parents:
303
 
            parent_id = ROOT_ID
304
 
        # TODO: jam 20060817 At present, caching file ids costs us too 
305
 
        #       much time. It slows down overall read performances from
306
 
        #       approx 500ms to 700ms. And doesn't improve future reads.
307
 
        #       it might be because revision ids and file ids are mixing.
308
 
        #       Consider caching *just* the file ids, for a limited period
309
 
        #       of time.
310
 
        #parent_id = get_cached(parent_id)
311
 
        #file_id = get_cached(elt.get('file_id'))
312
 
        file_id = elt.get('file_id')
 
304
        if parent_id is not None:
 
305
            parent_id = get_cached(parent_id)
 
306
        file_id = get_cached(elt.get('file_id'))
313
307
 
314
308
        if kind == 'directory':
315
309
            ie = inventory.InventoryDirectory(file_id,