bzr add and revert on symlink deletes symlink

Bug #87548 reported by Kent Gibson
32
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Bazaar
Invalid
Undecided
Unassigned

Bug Description

Adding a symlink to bzr and then reverting results in the symlink being removed
i.e.
echo > a
ln -s a b
bzr add b
bzr revert b

now b is gone.

Similarly, if there is a directory of symlinks (just symlinks) then add/revert will result in the complete directory being deleted.
e.g.
bzr add /etc/apache2/sites-enabled
bzr revert /etc/apache2/sites-enabled

You would hope that bzr add followed by bzr revert would be a null operation.

Kent Gibson (warthog618)
description: updated
Revision history for this message
James Westby (james-w) wrote :

bzr will also try and delete directories in the same way, but will not if they are not
empty, so wont cause any data loss.

It seems it is only files that it will try and preserve at all, and then only in some cases.

When I saw this bug I was suprised, but looking at the code it seems it is intentional, though I can't see a test for it with a quick look.

Revision history for this message
Martin Pool (mbp) wrote :

This is the designed behaviour: revert restores your tree to the state it previously had, including removing newly added files.

I'll add a message to the help message for revert explaining that it will do this.

It might be reasonable to have an option for revert called say --keep-added that disables this behaviour -- please talk about this on the list if you want it.

Changed in bzr:
status: New → Invalid
Revision history for this message
Daniel Hahler (blueyed) wrote :

wow.. I've just lost all my symlinks and empty directories because of:
# bzr init
# bzr add
# bzr revert
# bzr ignore ...

Instead of "bzr revert" I should have used "bzr rm --keep --new".

Not much fun.

Revision history for this message
Alexander Belchenko (bialix) wrote :

I agree -- it's not fun. Why revert is not deleting and newly added files as well?

Revision history for this message
Daniel Hahler (blueyed) wrote :

> This is the designed behaviour: revert restores your tree to the state it previously had, including removing newly added files.

I rather like the behavior from svn in this case, which would just undo the "add", but not delete the file, when doing:
svn add foo
svn revert

My understanding is, that the previous state of the tree (before bzr add) is "unknown file foo".
So, when doing a revert, it should only revert the "add", but not remove (or currently rename/backup) the file.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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