~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: 2010-02-12 07:42:09 UTC
  • mfrom: (4748.1.10 remove-tree-multi-253137)
  • Revision ID: pqm@pqm.ubuntu.com-20100212074209-ih8sj193z5w0aw2f
(Jared Hance) 'bzr remove-tree' can now remove multiple working
        trees. (#253137)

Show diffs side-by-side

added added

removed removed

Lines of Context:
453
453
    To re-create the working tree, use "bzr checkout".
454
454
    """
455
455
    _see_also = ['checkout', 'working-trees']
456
 
    takes_args = ['location?']
 
456
    takes_args = ['location*']
457
457
    takes_options = [
458
458
        Option('force',
459
459
               help='Remove the working tree even if it has '
460
460
                    'uncommitted changes.'),
461
461
        ]
462
462
 
463
 
    def run(self, location='.', force=False):
464
 
        d = bzrdir.BzrDir.open(location)
465
 
 
466
 
        try:
467
 
            working = d.open_workingtree()
468
 
        except errors.NoWorkingTree:
469
 
            raise errors.BzrCommandError("No working tree to remove")
470
 
        except errors.NotLocalUrl:
471
 
            raise errors.BzrCommandError("You cannot remove the working tree"
472
 
                                         " of a remote path")
473
 
        if not force:
474
 
            if (working.has_changes()):
475
 
                raise errors.UncommittedChanges(working)
476
 
 
477
 
        working_path = working.bzrdir.root_transport.base
478
 
        branch_path = working.branch.bzrdir.root_transport.base
479
 
        if working_path != branch_path:
480
 
            raise errors.BzrCommandError("You cannot remove the working tree"
481
 
                                         " from a lightweight checkout")
482
 
 
483
 
        d.destroy_workingtree()
 
463
    def run(self, location_list, force=False):
 
464
        if not location_list:
 
465
            location_list=['.']
 
466
 
 
467
        for location in location_list:
 
468
            d = bzrdir.BzrDir.open(location)
 
469
            
 
470
            try:
 
471
                working = d.open_workingtree()
 
472
            except errors.NoWorkingTree:
 
473
                raise errors.BzrCommandError("No working tree to remove")
 
474
            except errors.NotLocalUrl:
 
475
                raise errors.BzrCommandError("You cannot remove the working tree"
 
476
                                             " of a remote path")
 
477
            if not force:
 
478
                if (working.has_changes()):
 
479
                    raise errors.UncommittedChanges(working)
 
480
 
 
481
            working_path = working.bzrdir.root_transport.base
 
482
            branch_path = working.branch.bzrdir.root_transport.base
 
483
            if working_path != branch_path:
 
484
                raise errors.BzrCommandError("You cannot remove the working tree"
 
485
                                             " from a lightweight checkout")
 
486
 
 
487
            d.destroy_workingtree()
484
488
 
485
489
 
486
490
class cmd_revno(Command):