remove-tree removes shelved changes without warning

Bug #586639 reported by Matt Giuca
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Bazaar
Fix Released
Medium
Unassigned

Bug Description

The bzr remove-tree command will blow away any shelved changes without warning or prompting.

For example:
$ bzr init
$ echo foo > foo
$ bzr add
$ bzr ci -m "added foo"
$ echo bar > foo
$ bzr shelve --all -m "changed foo to bar"
Changes shelved with id "1".
$ bzr shelve --list
  1: changed foo to bar
$ bzr remove-tree
$ bzr checkout
$ bzr shelve --list
No shelved changes.

I am not sure if this behaviour is intentional or not (i.e., I am not sure if the shelved changes are considered part of the working tree or the branch). In any case, this behaviour is bad: data loss can be caused if someone (e.g., me) runs bzr remove-tree without checking if there were shelved changes, and later realises he had some useful but unfinished changes shelved in that branch.

If the removal of shelved changes is unintentional, then it should be fixed so that running bzr remove-tree does *not* destroy the shelved changes (such that if I run bzr checkout again, my shelf still exists).

Conversely, if the removal of shelved changes is an intended part of the remove-tree operation, it should not happen without warning. Running bzr remove-tree on a branch with shelved changes should print:
bzr: ERROR: Working tree "<path>" has shelved changes (See bzr shelve --list).
(Much like the error you get when you run bzr remove-tree with regular uncommitted changes.)
This should be circumventable with bzr remove-tree --force.

Tags: shelf

Related branches

Revision history for this message
Matt Giuca (mgiuca) wrote :

Also, in the latter case, the usage message for remove-tree should be updated:
  --force Remove the working tree even if it has uncommitted or shelved changes.
(Added "or shelved".)

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

I agree we shouldn't do this unless forced.

Changed in bzr:
importance: Undecided → Medium
status: New → Won't Fix
status: Won't Fix → Confirmed
Revision history for this message
Martin Pool (mbp) wrote :

sorry, misclicked

Revision history for this message
Matt Giuca (mgiuca) wrote :

OK, well here is a patch. remove-tree now refuses to run without --force if there are shelved changes.

I haven't run the full test suite on this, just the remove-tree test suite (and added two new test cases).

Revision history for this message
Matt Giuca (mgiuca) wrote :

Minor fix to the patch; simplified the test cases.

Revision history for this message
Alexander Belchenko (bialix) wrote : Re: [Bug 586639] Re: remove-tree removes shelved changes without warning

Matt Giuca пишет:
> Minor fix to the patch; simplified the test cases.
>
> ** Patch added: "remove-tree.patch"
> http://launchpadlibrarian.net/49247517/remove-tree.patch

Can you publish this change as a branch on LP?

Revision history for this message
Matt Giuca (mgiuca) wrote :

Oops yes. I have added the branch lp:~mgiuca/bzr/remove-tree-shelved and put in a merge request.

Revision history for this message
Eric Siegerman (eric97) wrote :

Marking "Fix Released".

A fix was merged at bzr.dev rev 5282, and first appeared in 2.2b4. I've manually confirmed that "remove-tree" now refuses to remove a tree with shelved changes, unless "--force" is passed.

Changed in bzr:
status: Confirmed → 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.