~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tsort.py

  • Committer: John Arbash Meinel
  • Date: 2009-08-26 16:03:59 UTC
  • mto: (4634.6.7 2.0)
  • mto: This revision was merged to the branch mainline in revision 4660.
  • Revision ID: john@arbash-meinel.com-20090826160359-ge4mai928bi3a5g2
Fix bug #419241. If a graph had a mainline ghost
we could get a segfault during KnownGraph.merge_sort().

Show diffs side-by-side

added added

removed removed

Lines of Context:
459
459
            left_subtree_pushed_stack_append(False)
460
460
            pending_parents_stack_append(list(parents))
461
461
            # as we push it, check if it is the first child
 
462
            parent_info = None
462
463
            if parents:
463
464
                # node has parents, assign from the left most parent.
464
 
                parent_info = revnos[parents[0]]
 
465
                try:
 
466
                    parent_info = revnos[parents[0]]
 
467
                except KeyError:
 
468
                    # Left-hand parent is a ghost, consider it not to exist
 
469
                    pass
 
470
            if parent_info is not None:
465
471
                first_child = parent_info[1]
466
472
                parent_info[1] = False
467
473
            else:
495
501
            pending_parents_stack_pop()
496
502
 
497
503
            parents = original_graph[node_name]
 
504
            parent_revno = None
498
505
            if parents:
499
506
                # node has parents, assign from the left most parent.
500
 
                parent_revno = revnos[parents[0]][0]
 
507
                try:
 
508
                    parent_revno = revnos[parents[0]][0]
 
509
                except KeyError:
 
510
                    # left-hand parent is a ghost, treat it as not existing
 
511
                    pass
 
512
            if parent_revno is not None:
501
513
                if not first_child:
502
514
                    # not the first child, make a new branch
503
515
                    base_revno = parent_revno[0]
628
640
        self._left_subtree_pushed_stack.append(False)
629
641
        self._pending_parents_stack.append(list(parents))
630
642
        # as we push it, figure out if this is the first child
631
 
        parents = self._original_graph[node_name]
 
643
        parent_info = None
632
644
        if parents:
633
645
            # node has parents, assign from the left most parent.
634
 
            parent_info = self._revnos[parents[0]]
 
646
            try:
 
647
                parent_info = self._revnos[parents[0]]
 
648
            except KeyError:
 
649
                # Left-hand parent is a ghost, consider it not to exist
 
650
                pass
 
651
        if parent_info is not None:
635
652
            first_child = parent_info[1]
636
653
            parent_info[1] = False
637
654
        else:
655
672
        self._pending_parents_stack.pop()
656
673
 
657
674
        parents = self._original_graph[node_name]
 
675
        parent_revno = None
658
676
        if parents:
659
677
            # node has parents, assign from the left most parent.
660
 
            parent_revno = self._revnos[parents[0]][0]
 
678
            try:
 
679
                parent_revno = self._revnos[parents[0]][0]
 
680
            except KeyError:
 
681
                # left-hand parent is a ghost, treat it as not existing
 
682
                pass
 
683
        if parent_revno is not None:
661
684
            if not first_child:
662
685
                # not the first child, make a new branch
663
686
                base_revno = parent_revno[0]