Can't bzr rm a directory that contained a modified+emigrated file

Bug #129880 reported by Matthew Paul Thomas
6
Affects Status Importance Assigned to Milestone
Bazaar
Fix Released
Medium
Marius Kruger

Bug Description

"bzr rm" fails to remove a directory if, since the last commit, the only file in that directory was both (1) modified and (2) moved out of the directory using bzr mv.
------------
18:56:40@bzr-test> bzr init bug
18
:56:48@bzr-test> cd bug/
18:56:50@bug> mkdir somedir
18:56:53@bug> echo "contents" > somedir/file
18:57:00@bug> bzr add
added somedir
added somedir/file
18:57:02@bug> bzr ci -m "1st"
added somedir
added somedir/file
Committed revision 1.
18:57:15@bug> echo "new" > somedir/file
18:57:21@bug> bzr mv somedir/file moved-file
somedir/file => moved-file
18:57:30@bug> bzr rm somedir
bzr: ERROR: Can't remove changed or unknown files:
renamed:
  somedir/file => moved-file
modified:
  moved-file
Use --keep to not delete them, or --force to delete them regardless.
------------

Problem occurs with: bzr 0.17, bzr 0.18, bzr.dev.

Workaround: Commit between doing the bzr mv and doing the bzr rm.

[Thanks to Andrew Bennetts for helping debug this problem.]

Tags: rm

Related branches

Revision history for this message
Dan Watkins (oddbloke) wrote :

An alternative workaround is to use 'bzr rm --force somedir/'.

The problem seems to be in WorkingTree.remove as the file that has been moved from the directory still seems to be considered to be a file on which the deletability of the directory depends.[0] As it has been changed, the directory is considered changed.

[Footnote 0: Around lines 1828 to 1855 in bzr.dev.]

Revision history for this message
Dan Watkins (oddbloke) wrote :

Another alternative workaround is to use 'bzr rm --keep somedir', which'll unversion 'somedir' but not remove it from the filesystem.

Attached is a merge-directive for a failing test which should pass once this bug is fixed.

Dan Watkins (oddbloke)
Changed in bzr:
status: New → Confirmed
Revision history for this message
John A Meinel (jameinel) wrote :

Well, the error clearly states that you could --keep or --force.

But certainly if you rename a file out of a directory, it should not prevent that directory from being deleted.

Are you sure the file must be modified? At least at one point, I thought just doing 'bzr mv dir/foo foo' would be enough to require --force/--keep for 'bzr rm dir'

Changed in bzr:
importance: Undecided → Medium
Revision history for this message
edam (edam) wrote :

This bug is still present in bzr 1.9.

John A Meinel: After testing, it appears that you *do* have to modify the file before/after moving it out of the directory. If you don't modify the file, bazaar deletes the directory just fine.

This bug would seem to be a trivial thing to fix (admittedly, I don't know the innards of bazaar at all). Why is it a year old?

Revision history for this message
Robert Collins (lifeless) wrote :

Developer time; we have a lot of bugs and while this *may* be trivial to fix its probably still several hours to do so with care.

tags: added: performance
tags: added: rm
removed: performance
Marius Kruger (amanica)
Changed in bzr:
assignee: nobody → Marius Kruger (amanica)
status: Confirmed → In Progress
Marius Kruger (amanica)
Changed in bzr:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.