~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tree.py

  • Committer: Jelmer Vernooij
  • Date: 2011-04-17 23:06:22 UTC
  • mto: This revision was merged to the branch mainline in revision 5803.
  • Revision ID: jelmer@samba.org-20110417230622-e52xsel9m0t0umcf
Add a RevisionTree.get_file_revision() method.

Show diffs side-by-side

added added

removed removed

Lines of Context:
433
433
            except errors.NoSuchRevisionInTree:
434
434
                yield self.repository.revision_tree(revision_id)
435
435
 
436
 
    @staticmethod
437
 
    def _file_revision(revision_tree, file_id):
438
 
        """Determine the revision associated with a file in a given tree."""
439
 
        # FIXME: Shouldn't this be a RevisionTree method?
440
 
        revision_tree.lock_read()
441
 
        try:
442
 
            return revision_tree.inventory[file_id].revision
443
 
        finally:
444
 
            revision_tree.unlock()
445
 
 
446
436
    def _get_file_revision(self, file_id, vf, tree_revision):
447
437
        """Ensure that file_id, tree_revision is in vf to plan the merge."""
448
438
 
449
439
        if getattr(self, '_repository', None) is None:
450
440
            last_revision = tree_revision
451
 
            parent_keys = [(file_id, self._file_revision(t, file_id)) for t in
 
441
            parent_keys = [(file_id, t.get_file_revision(file_id)) for t in
452
442
                self._iter_parent_trees()]
453
443
            vf.add_lines((file_id, last_revision), parent_keys,
454
444
                         self.get_file_lines(file_id))
455
445
            repo = self.branch.repository
456
446
            base_vf = repo.texts
457
447
        else:
458
 
            last_revision = self._file_revision(self, file_id)
 
448
            last_revision = self.get_file_revision(file_id)
459
449
            base_vf = self._repository.texts
460
450
        if base_vf not in vf.fallback_versionedfiles:
461
451
            vf.fallback_versionedfiles.append(base_vf)