~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/switch.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-01-12 08:03:28 UTC
  • mfrom: (4949.1.1 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20100112080328-cb0tvu90uglxlrw0
(mbp) merge 2.0 back to trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
from bzrlib.trace import note
23
23
 
24
24
 
25
 
def switch(control_dir, to_branch, force=False, quiet=False, revision_id=None):
 
25
def switch(control_dir, to_branch, force=False, quiet=False):
26
26
    """Switch the branch associated with a checkout.
27
27
 
28
28
    :param control_dir: BzrDir of the checkout to change
29
29
    :param to_branch: branch that the checkout is to reference
30
30
    :param force: skip the check for local commits in a heavy checkout
31
 
    :param revision_id: revision ID to switch to.
32
31
    """
33
32
    _check_pending_merges(control_dir, force)
34
33
    try:
37
36
        source_repository = to_branch.repository
38
37
    _set_branch_location(control_dir, to_branch, force)
39
38
    tree = control_dir.open_workingtree()
40
 
    _update(tree, source_repository, quiet, revision_id)
 
39
    _update(tree, source_repository, quiet)
41
40
 
42
41
 
43
42
def _check_pending_merges(control, force=False):
119
118
    return False
120
119
 
121
120
 
122
 
def _update(tree, source_repository, quiet=False, revision_id=None):
 
121
def _update(tree, source_repository, quiet=False):
123
122
    """Update a working tree to the latest revision of its branch.
124
123
 
125
124
    :param tree: the working tree
128
127
    tree.lock_tree_write()
129
128
    try:
130
129
        to_branch = tree.branch
131
 
        if revision_id is None:
132
 
            revision_id = to_branch.last_revision()
133
 
        if tree.last_revision() == revision_id:
 
130
        if tree.last_revision() == to_branch.last_revision():
134
131
            if not quiet:
135
132
                note("Tree is up to date at revision %d.", to_branch.revno())
136
133
            return
137
134
        base_tree = source_repository.revision_tree(tree.last_revision())
138
 
        merge.Merge3Merger(tree, tree, base_tree, to_branch.repository.revision_tree(revision_id))
 
135
        merge.Merge3Merger(tree, tree, base_tree, to_branch.basis_tree())
139
136
        tree.set_last_revision(to_branch.last_revision())
140
137
        if not quiet:
141
138
            note('Updated to revision %d.' % to_branch.revno())