~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/xml8.py

  • Committer: Vincent Ladeuil
  • Date: 2010-01-25 15:55:48 UTC
  • mto: (4985.1.4 add-attr-cleanup)
  • mto: This revision was merged to the branch mainline in revision 4988.
  • Revision ID: v.ladeuil+lp@free.fr-20100125155548-0l352pujvt5bzl5e
Deploy addAttrCleanup on the whole test suite.

Several use case worth mentioning:

- setting a module or any other object attribute is the majority
by far. In some cases the setting itself is deferred but most of
the time we want to set at the same time we add the cleanup.

- there multiple occurrences of protecting hooks or ui factory
which are now useless (the test framework takes care of that now),

- there was some lambda uses that can now be avoided.

That first cleanup already simplifies things a lot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
371
371
            prop_elt.tail = '\n'
372
372
        top_elt.tail = '\n'
373
373
 
374
 
    def _unpack_inventory(self, elt, revision_id=None, entry_cache=None):
 
374
    def _unpack_inventory(self, elt, revision_id=None, entry_cache=None,
 
375
                          return_from_cache=False):
375
376
        """Construct from XML Element"""
376
377
        if elt.tag != 'inventory':
377
378
            raise errors.UnexpectedInventoryFormat('Root tag is %r' % elt.tag)
384
385
            revision_id = cache_utf8.encode(revision_id)
385
386
        inv = inventory.Inventory(root_id=None, revision_id=revision_id)
386
387
        for e in elt:
387
 
            ie = self._unpack_entry(e, entry_cache=entry_cache)
 
388
            ie = self._unpack_entry(e, entry_cache=entry_cache,
 
389
                                    return_from_cache=return_from_cache)
388
390
            inv.add(ie)
389
391
        self._check_cache_size(len(inv), entry_cache)
390
392
        return inv
391
393
 
392
 
    def _unpack_entry(self, elt, entry_cache=None):
 
394
    def _unpack_entry(self, elt, entry_cache=None, return_from_cache=False):
393
395
        elt_get = elt.get
394
396
        file_id = elt_get('file_id')
395
397
        revision = elt_get('revision')
433
435
                pass
434
436
            else:
435
437
                # Only copying directory entries drops us 2.85s => 2.35s
436
 
                # if cached_ie.kind == 'directory':
437
 
                #     return cached_ie.copy()
438
 
                # return cached_ie
 
438
                if return_from_cache:
 
439
                    if cached_ie.kind == 'directory':
 
440
                        return cached_ie.copy()
 
441
                    return cached_ie
439
442
                return cached_ie.copy()
440
443
 
441
444
        kind = elt.tag