~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-08-20 13:57:27 UTC
  • mfrom: (4633.1.1 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20090820135727-pz56lf0l0tj6rbrn
(luks) Support for `bzr branch --switch`

Show diffs side-by-side

added added

removed removed

Lines of Context:
1167
1167
        help='Hard-link working tree files where possible.'),
1168
1168
        Option('no-tree',
1169
1169
            help="Create a branch without a working-tree."),
 
1170
        Option('switch',
 
1171
            help="Switch the checkout in the current directory "
 
1172
                 "to the new branch."),
1170
1173
        Option('stacked',
1171
1174
            help='Create a stacked branch referring to the source branch. '
1172
1175
                'The new branch will depend on the availability of the source '
1183
1186
 
1184
1187
    def run(self, from_location, to_location=None, revision=None,
1185
1188
            hardlink=False, stacked=False, standalone=False, no_tree=False,
1186
 
            use_existing_dir=False):
 
1189
            use_existing_dir=False, switch=False):
 
1190
        from bzrlib import switch as _mod_switch
1187
1191
        from bzrlib.tag import _merge_tags_if_possible
1188
 
 
1189
1192
        accelerator_tree, br_from = bzrdir.BzrDir.open_tree_or_branch(
1190
1193
            from_location)
1191
1194
        if (accelerator_tree is not None and
1245
1248
            except (errors.NotStacked, errors.UnstackableBranchFormat,
1246
1249
                errors.UnstackableRepositoryFormat), e:
1247
1250
                note('Branched %d revision(s).' % branch.revno())
 
1251
            if switch:
 
1252
                # Switch to the new branch
 
1253
                wt, _ = WorkingTree.open_containing('.')
 
1254
                _mod_switch.switch(wt.bzrdir, branch)
 
1255
                note('Switched to branch: %s',
 
1256
                    urlutils.unescape_for_display(branch.base, 'utf-8'))
1248
1257
        finally:
1249
1258
            br_from.unlock()
1250
1259