1076
1076
class cmd_remove(Command):
1077
"""Make a file unversioned.
1077
"""Remove files or directories.
1079
This makes bzr stop tracking changes to a versioned file. It does
1080
not delete the working copy.
1079
This makes bzr stop tracking changes to the specified files and
1080
delete them if they can easily be recovered using revert.
1082
1082
You can specify one or more files, and/or --new. If you specify --new,
1083
1083
only 'added' files will be removed. If you specify both, then new files
1085
1085
also new, they will also be removed.
1087
1087
takes_args = ['file*']
1088
takes_options = ['verbose', Option('new', help='remove newly-added files')]
1088
takes_options = ['verbose',
1089
Option('new', help='remove newly-added files'),
1090
RegistryOption.from_kwargs('file-deletion-strategy',
1091
'The file deletion mode to be used',
1092
title='Deletion Strategy', value_switches=True, enum_switch=False,
1093
safe='Only delete files if they can be'
1094
' safely recovered (default).',
1095
keep="Don't delete any files.",
1096
force='Delete all the specified files, even if they can not be '
1097
'recovered and even if they are non-empty directories.')]
1089
1098
aliases = ['rm']
1090
1099
encoding_type = 'replace'
1092
def run(self, file_list, verbose=False, new=False):
1101
def run(self, file_list, verbose=False, new=False,
1102
file_deletion_strategy='safe'):
1093
1103
tree, file_list = tree_files(file_list)
1095
if file_list is None:
1096
raise errors.BzrCommandError('Specify one or more files to'
1097
' remove, or use --new.')
1105
if file_list is not None:
1106
file_list = [f for f in file_list if f != '']
1108
raise errors.BzrCommandError('Specify one or more files to'
1109
' remove, or use --new.')
1099
1112
added = tree.changes_from(tree.basis_tree(),
1100
1113
specific_files=file_list).added
1101
1114
file_list = sorted([f[0] for f in added], reverse=True)
1102
1115
if len(file_list) == 0:
1103
1116
raise errors.BzrCommandError('No matching files.')
1104
tree.remove(file_list, verbose=verbose, to_file=self.outf)
1117
tree.remove(file_list, verbose=verbose, to_file=self.outf,
1118
keep_files=file_deletion_strategy=='keep',
1119
force=file_deletion_strategy=='force')
1107
1122
class cmd_file_id(Command):