/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: Lukáš Lalinský
  • Date: 2007-12-17 17:28:25 UTC
  • mfrom: (3120 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3123.
  • Revision ID: lalinsky@gmail.com-20071217172825-tr3pqm1mhvs3gwnn
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
277
277
        """
278
278
        raise NotImplementedError(self.get_symlink_target)
279
279
 
 
280
    def get_root_id(self):
 
281
        """Return the file_id for the root of this tree."""
 
282
        raise NotImplementedError(self.get_root_id)
 
283
 
280
284
    def annotate_iter(self, file_id):
281
285
        """Return an iterator of revision_id, line tuples.
282
286
 
295
299
        uncommitted changes in the other tree, they will be assigned to the
296
300
        'other:' pseudo-revision.
297
301
        """
298
 
        from bzrlib import merge
299
 
        annotated_a = list(self.annotate_iter(file_id,
300
 
                                              _mod_revision.CURRENT_REVISION))
301
 
        annotated_b = list(other.annotate_iter(file_id, 'other:'))
302
 
        ancestors_a = self._get_ancestors(_mod_revision.CURRENT_REVISION)
303
 
        ancestors_b = other._get_ancestors('other:')
304
 
        return merge._plan_annotate_merge(annotated_a, annotated_b,
305
 
                                          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
306
336
 
307
337
    inventory = property(_get_inventory,
308
338
                         doc="Inventory of this Tree")