~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

  • Committer: Aaron Bentley
  • Date: 2007-07-11 19:44:51 UTC
  • mto: This revision was merged to the branch mainline in revision 2606.
  • Revision ID: abentley@panoramicfeedback.com-20070711194451-3jqhye1nnd02a9uv
Restore original Branch.last_revision behavior, fix bits that care

Show diffs side-by-side

added added

removed removed

Lines of Context:
812
812
            # local alterations
813
813
            merger.check_basis(check_clean=True, require_commits=False)
814
814
            if to_revision is None:
815
 
                to_revision = branch.last_revision()
 
815
                to_revision = _mod_revision.ensure_null(branch.last_revision())
816
816
            else:
817
817
                to_revision = osutils.safe_revision_id(to_revision)
818
818
            merger.other_rev_id = to_revision
2037
2037
            last_rev = self.get_parent_ids()[0]
2038
2038
        except IndexError:
2039
2039
            last_rev = _mod_revision.NULL_REVISION
2040
 
        if last_rev != self.branch.last_revision():
 
2040
        if last_rev != _mod_revision.ensure_null(self.branch.last_revision()):
2041
2041
            # merge tree state up to new branch tip.
2042
2042
            basis = self.basis_tree()
2043
2043
            basis.lock_read()
2600
2600
        if not isinstance(a_bzrdir.transport, LocalTransport):
2601
2601
            raise errors.NotLocalUrl(a_bzrdir.transport.base)
2602
2602
        branch = a_bzrdir.open_branch()
2603
 
        if revision_id is not None:
 
2603
        if revision_id is None:
 
2604
            revision_id = _mod_revision.ensure_null(branch.last_revision())
 
2605
        else:
2604
2606
            revision_id = osutils.safe_revision_id(revision_id)
2605
 
            branch.lock_write()
2606
 
            try:
2607
 
                revision_history = branch.revision_history()
2608
 
                try:
2609
 
                    position = revision_history.index(revision_id)
2610
 
                except ValueError:
2611
 
                    raise errors.NoSuchRevision(branch, revision_id)
2612
 
                branch.set_revision_history(revision_history[:position + 1])
2613
 
            finally:
2614
 
                branch.unlock()
2615
 
        revision = branch.last_revision()
 
2607
        branch.lock_write()
 
2608
        try:
 
2609
            branch.generate_revision_history(revision_id)
 
2610
        finally:
 
2611
            branch.unlock()
2616
2612
        inv = Inventory()
2617
2613
        wt = WorkingTree2(a_bzrdir.root_transport.local_abspath('.'),
2618
2614
                         branch,
2620
2616
                         _internal=True,
2621
2617
                         _format=self,
2622
2618
                         _bzrdir=a_bzrdir)
2623
 
        basis_tree = branch.repository.revision_tree(revision)
 
2619
        basis_tree = branch.repository.revision_tree(revision_id)
2624
2620
        if basis_tree.inventory.root is not None:
2625
2621
            wt.set_root_id(basis_tree.inventory.root.file_id)
2626
2622
        # set the parent list and cache the basis tree.
2627
 
        if _mod_revision.is_null(revision):
 
2623
        if _mod_revision.is_null(revision_id):
2628
2624
            parent_trees = []
2629
2625
        else:
2630
 
            parent_trees = [(revision, basis_tree)]
 
2626
            parent_trees = [(revision_id, basis_tree)]
2631
2627
        wt.set_parent_trees(parent_trees)
2632
2628
        transform.build_tree(basis_tree, wt)
2633
2629
        return wt
2727
2723
            # only set an explicit root id if there is one to set.
2728
2724
            if basis_tree.inventory.root is not None:
2729
2725
                wt.set_root_id(basis_tree.inventory.root.file_id)
2730
 
            if revision_id == NULL_REVISION:
 
2726
            if revision_id is None or revision_id == NULL_REVISION:
2731
2727
                wt.set_parent_trees([])
2732
2728
            else:
2733
2729
                wt.set_parent_trees([(revision_id, basis_tree)])