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

  • Committer: Daniel Watkins
  • Date: 2009-02-07 16:52:08 UTC
  • mto: This revision was merged to the branch mainline in revision 4964.
  • Revision ID: daniel@daniel-watkins.co.uk-20090207165208-wek2zjo4gtm4sn0j
Implement use of a revision at the bzrlib.switch level.

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):
 
25
def switch(control_dir, to_branch, force=False, revision_id=None):
26
26
    """Switch the branch associated with a checkout.
27
27
 
28
28
    :param control_dir: BzrDir of the checkout to change
36
36
        source_repository = to_branch.repository
37
37
    _set_branch_location(control_dir, to_branch, force)
38
38
    tree = control_dir.open_workingtree()
39
 
    _update(tree, source_repository)
 
39
    _update(tree, source_repository, revision_id)
40
40
 
41
41
 
42
42
def _check_pending_merges(control, force=False):
112
112
    return False
113
113
 
114
114
 
115
 
def _update(tree, source_repository):
 
115
def _update(tree, source_repository, revision_id=None):
116
116
    """Update a working tree to the latest revision of its branch.
117
117
 
118
118
    :param tree: the working tree
121
121
    tree.lock_tree_write()
122
122
    try:
123
123
        to_branch = tree.branch
124
 
        if tree.last_revision() == to_branch.last_revision():
 
124
        if revision_id is None:
 
125
            revision_id = to_branch.last_revision()
 
126
        if tree.last_revision() == revision_id:
125
127
            note("Tree is up to date at revision %d.", to_branch.revno())
126
128
            return
127
129
        base_tree = source_repository.revision_tree(tree.last_revision())
128
 
        merge.Merge3Merger(tree, tree, base_tree, to_branch.basis_tree())
129
 
        tree.set_last_revision(to_branch.last_revision())
 
130
        merge.Merge3Merger(tree, tree, base_tree, to_branch.repository.revision_tree(revision_id))
 
131
        tree.set_last_revision(revision_id)
130
132
        note('Updated to revision %d.' % to_branch.revno())
131
133
    finally:
132
134
        tree.unlock()