1066
1066
class cmd_remove(Command):
1067
1067
"""Remove files or directories.
1069
This makes bzr stop tracking changes to the specified files and
1070
delete them if they can easily be recovered using revert.
1072
You can specify one or more files, and/or --new. If you specify --new,
1073
only 'added' files will be removed. If you specify both, then new files
1074
in the specified directories will be removed. If the directories are
1075
also new, they will also be removed.
1069
This makes bzr stop tracking changes to the specified files and delete them
1070
if they can easily be recovered using revert. If no options or parameters
1071
are given bzr will scan for files that are versioned by bzr but missing in
1072
your tree and unversion them for you.
1077
1074
takes_args = ['file*']
1078
1075
takes_options = ['verbose',
1079
Option('new', help='Remove newly-added files.'),
1076
Option('new', help='Only remove files that have never been committed.'),
1080
1077
RegistryOption.from_kwargs('file-deletion-strategy',
1081
1078
'The file deletion mode to be used.',
1082
1079
title='Deletion Strategy', value_switches=True, enum_switch=False,
1095
1092
if file_list is not None:
1096
1093
file_list = [f for f in file_list]
1098
raise errors.BzrCommandError('Specify one or more files to'
1099
' remove, or use --new.')
1102
added = tree.changes_from(tree.basis_tree(),
1103
specific_files=file_list).added
1104
file_list = sorted([f[0] for f in added], reverse=True)
1105
if len(file_list) == 0:
1106
raise errors.BzrCommandError('No matching files.')
1107
tree.remove(file_list, verbose=verbose, to_file=self.outf,
1108
keep_files=file_deletion_strategy=='keep',
1109
force=file_deletion_strategy=='force')
1097
# Heuristics should probably all move into tree.remove_smart or
1100
added = tree.changes_from(tree.basis_tree(),
1101
specific_files=file_list).added
1102
file_list = sorted([f[0] for f in added], reverse=True)
1103
if len(file_list) == 0:
1104
raise errors.BzrCommandError('No matching files.')
1105
elif file_list is None:
1106
# missing files show up in iter_changes(basis) as
1107
# versioned-with-no-kind.
1109
for change in tree.iter_changes(tree.basis_tree()):
1110
if change[6][1] is None:
1111
missing.append(change[1][1])
1112
file_list = sorted(missing, reverse=True)
1113
file_deletion_strategy = 'keep'
1114
tree.remove(file_list, verbose=verbose, to_file=self.outf,
1115
keep_files=file_deletion_strategy=='keep',
1116
force=file_deletion_strategy=='force')
1112
1121
class cmd_file_id(Command):