~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Martin Pool
  • Date: 2009-08-28 04:13:16 UTC
  • mfrom: (4634.6.8 2.0)
  • mto: This revision was merged to the branch mainline in revision 4660.
  • Revision ID: mbp@sourcefrog.net-20090828041316-adcbxfnfpc4bjtpl
Merge 2.0 back to trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1176
1176
        help='Hard-link working tree files where possible.'),
1177
1177
        Option('no-tree',
1178
1178
            help="Create a branch without a working-tree."),
 
1179
        Option('switch',
 
1180
            help="Switch the checkout in the current directory "
 
1181
                 "to the new branch."),
1179
1182
        Option('stacked',
1180
1183
            help='Create a stacked branch referring to the source branch. '
1181
1184
                'The new branch will depend on the availability of the source '
1192
1195
 
1193
1196
    def run(self, from_location, to_location=None, revision=None,
1194
1197
            hardlink=False, stacked=False, standalone=False, no_tree=False,
1195
 
            use_existing_dir=False):
 
1198
            use_existing_dir=False, switch=False):
 
1199
        from bzrlib import switch as _mod_switch
1196
1200
        from bzrlib.tag import _merge_tags_if_possible
1197
 
 
1198
1201
        accelerator_tree, br_from = bzrdir.BzrDir.open_tree_or_branch(
1199
1202
            from_location)
1200
1203
        if (accelerator_tree is not None and
1254
1257
            except (errors.NotStacked, errors.UnstackableBranchFormat,
1255
1258
                errors.UnstackableRepositoryFormat), e:
1256
1259
                note('Branched %d revision(s).' % branch.revno())
 
1260
            if switch:
 
1261
                # Switch to the new branch
 
1262
                wt, _ = WorkingTree.open_containing('.')
 
1263
                _mod_switch.switch(wt.bzrdir, branch)
 
1264
                note('Switched to branch: %s',
 
1265
                    urlutils.unescape_for_display(branch.base, 'utf-8'))
1257
1266
        finally:
1258
1267
            br_from.unlock()
1259
1268
 
3029
3038
                raise errors.BzrCommandError("empty commit message specified")
3030
3039
            return my_message
3031
3040
 
 
3041
        # The API permits a commit with a filter of [] to mean 'select nothing'
 
3042
        # but the command line should not do that.
 
3043
        if not selected_list:
 
3044
            selected_list = None
3032
3045
        try:
3033
3046
            tree.commit(message_callback=get_message,
3034
3047
                        specific_files=selected_list,