~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-04-28 09:40:23 UTC
  • mfrom: (5155.1.5 320119-exclude-ancestry)
  • Revision ID: pqm@pqm.ubuntu.com-20100428094023-7504mlou1qk28r9n
(vila) Add --exclude-common-ancestry log option (Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
417
417
            * 'include' - the stop revision is the last item in the result
418
418
            * 'with-merges' - include the stop revision and all of its
419
419
              merged revisions in the result
 
420
            * 'with-merges-without-common-ancestry' - filter out revisions 
 
421
              that are in both ancestries
420
422
        :param direction: either 'reverse' or 'forward':
421
423
            * reverse means return the start_revision_id first, i.e.
422
424
              start at the most recent revision and go backwards in history
453
455
            stop_revision_id, stop_rule)
454
456
        # Make sure we don't return revisions that are not part of the
455
457
        # start_revision_id ancestry.
456
 
        filtered = self._filter_non_ancestors(filtered)
 
458
        filtered = self._filter_start_non_ancestors(filtered)
457
459
        if direction == 'reverse':
458
460
            return filtered
459
461
        if direction == 'forward':
496
498
                       node.end_of_merge)
497
499
                if rev_id == stop_revision_id:
498
500
                    return
 
501
        elif stop_rule == 'with-merges-without-common-ancestry':
 
502
            # We want to exclude all revisions that are already part of the
 
503
            # stop_revision_id ancestry.
 
504
            graph = self.repository.get_graph()
 
505
            ancestors = graph.find_unique_ancestors(start_revision_id,
 
506
                                                    [stop_revision_id])
 
507
            for node in rev_iter:
 
508
                rev_id = node.key[-1]
 
509
                if rev_id not in ancestors:
 
510
                    continue
 
511
                yield (rev_id, node.merge_depth, node.revno,
 
512
                       node.end_of_merge)
499
513
        elif stop_rule == 'with-merges':
500
514
            stop_rev = self.repository.get_revision(stop_revision_id)
501
515
            if stop_rev.parent_ids:
524
538
        else:
525
539
            raise ValueError('invalid stop_rule %r' % stop_rule)
526
540
 
527
 
    def _filter_non_ancestors(self, rev_iter):
 
541
    def _filter_start_non_ancestors(self, rev_iter):
528
542
        # If we started from a dotted revno, we want to consider it as a tip
529
543
        # and don't want to yield revisions that are not part of its
530
544
        # ancestry. Given the order guaranteed by the merge sort, we will see