remove --keep deletes files from disk in remote branches
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Bazaar |
Confirmed
|
Wishlist
|
Unassigned |
Bug Description
Hi
I've noticed that if a file gets added to version control and is then removed but kept on disk using --keep then the same file is removed from disk on remote branches.
A use case is where, say, a config file is added to a local branch and merged into a remote branch. If that config file is removed from bzr using "bzr remove --keep file.ext" because it's decided that it should not be stored in version control, then that same file is deleted from disk on the remote branch.
The file should actually be kept on disk as the --keep flag is used, I understand that the file probably shouldn't be in bzr in the first place but in some cases this happens. The file being removed from disk can cause flow-on problems (e.g maybe it's an application config file for a website) -- the file then needs to be recreated manually which can be an annoyance.
A workaround is to dive in to the remote branch and make a copy of the file before the branch is updated then move the file back into place after the update. This is also an annoyance.
from the help docs:
bzr help remove:
"--keep Don't delete any files."
Simple command flow:
$ mkdir source
$ cd source
$ touch foo.txt
$ touch bar.txt
$ touch unwanted.txt
$ bzr init .
Created a standalone tree (format: pack-0.92)
$ bzr add
adding bar.txt
adding foo.txt
adding unwanted.txt
$ bzr commit -m "initial commit"
Committing to: /path/to/source/
added bar.txt
added foo.txt
added unwanted.txt
Committed revision 1.
$ cd ../
$ bzr branch ./source remote
Branched 1 revision(s).
$ cd remote
$ ls -la
total 12
drwxr-xr-x 3 james james 4096 2009-07-21 22:12 .
drwxr-xr-x 4 james james 4096 2009-07-21 22:12 ..
-rw-r--r-- 1 james james 0 2009-07-21 22:12 bar.txt
drwxr-xr-x 6 james james 4096 2009-07-21 22:12 .bzr
-rw-r--r-- 1 james james 0 2009-07-21 22:12 foo.txt
-rw-r--r-- 1 james james 0 2009-07-21 22:12 unwanted.txt
$ cd ../source/
$ bzr remove --keep unwanted.txt
removed unwanted.txt
$ bzr commit -m "remove unwanted file that should not be version controlled"
Committing to: /path/to/source/
deleted unwanted.txt
Committed revision 2.
$ ls -la
total 12
drwxr-xr-x 3 james james 4096 2009-07-21 22:12 .
drwxr-xr-x 4 james james 4096 2009-07-21 22:13 ..
-rw-r--r-- 1 james james 0 2009-07-21 22:12 bar.txt
drwxr-xr-x 6 james james 4096 2009-07-21 22:12 .bzr
-rw-r--r-- 1 james james 0 2009-07-21 22:11 foo.txt
-rw-r--r-- 1 james james 0 2009-07-21 22:12 unwanted.txt
$ cd ../remote
$ bzr pull
Using saved parent location: /path/to/source/
-D unwanted.txt
All changes applied successfully.
Now on revision 2.
$ ls -la
total 12
drwxr-xr-x 3 james james 4096 2009-07-21 22:13 .
drwxr-xr-x 4 james james 4096 2009-07-21 22:13 ..
-rw-r--r-- 1 james james 0 2009-07-21 22:12 bar.txt
drwxr-xr-x 6 james james 4096 2009-07-21 22:12 .bzr
-rw-r--r-- 1 james james 0 2009-07-21 22:12 foo.txt
After the bzr pull in "remote" I'd expect unwanted.txt to be kept on disk but removed from bzr -- is that a correct assumption or is this behaviour by design in remove --keep ?
If I had just used "bzr remove" then I'd expect unwanted.txt to be removed from bzr and disk as has happened above.
This also happens whether the "remote" branch is on the same disk or on a remote server over sftp.
Thanks
James
$ bzr version
Bazaar (bzr) 1.16.1
Python interpreter: /usr/bin/python 2.6.2
Python standard library: /usr/lib/python2.6
bzrlib: /usr/lib/
installed from ubuntu packages
Changed in bzr: | |
status: | Triaged → Confirmed |
tags: | added: check-for-breezy |
I can see why you'd want this in this case, and it's a reasonable case, but it's not a bug so much as a misunderstanding of bzr.
bzr --keep really means "keep in the working tree but delete from bzr". The results in terms of what's committed are the same whether you use --keep or not. Possibly this should be made more clear in the documentation or help, with eg
Would that have made it more clear?
It would be a separate feature request to have a way to update a tree without deleting files.
For now I suggest you in the updated tree use 'bzr revert' to extract the wanted revision of the configuration file...