unshelving new file fails if its directory has been committed since shelving

Bug #850594 reported by everybody
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Bazaar
Confirmed
High
Unassigned
Breezy
Triaged
Medium
Unassigned

Bug Description

If I create new files in new subdirectories, and then want to commit the changes to the directory structure separately from the changes to the actual files, by shelving the files, committing the added directories, and then unshelving the new files to commit, bzr raises an exception, leaving the new files inaccessible on the shelf.

Minimal steps to reproduce:

# in a clean working directory
mkdir dir/
echo "this line represents editing" >> dir/file
bzr add
bzr shelve -m "work on file" dir/file
# Shelve adding file "dir/file"? [yNfq?] y
# Shelve adding file "dir"? [yNfq?] n
# Selected changes:
# -D dir/file
# Shelve 1 change(s)? [yNfq?] y
bzr ci -m "setup dir"
bzr unshelve

Expected outcome: the new file is unshelved successfully.

Actual outcome:
Using changes with id "1".
Message: work on file
bzr: ERROR: No final name for trans_id 'new-2'
file-id: 'dir-20110915030501-qxj7l1zjc3xx5tq7-1'
root trans-id: 'new-0'

For my current situation (a number of files stuck in shelf purgatory, impeding work progress):
* Is it somehow possible to get back the shelved changes within the facilities of bzr (e.g. unwinding the add, commit and shelve), or will I have to resort to manually fiddling them out of .bzr/checkout/shelf/shelf-1?
* If I do manually recreate the files, do I have to keep anything in mind to avoid corrupting the repository?
* How do I then get rid of the broken shelf?

For the future, what is the recommended workflow to get new files committed separately from their directories?

Revision history for this message
everybody (evrybod) wrote :

I'm using
Bazaar: version 2.4.0
Python: version 2.6.5
Platform: Linux-2.6.32-33-generic-i686-with-Ubuntu-10.04-lucid

Here's the traceback from the Bazaar log file:

modules/python2.6/bzrlib/cleanup.py", line 165, in _do_with_cleanups
    result = func(*args, **kwargs)
  File "/usr/lib/pymodules/python2.6/bzrlib/builtins.py", line 6138, in run
    unshelver.run()
  File "/usr/lib/pymodules/python2.6/bzrlib/shelf_ui.py", line 479, in run
    merger = unshelver.make_merger(None)
  File "/usr/lib/pymodules/python2.6/bzrlib/shelf.py", line 332, in make_merger
    target_tree = self.transform.get_preview_tree()
  File "/usr/lib/pymodules/python2.6/bzrlib/transform.py", line 1022, in get_preview_tree
    return _PreviewTree(self)
  File "/usr/lib/pymodules/python2.6/bzrlib/transform.py", line 1997, in __init__
    self._transform.iter_changes())
  File "/usr/lib/pymodules/python2.6/bzrlib/transform.py", line 997, in iter_changes
    to_path = final_paths.get_path(to_trans_id)
  File "/usr/lib/pymodules/python2.6/bzrlib/transform.py", line 2473, in get_path
    self._known_paths[trans_id] = self._determine_path(trans_id)
  File "/usr/lib/pymodules/python2.6/bzrlib/transform.py", line 2468, in _determine_path
    return pathjoin(self.get_path(parent_id), name)
  File "/usr/lib/pymodules/python2.6/bzrlib/transform.py", line 2473, in get_path
    self._known_paths[trans_id] = self._determine_path(trans_id)
  File "/usr/lib/pymodules/python2.6/bzrlib/transform.py", line 2463, in _determine_path
    name = self.transform.final_name(trans_id)
  File "/usr/lib/pymodules/python2.6/bzrlib/transform.py", line 509, in final_name
    raise NoFinalPath(trans_id, self)
NoFinalPath: No final name for trans_id 'new-2'
file-id: 'dir-20110915030501-qxj7l1zjc3xx5tq7-1'
root trans-id: 'new-0'

Revision history for this message
everybody (evrybod) wrote :

Here is a workaround, thanks to poolie and vila on the #bzr IRC channel:

Instead of adding the new file and then shelving it, simply do not add it in the first place (using "bzr add --no-recurse").

So, with the setup from above, after editing your file, simply do

bzr add --no-recurse dir
bzr ci -m "setup dir"
bzr add dir/file
bzr ci -m "work on file"

instead of

# DON'T DO THIS
bzr add
bzr shelve -m "work on file" dir/file
bzr ci -m "setup dir"
bzr unshelve

Revision history for this message
Vincent Ladeuil (vila) wrote :

Reproduced locally, thanks for the nice recipe.

Changed in bzr:
importance: Undecided → High
status: New → Confirmed
Jelmer Vernooij (jelmer)
tags: added: check-for-breezy
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

Still reproducible in breezy.

Changed in brz:
status: New → Triaged
importance: Undecided → Medium
tags: added: traceback
removed: check-for-breezy
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.