~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

(robertc) Deprecate WorkingTree.pending_merges.

Show diffs side-by-side

added added

removed removed

Lines of Context:
96
96
        deprecated_function,
97
97
        DEPRECATED_PARAMETER,
98
98
        zero_eight,
 
99
        zero_eleven,
99
100
        )
100
101
from bzrlib.trace import mutter, note
101
102
from bzrlib.transform import build_tree
399
400
        If the left most parent is a ghost then the returned tree will be an
400
401
        empty tree - one obtained by calling repository.revision_tree(None).
401
402
        """
402
 
        revision_id = self.last_revision()
403
 
        if revision_id is not None:
 
403
        try:
 
404
            revision_id = self.get_parent_ids()[0]
 
405
        except IndexError:
 
406
            # no parents, return an empty revision tree.
 
407
            # in the future this should return the tree for
 
408
            # 'empty:' - the implicit root empty tree.
 
409
            return self.branch.repository.revision_tree(None)
 
410
        else:
404
411
            try:
405
412
                xml = self.read_basis_inventory()
406
413
                inv = bzrlib.xml5.serializer_v5.read_inventory_from_string(xml)
410
417
            if inv is not None and inv.revision_id == revision_id:
411
418
                return bzrlib.tree.RevisionTree(self.branch.repository, inv,
412
419
                                                revision_id)
413
 
        # FIXME? RBC 20060403 should we cache the inventory here ?
 
420
        # No cached copy available, retrieve from the repository.
 
421
        # FIXME? RBC 20060403 should we cache the inventory locally
 
422
        # at this point ?
414
423
        try:
415
424
            return self.branch.repository.revision_tree(revision_id)
416
425
        except errors.RevisionNotPresent:
486
495
        This implementation reads the pending merges list and last_revision
487
496
        value and uses that to decide what the parents list should be.
488
497
        """
489
 
        last_rev = self.last_revision()
 
498
        last_rev = self._last_revision()
490
499
        if last_rev is None:
491
500
            parents = []
492
501
        else:
714
723
        if updated:
715
724
            self.set_parent_ids(parents, allow_leftmost_as_ghost=True)
716
725
 
 
726
    @deprecated_method(zero_eleven)
717
727
    @needs_read_lock
718
728
    def pending_merges(self):
719
729
        """Return a list of pending merges.
720
730
 
721
731
        These are revisions that have been merged into the working
722
732
        directory but not yet committed.
 
733
 
 
734
        As of 0.11 this is deprecated. Please see WorkingTree.get_parent_ids()
 
735
        instead - which is available on all tree objects.
723
736
        """
724
737
        return self.get_parent_ids()[1:]
725
738
 
1345
1358
    def kind(self, file_id):
1346
1359
        return file_kind(self.id2abspath(file_id))
1347
1360
 
1348
 
    @needs_read_lock
1349
1361
    def last_revision(self):
1350
1362
        """Return the last revision id of this working tree.
1351
1363
 
1352
 
        In early branch formats this was == the branch last_revision,
 
1364
        In early branch formats this was the same as the branch last_revision,
1353
1365
        but that cannot be relied upon - for working tree operations,
1354
 
        always use tree.last_revision().
 
1366
        always use tree.last_revision(). This returns the left most parent id,
 
1367
        or None if there are no parents.
 
1368
 
 
1369
        This was deprecated as of 0.11. Please use get_parent_ids instead.
1355
1370
        """
 
1371
        return self._last_revision()
 
1372
 
 
1373
    @needs_read_lock
 
1374
    def _last_revision(self):
 
1375
        """helper for get_parent_ids."""
1356
1376
        return self.branch.last_revision()
1357
1377
 
1358
1378
    def is_locked(self):
1585
1605
        # local work is unreferenced and will appear to have been lost.
1586
1606
        # 
1587
1607
        result = 0
1588
 
        if self.last_revision() != self.branch.last_revision():
 
1608
        try:
 
1609
            last_rev = self.get_parent_ids()[0]
 
1610
        except IndexError:
 
1611
            last_rev = None
 
1612
        if last_rev != self.branch.last_revision():
1589
1613
            # merge tree state up to new branch tip.
1590
1614
            basis = self.basis_tree()
1591
1615
            to_tree = self.branch.basis_tree()
1609
1633
                parent_trees.append(
1610
1634
                    (old_tip, self.branch.repository.revision_tree(old_tip)))
1611
1635
            self.set_parent_trees(parent_trees)
 
1636
            last_rev = parent_trees[0][0]
1612
1637
        else:
1613
1638
            # the working tree had the same last-revision as the master
1614
1639
            # branch did. We may still have pivot local work from the local
1615
1640
            # branch into old_tip:
1616
1641
            if old_tip is not None:
1617
1642
                self.add_parent_tree_id(old_tip)
1618
 
        if old_tip and old_tip != self.last_revision():
 
1643
        if old_tip and old_tip != last_rev:
1619
1644
            # our last revision was not the prior branch last revision
1620
1645
            # and we have converted that last revision to a pending merge.
1621
1646
            # base is somewhere between the branch tip now
1707
1732
    """
1708
1733
 
1709
1734
    @needs_read_lock
1710
 
    def last_revision(self):
1711
 
        """See WorkingTree.last_revision."""
 
1735
    def _last_revision(self):
 
1736
        """See WorkingTree._last_revision."""
1712
1737
        try:
1713
1738
            return self._control_files.get_utf8('last-revision').read()
1714
1739
        except NoSuchFile: