~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Ian Clatworthy
  • Date: 2007-12-07 05:53:45 UTC
  • mfrom: (3078.2.8 bzr.switch)
  • mto: This revision was merged to the branch mainline in revision 3093.
  • Revision ID: ian.clatworthy@internode.on.net-20071207055345-ek2m118pm79nowuf
switch for heavyweight checkouts

Show diffs side-by-side

added added

removed removed

Lines of Context:
4353
4353
 
4354
4354
 
4355
4355
class cmd_switch(Command):
4356
 
    """Set the branch of a lightweight checkout and update."""
 
4356
    """Set the branch of a checkout and update.
 
4357
    
 
4358
    For lightweight checkouts, this changes the branch being referenced.
 
4359
    For heavyweight checkouts, this checks that there are no local commits
 
4360
    versus the current bound branch, then it makes the local branch a mirror
 
4361
    of the new location and binds to it.
 
4362
    
 
4363
    In both cases, the working tree is updated and uncommitted changes
 
4364
    are merged. The user can commit or revert these as they desire.
 
4365
 
 
4366
    Pending merges need to be committed or reverted before using switch.
 
4367
    """
4357
4368
 
4358
4369
    takes_args = ['to_location']
 
4370
    takes_options = [Option('force',
 
4371
                        help='Switch even if local commits will be lost.')
 
4372
                     ]
4359
4373
 
4360
 
    def run(self, to_location):
 
4374
    def run(self, to_location, force=False):
4361
4375
        from bzrlib import switch
4362
4376
        to_branch = Branch.open(to_location)
4363
4377
        tree_location = '.'
4364
4378
        control_dir = bzrdir.BzrDir.open_containing(tree_location)[0]
4365
 
        switch.switch(control_dir, to_branch)
 
4379
        switch.switch(control_dir, to_branch, force)
4366
4380
        note('Switched to branch: %s',
4367
4381
            urlutils.unescape_for_display(to_branch.base, 'utf-8'))
4368
4382