/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-12-17 19:55:27 UTC
  • mfrom: (1551.9.21 Aaron's mergeable stuff)
  • Revision ID: pqm@pqm.ubuntu.com-20061217195527-29196a8633600671
Add Tree.annotate_iter

Show diffs side-by-side

added added

removed removed

Lines of Context:
102
102
from bzrlib.transport.local import LocalTransport
103
103
import bzrlib.tree
104
104
from bzrlib.progress import DummyProgress, ProgressPhase
105
 
from bzrlib.revision import NULL_REVISION
 
105
from bzrlib.revision import NULL_REVISION, CURRENT_REVISION
106
106
import bzrlib.revisiontree
107
107
from bzrlib.rio import RioReader, rio_file, Stanza
108
108
from bzrlib.symbol_versioning import (deprecated_passed,
468
468
    def get_file_byname(self, filename):
469
469
        return file(self.abspath(filename), 'rb')
470
470
 
 
471
    def annotate_iter(self, file_id):
 
472
        """See Tree.annotate_iter
 
473
 
 
474
        This implementation will use the basis tree implementation if possible.
 
475
        Lines not in the basis are attributed to CURRENT_REVISION
 
476
 
 
477
        If there are pending merges, lines added by those merges will be
 
478
        incorrectly attributed to CURRENT_REVISION (but after committing, the
 
479
        attribution will be correct).
 
480
        """
 
481
        basis = self.basis_tree()
 
482
        changes = self._iter_changes(basis, True, [file_id]).next()
 
483
        changed_content, kind = changes[2], changes[6]
 
484
        if not changed_content:
 
485
            return basis.annotate_iter(file_id)
 
486
        if kind[1] is None:
 
487
            return None
 
488
        import annotate
 
489
        if kind[0] != 'file':
 
490
            old_lines = []
 
491
        else:
 
492
            old_lines = list(basis.annotate_iter(file_id))
 
493
        old = [old_lines]
 
494
        for tree in self.branch.repository.revision_trees(
 
495
            self.get_parent_ids()[1:]):
 
496
            if file_id not in tree:
 
497
                continue
 
498
            old.append(list(tree.annotate_iter(file_id)))
 
499
        return annotate.reannotate(old, self.get_file(file_id).readlines(),
 
500
                                   CURRENT_REVISION)
 
501
 
471
502
    def get_parent_ids(self):
472
503
        """See Tree.get_parent_ids.
473
504