/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/workingtree.py

Alter set_pending_merges to shove the left most merge into the trees last-revision if that is not set. Related bugfixes include basis_tree handling ghosts, de-duping the merges with the last-revision and update changing where and how it adds its pending merge.

Show diffs side-by-side

added added

removed removed

Lines of Context:
407
407
                return bzrlib.tree.RevisionTree(self.branch.repository, inv,
408
408
                                                revision_id)
409
409
        # FIXME? RBC 20060403 should we cache the inventory here ?
410
 
        return self.branch.repository.revision_tree(revision_id)
 
410
        try:
 
411
            return self.branch.repository.revision_tree(revision_id)
 
412
        except errors.RevisionNotPresent:
 
413
            # the basis tree *may* be a ghost or a low level error may have
 
414
            # occured. If the revision is present, its a problem, if its not
 
415
            # its a ghost.
 
416
            if self.branch.repository.has_revision(revision_id):
 
417
                raise
 
418
            # the basis tree is a ghost
 
419
            return self.branch.repository.revision_tree(None)
411
420
 
412
421
    @staticmethod
413
422
    @deprecated_method(zero_eight)
648
657
        # TODO: Perhaps should check at this point that the
649
658
        # history of the revision is actually present?
650
659
        p = self.pending_merges()
 
660
        existing_parents = self.get_parent_ids()
651
661
        updated = False
652
662
        for rev_id in revision_ids:
653
663
            if rev_id in p:
654
664
                continue
 
665
            if rev_id in existing_parents:
 
666
                continue
655
667
            p.append(rev_id)
656
668
            updated = True
657
669
        if updated:
675
687
 
676
688
    @needs_write_lock
677
689
    def set_pending_merges(self, rev_list):
 
690
        if self.last_revision() is None:
 
691
            new_last_list = rev_list[:1]
 
692
            rev_list = rev_list[1:]
 
693
            if new_last_list:
 
694
                self.set_last_revision(new_last_list[0])
678
695
        self._control_files.put_utf8('pending-merges', '\n'.join(rev_list))
679
696
 
680
697
    @needs_write_lock
1403
1420
        Do a 'normal' merge of the old branch basis if it is relevant.
1404
1421
        """
1405
1422
        old_tip = self.branch.update()
1406
 
        if old_tip is not None:
1407
 
            self.add_pending_merge(old_tip)
1408
 
        self.branch.lock_read()
1409
1423
        try:
1410
1424
            result = 0
1411
1425
            if self.last_revision() != self.branch.last_revision():
1437
1451
                                      this_tree=self)
1438
1452
            return result
1439
1453
        finally:
1440
 
            self.branch.unlock()
 
1454
            if old_tip is not None:
 
1455
                self.add_pending_merge(old_tip)
1441
1456
 
1442
1457
    @needs_write_lock
1443
1458
    def _write_inventory(self, inv):