bzr mv should handle and report failure better
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Bazaar |
Confirmed
|
Medium
|
Unassigned | ||
Breezy |
Triaged
|
High
|
Unassigned |
Bug Description
The Problem
~~~~~~~~~
I was using bzr 1.0 on windows.
I had a branch similar as follows:
branch-dir
- child-dir
- foo.h
- foo.cpp
- bar.h
- bar.cpp
- baz.h
- baz.cpp
So running the following produced:
$ bzr mv foo.h foo.cpp bar.h bar.h baz.h baz.cpp child-dir
bzr: ERROR: Could not move bar.h => child-dir: bar.h is not versioned.
My first guess was that nothing happened and that I needed to modify my command, but when I edited and ran the following:
$ bzr mv foo.h foo.cpp bar.h bar.cpp baz.h baz.cpp child-dir
bzr: ERROR: Could not move foo.h => child-dir: foo.h is not versioned.
So then I ran bzr status to see what was going on:
$ bzr status
renamed:
bar.h => child-dir/bar.h
foo.cpp => child-dir/foo.cpp
foo.h => child-dir/foo.h
so, then I realized what happened - it processed the move of my files up to a point, then quit.
Cognitive Dissonance
~~~~~~~~~~~~~~~~
Due to insufficient reporting, I assumed the command as a whole had failed. However, it makes sense from an implementation perspective that it would work until it couldn't.
From my perspective, I expected bzr mv would inform me that it had done /something/ successfully while other things unsuccessfully.
Since some of my move request was processed, I would expect that it would continue trying to process the rest of my command even if it encountered some errors. Plus, since my "error" was actually a duplicate file name, I wouldn't expect to see an error at all.
What I Expected
~~~~~~~~~~~~
So, if I would have ran the following command with my original branch above, I would expect to see:
$ bzr mv foo.h foo.cpp bar.h bar.h baz.h baz.cpp makebelieve.txt child-dir
renamed:
bar.h => child-dir/bar.h
baz.cpp => child-dir/baz.cpp
baz.h => child-dir/baz.h
foo.cpp => child-dir/foo.cpp
foo.h => child-dir/foo.h
failed to rename (does not exist):
makebelieve.txt
duplicate argument:
foo.h
description: | updated |
Changed in bzr: | |
milestone: | 1.4 → none |
Changed in bzr: | |
status: | Triaged → Confirmed |
tags: | added: mv ui |
tags: | added: check-for-breezy |
tags: | removed: check-for-breezy |
Changed in brz: | |
status: | New → Triaged |
importance: | Undecided → High |
I agree that bzr should report about already moved things until it encounters error. But I don't think bzr should continue to work if some error encountered. So I'd like to fix reporting problem rather than made all moves independent.
To fix problem with reporting I think we should extent arguments of tree.move() method with one optional argument `report`. This argument could be a list object to accumulate finished moves info. So if error will be raised command mv still will be able to get report and show it in finally block. Something like this:
# move into existing directory move(rel_ names[: -1], rel_names[-1], after=after, report=report)
self.outf. write(" %s => %s\n" % pair)
report = []
try:
tree.
finally:
for pair in report:
IMO it will be simplier to implementing and testing. But will require additional tests in bzrlib/ tests/workingtr ee_implementati ons/
Spencer, do you want to rework your patch in this way? If not I'll do it.