~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: 2006-05-31 06:31:45 UTC
  • mfrom: (1551.6.26 Aaron's mergeable stuff)
  • Revision ID: pqm@pqm.ubuntu.com-20060531063145-514f175d1d270a48
Add --new option to 'bzr remove'

Show diffs side-by-side

added added

removed removed

Lines of Context:
793
793
 
794
794
    This makes bzr stop tracking changes to a versioned file.  It does
795
795
    not delete the working copy.
 
796
 
 
797
    You can specify one or more files, and/or --new.  If you specify --new,
 
798
    only 'added' files will be removed.  If you specify both, then new files
 
799
    in the specified directories will be removed.  If the directories are
 
800
    also new, they will also be removed.
796
801
    """
797
 
    takes_args = ['file+']
798
 
    takes_options = ['verbose']
 
802
    takes_args = ['file*']
 
803
    takes_options = ['verbose', Option('new', help='remove newly-added files')]
799
804
    aliases = ['rm']
800
805
    
801
 
    def run(self, file_list, verbose=False):
 
806
    def run(self, file_list, verbose=False, new=False):
802
807
        tree, file_list = tree_files(file_list)
 
808
        if new is False:
 
809
            if file_list is None:
 
810
                raise BzrCommandError('Specify one or more files to remove, or'
 
811
                                      ' use --new.')
 
812
        else:
 
813
            from bzrlib.delta import compare_trees
 
814
            added = [compare_trees(tree.basis_tree(), tree,
 
815
                                   specific_files=file_list).added]
 
816
            file_list = sorted([f[0] for f in added[0]], reverse=True)
 
817
            if len(file_list) == 0:
 
818
                raise BzrCommandError('No matching files.')
803
819
        tree.remove(file_list, verbose=verbose)
804
820
 
805
821