~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Parth Malwankar
  • Date: 2010-04-19 13:23:53 UTC
  • mfrom: (5165 +trunk)
  • mto: (5183.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 5184.
  • Revision ID: parth.malwankar@gmail.com-20100419132353-gwp4r4srafq2i2kb
merged in trunk and moved NEWS entry to 2.2b2

Show diffs side-by-side

added added

removed removed

Lines of Context:
447
447
        # start_revision_id.
448
448
        if self._merge_sorted_revisions_cache is None:
449
449
            last_revision = self.last_revision()
450
 
            last_key = (last_revision,)
451
 
            known_graph = self.repository.revisions.get_known_graph_ancestry(
452
 
                [last_key])
 
450
            known_graph = self.repository.get_known_graph_ancestry(
 
451
                [last_revision])
453
452
            self._merge_sorted_revisions_cache = known_graph.merge_sort(
454
 
                last_key)
 
453
                last_revision)
455
454
        filtered = self._filter_merge_sorted_revisions(
456
455
            self._merge_sorted_revisions_cache, start_revision_id,
457
456
            stop_revision_id, stop_rule)
 
457
        # Make sure we don't return revisions that are not part of the
 
458
        # start_revision_id ancestry.
 
459
        filtered = self._filter_non_ancestors(filtered)
458
460
        if direction == 'reverse':
459
461
            return filtered
460
462
        if direction == 'forward':
525
527
        else:
526
528
            raise ValueError('invalid stop_rule %r' % stop_rule)
527
529
 
 
530
    def _filter_non_ancestors(self, rev_iter):
 
531
        # If we started from a dotted revno, we want to consider it as a tip
 
532
        # and don't want to yield revisions that are not part of its
 
533
        # ancestry. Given the order guaranteed by the merge sort, we will see
 
534
        # uninteresting descendants of the first parent of our tip before the
 
535
        # tip itself.
 
536
        first = rev_iter.next()
 
537
        (rev_id, merge_depth, revno, end_of_merge) = first
 
538
        yield first
 
539
        if not merge_depth:
 
540
            # We start at a mainline revision so by definition, all others
 
541
            # revisions in rev_iter are ancestors
 
542
            for node in rev_iter:
 
543
                yield node
 
544
 
 
545
        clean = False
 
546
        whitelist = set()
 
547
        pmap = self.repository.get_parent_map([rev_id])
 
548
        parents = pmap.get(rev_id, [])
 
549
        if parents:
 
550
            whitelist.update(parents)
 
551
        else:
 
552
            # If there is no parents, there is nothing of interest left
 
553
 
 
554
            # FIXME: It's hard to test this scenario here as this code is never
 
555
            # called in that case. -- vila 20100322
 
556
            return
 
557
 
 
558
        for (rev_id, merge_depth, revno, end_of_merge) in rev_iter:
 
559
            if not clean:
 
560
                if rev_id in whitelist:
 
561
                    pmap = self.repository.get_parent_map([rev_id])
 
562
                    parents = pmap.get(rev_id, [])
 
563
                    whitelist.remove(rev_id)
 
564
                    whitelist.update(parents)
 
565
                    if merge_depth == 0:
 
566
                        # We've reached the mainline, there is nothing left to
 
567
                        # filter
 
568
                        clean = True
 
569
                else:
 
570
                    # A revision that is not part of the ancestry of our
 
571
                    # starting revision.
 
572
                    continue
 
573
            yield (rev_id, merge_depth, revno, end_of_merge)
 
574
 
528
575
    def leave_lock_in_place(self):
529
576
        """Tell this branch object not to release the physical lock when this
530
577
        object is unlocked.