~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

Merge with get_file_sha1

Show diffs side-by-side

added added

removed removed

Lines of Context:
250
250
    To re-create the working tree, use "bzr checkout".
251
251
    """
252
252
    _see_also = ['checkout', 'working-trees']
253
 
 
254
253
    takes_args = ['location?']
 
254
    takes_options = [
 
255
        Option('force',
 
256
               help='Remove the working tree even if it has '
 
257
                    'uncommitted changes.'),
 
258
        ]
255
259
 
256
 
    def run(self, location='.'):
 
260
    def run(self, location='.', force=False):
257
261
        d = bzrdir.BzrDir.open(location)
258
262
        
259
263
        try:
263
267
        except errors.NotLocalUrl:
264
268
            raise errors.BzrCommandError("You cannot remove the working tree of a "
265
269
                                         "remote path")
266
 
        
 
270
        if not force:
 
271
            changes = working.changes_from(working.basis_tree())
 
272
            if changes.has_changed():
 
273
                raise errors.UncommittedChanges(working)
 
274
 
267
275
        working_path = working.bzrdir.root_transport.base
268
276
        branch_path = working.branch.bzrdir.root_transport.base
269
277
        if working_path != branch_path:
837
845
            help='Create a stacked branch referring to the source branch. '
838
846
                'The new branch will depend on the availability of the source '
839
847
                'branch for all operations.'),
 
848
        Option('standalone',
 
849
               help='Do not use a shared repository, even if available.'),
840
850
        ]
841
851
    aliases = ['get', 'clone']
842
852
 
843
853
    def run(self, from_location, to_location=None, revision=None,
844
 
            hardlink=False, stacked=False):
 
854
            hardlink=False, stacked=False, standalone=False):
845
855
        from bzrlib.tag import _merge_tags_if_possible
846
856
        if revision is None:
847
857
            revision = [None]
876
886
                dir = br_from.bzrdir.sprout(to_transport.base, revision_id,
877
887
                                            possible_transports=[to_transport],
878
888
                                            accelerator_tree=accelerator_tree,
879
 
                                            hardlink=hardlink, stacked=stacked)
 
889
                                            hardlink=hardlink, stacked=stacked,
 
890
                                            force_new_repo=standalone)
880
891
                branch = dir.open_branch()
881
892
            except errors.NoSuchRevision:
882
893
                to_transport.delete_tree('.')
4559
4570
        try:
4560
4571
            to_branch = Branch.open(to_location)
4561
4572
        except errors.NotBranchError:
 
4573
            this_branch = control_dir.open_branch()
 
4574
            # This may be a heavy checkout, where we want the master branch
 
4575
            this_url = this_branch.get_bound_location()
 
4576
            # If not, use a local sibling
 
4577
            if this_url is None:
 
4578
                this_url = this_branch.base
4562
4579
            to_branch = Branch.open(
4563
 
                control_dir.open_branch().base + '../' + to_location)
 
4580
                urlutils.join(this_url, '..', to_location))
4564
4581
        switch.switch(control_dir, to_branch, force)
4565
4582
        note('Switched to branch: %s',
4566
4583
            urlutils.unescape_for_display(to_branch.base, 'utf-8'))