~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repository.py

  • Committer: Aaron Bentley
  • Date: 2006-06-25 21:32:29 UTC
  • mfrom: (1811 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1813.
  • Revision ID: aaron.bentley@utoronto.ca-20060625213229-b75551f64a4acf69
merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
331
331
        self._check_revision_parents(r, inv)
332
332
        return r
333
333
 
 
334
    @needs_read_lock
 
335
    def get_deltas_for_revisions(self, revisions):
 
336
        """Produce a generator of revision deltas.
 
337
        
 
338
        Note that the input is a sequence of REVISIONS, not revision_ids.
 
339
        Trees will be held in memory until the generator exits.
 
340
        Each delta is relative to the revision's lefthand predecessor.
 
341
        """
 
342
        required_trees = set()
 
343
        for revision in revisions:
 
344
            required_trees.add(revision.revision_id)
 
345
            required_trees.update(revision.parent_ids[:1])
 
346
        trees = dict((t.get_revision_id(), t) for 
 
347
                     t in self.revision_trees(required_trees))
 
348
        for revision in revisions:
 
349
            if not revision.parent_ids:
 
350
                old_tree = EmptyTree()
 
351
            else:
 
352
                old_tree = trees[revision.parent_ids[0]]
 
353
            yield delta.compare_trees(old_tree, trees[revision.revision_id])
 
354
 
 
355
    @needs_read_lock
334
356
    def get_revision_delta(self, revision_id):
335
357
        """Return the delta for one revision.
336
358
 
337
359
        The delta is relative to the left-hand predecessor of the
338
360
        revision.
339
361
        """
340
 
        revision = self.get_revision(revision_id)
341
 
        new_tree = self.revision_tree(revision_id)
342
 
        if not revision.parent_ids:
343
 
            old_tree = EmptyTree()
344
 
        else:
345
 
            old_tree = self.revision_tree(revision.parent_ids[0])
346
 
        return delta.compare_trees(old_tree, new_tree)
 
362
        r = self.get_revision(revision_id)
 
363
        return list(self.get_deltas_for_revisions([r]))[0]
347
364
 
348
365
    def _check_revision_parents(self, revision, inventory):
349
366
        """Private to Repository and Fetch.
550
567
            return RevisionTree(self, inv, revision_id)
551
568
 
552
569
    @needs_read_lock
 
570
    def revision_trees(self, revision_ids):
 
571
        """Return Tree for a revision on this branch.
 
572
 
 
573
        `revision_id` may not be None or 'null:'"""
 
574
        assert None not in revision_ids
 
575
        assert NULL_REVISION not in revision_ids
 
576
        texts = self.get_inventory_weave().get_texts(revision_ids)
 
577
        for text, revision_id in zip(texts, revision_ids):
 
578
            inv = self.deserialise_inventory(revision_id, text)
 
579
            yield RevisionTree(self, inv, revision_id)
 
580
 
 
581
    @needs_read_lock
553
582
    def get_ancestry(self, revision_id):
554
583
        """Return a list of revision-ids integrated by a revision.
555
584