~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tree.py

Merge with list_files

Show diffs side-by-side

added added

removed removed

Lines of Context:
373
373
        return vf.plan_lca_merge(last_revision_a, last_revision_b,
374
374
                                 last_revision_base)
375
375
 
 
376
    def _iter_parent_trees(self):
 
377
        """Iterate through parent trees, defaulting to Tree.revision_tree."""
 
378
        for revision_id in self.get_parent_ids():
 
379
            try:
 
380
                yield self.revision_tree(revision_id)
 
381
            except errors.NoSuchRevisionInTree:
 
382
                yield self.repository.revision_tree(revision_id)
 
383
 
 
384
    @staticmethod
 
385
    def _file_revision(revision_tree, file_id):
 
386
        """Determine the revision associated with a file in a given tree."""
 
387
        revision_tree.lock_read()
 
388
        try:
 
389
            return revision_tree.inventory[file_id].revision
 
390
        finally:
 
391
            revision_tree.unlock()
 
392
 
376
393
    def _get_file_revision(self, file_id, vf, tree_revision):
377
394
        """Ensure that file_id, tree_revision is in vf to plan the merge."""
378
 
        def file_revision(revision_tree):
379
 
            revision_tree.lock_read()
380
 
            try:
381
 
                return revision_tree.inventory[file_id].revision
382
 
            finally:
383
 
                revision_tree.unlock()
384
 
 
385
 
        def iter_parent_trees():
386
 
            for revision_id in self.get_parent_ids():
387
 
                try:
388
 
                    yield self.revision_tree(revision_id)
389
 
                except:
390
 
                    yield self.repository.revision_tree(revision_id)
391
395
 
392
396
        if getattr(self, '_repository', None) is None:
393
397
            last_revision = tree_revision
394
 
            parent_keys = [(file_id, file_revision(t)) for t in
395
 
                iter_parent_trees()]
 
398
            parent_keys = [(file_id, self._file_revision(t, file_id)) for t in
 
399
                self._iter_parent_trees()]
396
400
            vf.add_lines((file_id, last_revision), parent_keys,
397
401
                         self.get_file(file_id).readlines())
398
402
            repo = self.branch.repository
399
403
            base_vf = repo.texts
400
404
        else:
401
 
            last_revision = file_revision(self)
 
405
            last_revision = self._file_revision(self, file_id)
402
406
            base_vf = self._repository.texts
403
407
        if base_vf not in vf.fallback_versionedfiles:
404
408
            vf.fallback_versionedfiles.append(base_vf)