/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/tree.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-12-04 00:42:43 UTC
  • mfrom: (3062.1.14 fast-plan-merge)
  • Revision ID: pqm@pqm.ubuntu.com-20071204004243-cgss0sl9yf0ayepc
Speed up annotate on packs

Show diffs side-by-side

added added

removed removed

Lines of Context:
299
299
        uncommitted changes in the other tree, they will be assigned to the
300
300
        'other:' pseudo-revision.
301
301
        """
302
 
        from bzrlib import merge
303
 
        annotated_a = list(self.annotate_iter(file_id,
304
 
                                              _mod_revision.CURRENT_REVISION))
305
 
        annotated_b = list(other.annotate_iter(file_id, 'other:'))
306
 
        ancestors_a = self._get_ancestors(_mod_revision.CURRENT_REVISION)
307
 
        ancestors_b = other._get_ancestors('other:')
308
 
        return merge._plan_annotate_merge(annotated_a, annotated_b,
309
 
                                          ancestors_a, ancestors_b)
 
302
        from bzrlib import merge, versionedfile
 
303
        vf = versionedfile._PlanMergeVersionedFile(file_id)
 
304
        last_revision_a = self._get_file_revision(file_id, vf, 'this:')
 
305
        last_revision_b = other._get_file_revision(file_id, vf, 'other:')
 
306
        return vf.plan_merge(last_revision_a, last_revision_b)
 
307
 
 
308
    def _get_file_revision(self, file_id, vf, tree_revision):
 
309
        def file_revision(revision_tree):
 
310
            revision_tree.lock_read()
 
311
            try:
 
312
                return revision_tree.inventory[file_id].revision
 
313
            finally:
 
314
                revision_tree.unlock()
 
315
 
 
316
        def iter_parent_trees():
 
317
            for revision_id in self.get_parent_ids():
 
318
                try:
 
319
                    yield self.revision_tree(revision_id)
 
320
                except:
 
321
                    yield self.repository.revision_tree(revision_id)
 
322
 
 
323
        if getattr(self, '_get_weave', None) is None:
 
324
            last_revision = tree_revision
 
325
            parent_revisions = [file_revision(t) for t in iter_parent_trees()]
 
326
            vf.add_lines(last_revision, parent_revisions,
 
327
                         self.get_file(file_id).readlines())
 
328
            repo = self.branch.repository
 
329
            transaction = repo.get_transaction()
 
330
            base_vf = repo.weave_store.get_weave(file_id, transaction)
 
331
        else:
 
332
            last_revision = file_revision(self)
 
333
            base_vf = self._get_weave(file_id)
 
334
        vf.fallback_versionedfiles.append(base_vf)
 
335
        return last_revision
310
336
 
311
337
    inventory = property(_get_inventory,
312
338
                         doc="Inventory of this Tree")