~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/xml8.py

  • Committer: Robert J. Tanner
  • Date: 2009-06-10 03:56:49 UTC
  • mfrom: (4423 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4425.
  • Revision ID: tanner@real-time.com-20090610035649-7rfx4cls4550zc3c
Merge 1.15.1 back to trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
    Element,
29
29
    SubElement,
30
30
    XMLSerializer,
31
 
    escape_invalid_chars,
32
31
    )
33
32
from bzrlib.inventory import ROOT_ID, Inventory, InventoryEntry
34
33
from bzrlib.revision import Revision
168
167
        :raises: AssertionError if an error has occurred.
169
168
        """
170
169
        if inv.revision_id is None:
171
 
            raise AssertionError("inv.revision_id is None")
 
170
            raise AssertionError()
172
171
        if inv.root.revision is None:
173
 
            raise AssertionError("inv.root.revision is None")
 
172
            raise AssertionError()
174
173
 
175
174
    def _check_cache_size(self, inv_size, entry_cache):
176
175
        """Check that the entry_cache is large enough.
346
345
            root.set('timezone', str(rev.timezone))
347
346
        root.text = '\n'
348
347
        msg = SubElement(root, 'message')
349
 
        msg.text = escape_invalid_chars(rev.message)[0]
 
348
        msg.text = rev.message
350
349
        msg.tail = '\n'
351
350
        if rev.parent_ids:
352
351
            pelts = SubElement(root, 'parents')
371
370
            prop_elt.tail = '\n'
372
371
        top_elt.tail = '\n'
373
372
 
374
 
    def _unpack_inventory(self, elt, revision_id=None, entry_cache=None,
375
 
                          return_from_cache=False):
 
373
    def _unpack_inventory(self, elt, revision_id=None, entry_cache=None):
376
374
        """Construct from XML Element"""
377
375
        if elt.tag != 'inventory':
378
376
            raise errors.UnexpectedInventoryFormat('Root tag is %r' % elt.tag)
385
383
            revision_id = cache_utf8.encode(revision_id)
386
384
        inv = inventory.Inventory(root_id=None, revision_id=revision_id)
387
385
        for e in elt:
388
 
            ie = self._unpack_entry(e, entry_cache=entry_cache,
389
 
                                    return_from_cache=return_from_cache)
 
386
            ie = self._unpack_entry(e, entry_cache=entry_cache)
390
387
            inv.add(ie)
391
388
        self._check_cache_size(len(inv), entry_cache)
392
389
        return inv
393
390
 
394
 
    def _unpack_entry(self, elt, entry_cache=None, return_from_cache=False):
 
391
    def _unpack_entry(self, elt, entry_cache=None):
395
392
        elt_get = elt.get
396
393
        file_id = elt_get('file_id')
397
394
        revision = elt_get('revision')
435
432
                pass
436
433
            else:
437
434
                # Only copying directory entries drops us 2.85s => 2.35s
438
 
                if return_from_cache:
439
 
                    if cached_ie.kind == 'directory':
440
 
                        return cached_ie.copy()
441
 
                    return cached_ie
 
435
                # if cached_ie.kind == 'directory':
 
436
                #     return cached_ie.copy()
 
437
                # return cached_ie
442
438
                return cached_ie.copy()
443
439
 
444
440
        kind = elt.tag