~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: 2009-06-26 03:32:27 UTC
  • mfrom: (4459.4.1 bzr.qpipe)
  • Revision ID: pqm@pqm.ubuntu.com-20090626033227-k6uokcs5iehqp80h
(abentley) Provide finer control over shelve and switch output.

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, quiet=False):
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, quiet)
40
40
 
41
41
 
42
42
def _check_pending_merges(control, force=False):
118
118
    return False
119
119
 
120
120
 
121
 
def _update(tree, source_repository):
 
121
def _update(tree, source_repository, quiet=False):
122
122
    """Update a working tree to the latest revision of its branch.
123
123
 
124
124
    :param tree: the working tree
128
128
    try:
129
129
        to_branch = tree.branch
130
130
        if tree.last_revision() == to_branch.last_revision():
131
 
            note("Tree is up to date at revision %d.", to_branch.revno())
 
131
            if not quiet:
 
132
                note("Tree is up to date at revision %d.", to_branch.revno())
132
133
            return
133
134
        base_tree = source_repository.revision_tree(tree.last_revision())
134
135
        merge.Merge3Merger(tree, tree, base_tree, to_branch.basis_tree())
135
136
        tree.set_last_revision(to_branch.last_revision())
136
 
        note('Updated to revision %d.' % to_branch.revno())
 
137
        if not quiet:
 
138
            note('Updated to revision %d.' % to_branch.revno())
137
139
    finally:
138
140
        tree.unlock()