1768
1768
@needs_tree_write_lock
1769
def remove(self, files, verbose=False, to_file=None, keep_files=True,
1769
def remove(self, files, verbose=False, to_file=None, keep_files=True,
1771
1771
"""Remove nominated files from the working inventor.
1773
:files: File paths relative to the basedir.
1773
1774
:keep_files: If true, the files will also be kept.
1774
1775
:force: Delete files and directories, even if they are changed and
1775
1776
even if the directories are not empty.
1777
## TODO: Normalize names
1778
1778
if isinstance(files, basestring):
1779
1779
files = [files]
1781
1781
inv = self.inventory
1782
1782
changed_files=[]
1784
# Sort needed when deleting files:
1785
# first delete directory content before the directory
1784
# Get file names into canonical form.
1785
files = [self.relpath(self.abspath(filename))
1786
for filename in files]
1788
# Sort needed to first handle directory content before the directory
1789
files.sort(reverse=True)
1786
1791
if not keep_files and not force:
1787
files = [self.relpath(osutils.dereference_path(filename))
1788
for filename in files]
1789
files.sort(reverse=True)
1790
1792
changes = self.changes_from(self.basis_tree(),
1791
1793
specific_files=files)
1793
1794
for f in changes.modified:
1794
1795
changed_files.append(f[0])
1795
1796
for f in changes.added: