NotImplementedError(_PreviewTree.inventory) when unshelving must create the parent directory

Bug #389674 reported by John Bachir
42
This bug affects 7 people
Affects Status Importance Assigned to Milestone
Bazaar
Fix Released
Medium
John A Meinel

Bug Description

when trying to unshelve changes, I got the below exception.

This was after a lot of uncommitting and reverting in the branch in question, I don't know if that could be a factor.

$ bzr unshelve
Unshelving changes with id "2".
bzr: ERROR: exceptions.NotImplementedError: <property object at 0x7b9bc0>

Traceback (most recent call last):
  File "/Library/Python/2.5/site-packages/bzrlib/commands.py", line 729, in exception_to_return_code
    return the_callable(*args, **kwargs)
  File "/Library/Python/2.5/site-packages/bzrlib/commands.py", line 924, in run_bzr
    ret = run(*run_argv)
  File "/Library/Python/2.5/site-packages/bzrlib/commands.py", line 560, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/Library/Python/2.5/site-packages/bzrlib/builtins.py", line 5479, in run
    Unshelver.from_args(shelf_id, action).run()
  File "/Library/Python/2.5/site-packages/bzrlib/shelf_ui.py", line 305, in run
    merger.do_merge()
  File "/Library/Python/2.5/site-packages/bzrlib/merge.py", line 495, in do_merge
    self._do_merge_to(merge)
  File "/Library/Python/2.5/site-packages/bzrlib/merge.py", line 467, in _do_merge_to
    merge.do_merge()
  File "/Library/Python/2.5/site-packages/bzrlib/merge.py", line 606, in do_merge
    self._compute_transform()
  File "/Library/Python/2.5/site-packages/bzrlib/merge.py", line 661, in _compute_transform
    lambda t, c: conflict_pass(t, c, self.other_tree))
  File "/Library/Python/2.5/site-packages/bzrlib/transform.py", line 2556, in resolve_conflicts
    new_conflicts.update(pass_func(tt, conflicts))
  File "/Library/Python/2.5/site-packages/bzrlib/merge.py", line 661, in <lambda>
    lambda t, c: conflict_pass(t, c, self.other_tree))
  File "/Library/Python/2.5/site-packages/bzrlib/transform.py", line 2632, in conflict_pass
    if path_tree.inventory[file_id].parent_id is None:
  File "/Library/Python/2.5/site-packages/bzrlib/transform.py", line 1670, in inventory
    raise NotImplementedError(_PreviewTree.inventory)
NotImplementedError: <property object at 0x7b9bc0>

bzr 1.16 on python 2.5.1 (darwin)
arguments: ['/usr/local/bin/bzr', 'unshelve']
encoding: 'UTF-8', fsenc: 'utf-8', lang: 'en_US.UTF-8'
plugins:
  launchpad /Library/Python/2.5/site-packages/bzrlib/plugins/launchpad [1.16]
  netrc_credential_store /Library/Python/2.5/site-packages/bzrlib/plugins/netrc_credential_store [1.16]

Related branches

description: updated
Revision history for this message
Aaron Bentley (abentley) wrote : Re: [Bug 389674] [NEW] exception encountered when unshelving

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

John Bachir wrote:
> Public bug reported:
>
> when trying to unshelve changes, I got the below exception.
>
> This was after a lot of uncommitting and reverting in the branch in
> question, I don't know if that could be a factor.

This is because the conflict handling code has not been fully updated to
 avoid using Tree.inventory.

Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkpgAi0ACgkQ0F+nu1YWqI225gCeJbmmn05Yd9YRHcwn2cbj6C4h
3ZQAnibLHcEKB+I5LBwSFNqotdJo/csP
=ibwW
-----END PGP SIGNATURE-----

Revision history for this message
Paul Hinze (phinze) wrote : Re: exception encountered when unshelving

Same problem here on bzr 2.0.0

Unshelving changes with id "1".
bzr: ERROR: exceptions.NotImplementedError: <property object at 0x97b370c>

Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/bzrlib/commands.py", line 842, in exception_to_return_code
    return the_callable(*args, **kwargs)
  File "/usr/lib/python2.6/site-packages/bzrlib/commands.py", line 1037, in run_bzr
    ret = run(*run_argv)
  File "/usr/lib/python2.6/site-packages/bzrlib/commands.py", line 654, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/usr/lib/python2.6/site-packages/bzrlib/builtins.py", line 5699, in run
    unshelver.run()
  File "/usr/lib/python2.6/site-packages/bzrlib/shelf_ui.py", line 399, in run
    merger.do_merge()
  File "/usr/lib/python2.6/site-packages/bzrlib/merge.py", line 508, in do_merge
    self._do_merge_to(merge)
  File "/usr/lib/python2.6/site-packages/bzrlib/merge.py", line 480, in _do_merge_to
    merge.do_merge()
  File "/usr/lib/python2.6/site-packages/bzrlib/merge.py", line 619, in do_merge
    self._compute_transform()
  File "/usr/lib/python2.6/site-packages/bzrlib/merge.py", line 674, in _compute_transform
    lambda t, c: conflict_pass(t, c, self.other_tree))
  File "/usr/lib/python2.6/site-packages/bzrlib/transform.py", line 2633, in resolve_conflicts
    new_conflicts.update(pass_func(tt, conflicts))
  File "/usr/lib/python2.6/site-packages/bzrlib/merge.py", line 674, in <lambda>
    lambda t, c: conflict_pass(t, c, self.other_tree))
  File "/usr/lib/python2.6/site-packages/bzrlib/transform.py", line 2709, in conflict_pass
    if path_tree.inventory[file_id].parent_id is None:
  File "/usr/lib/python2.6/site-packages/bzrlib/transform.py", line 1706, in inventory
    raise NotImplementedError(_PreviewTree.inventory)
NotImplementedError: <property object at 0x97b370c>

bzr 2.0.0 on python 2.6.4 (Linux-2.6.31-ARCH-i686-Intel-R-_Core-TM-2_Duo_CPU_T9500_@_2.60GHz-with-glibc2.0)
arguments: ['/usr/bin/bzr', 'usv']
encoding: 'UTF-8', fsenc: 'UTF-8', lang: 'en_US.UTF-8'
plugins:
  bzrtools /usr/lib/python2.6/site-packages/bzrlib/plugins/bzrtools [2.0.1]
  dontcommit /home/phinze/.bazaar/plugins/dontcommit [unknown]
  extmerge /home/phinze/.bazaar/plugins/extmerge [unknown]
  gtk /usr/lib/python2.6/site-packages/bzrlib/plugins/gtk [0.97.0.final]
  interactive /home/phinze/.bazaar/plugins/interactive [1.2.0]
  launchpad /usr/lib/python2.6/site-packages/bzrlib/plugins/launchpad [2.0.0]
  netrc_credential_store /usr/lib/python2.6/site-packages/bzrlib/plugins/netrc_credential_store [2.0.0]
  protect /usr/lib/python2.6/site-packages/bzrlib/plugins/protect [unknown]
  rebase /home/phinze/.bazaar/plugins/rebase [0.5.4dev]
  rmbr /home/phinze/.bazaar/plugins/rmbr [unknown]
  scmproj /home/phinze/.bazaar/plugins/scmproj [0.4.5]

Revision history for this message
John A Meinel (jameinel) wrote : Re: [Bug 389674] Re: exception encountered when unshelving

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Paul Hinze wrote:
> Same problem here on bzr 2.0.0
>
> Unshelving changes with id "1".
> bzr: ERROR: exceptions.NotImplementedError: <property object at 0x97b370c>
...

> File "/usr/lib/python2.6/site-packages/bzrlib/transform.py", line 2709, in conflict_pass
> if path_tree.inventory[file_id].parent_id is None:
> File "/usr/lib/python2.6/site-packages/bzrlib/transform.py", line 1706, in inventory
> raise NotImplementedError(_PreviewTree.inventory)
> NotImplementedError: <property object at 0x97b370c>

This conflict happens during:
          elif c_type == 'unversioned parent':

Which seems to say that a directory was removed. I can't tell whether
you shelved the deletion of a directory, and then added a new file. Or
whether you shelved changes to a file, and then deleted the directory.
Anyway, it might help to make it easier to track down under what
conditions it takes to trigger this.

Of course, that specific line claims that it is just trying to find out
if the given unversioned parent is the 'tree root', which could be more
easily found with:

if file_id == path_tree.path2id(''):

And doesn't have to access a '.inventory' member, and might make things
work again.

Care to try that one-line change and see if it fixes things for you?

John
=:->

 status confirmed
 importance medium
 tags shelve
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAksgIA4ACgkQJdeBCYSNAAMUuwCgxzI0snWDM7IHXwl8ZrOQMdX3
ObgAoLh747aEPI52DZ3rHQi/PGWGIo3Y
=OgM+
-----END PGP SIGNATURE-----

Changed in bzr:
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
Russ Brown (pickscrape) wrote : Re: exception encountered when unshelving

Attached is a script that reproduces this bug for me using bzr 2.1.0

The crux of it appears to be when unshelve attempts to create new files under a directory that does not exist in the working tree and is not the exact same directory that bzr knows as being the parent of the unshelved files.

The script includes a couple of commented out lines which demonstrate that adding the directory before attempting to unshelve doesn't work around the problem.

Revision history for this message
John Bachir (johnjosephbachir) wrote :

NICE!

Martin Pool (mbp)
summary: - exception encountered when unshelving
+ NotImplementedError(_PreviewTree.inventory) when unshelving must create
+ the parent directory
tags: added: shelf treetransform
Revision history for this message
John Bachir (johnjosephbachir) wrote :

I just experienced this problem again in 2.1.1 on os x, and it does indeed seem to be a result of the scenario described by Russ Brown.

Revision history for this message
Russ Brown (pickscrape) wrote :

I just had a play with what john suggested with no luck. This is currently keeping quite a bit of code stuck on my shelf that I really don't want to have to write again. :)

Is there anything I can do as a workaround to this to get at it?

Revision history for this message
Russ Brown (pickscrape) wrote :

Following on from an IRC discussion with John, my most recent case was as a result of attempting to unshelve to a different branch (in a lightweight checkout) to the branch that the shelve was originally performed on.

John mentioned that there is a "required revision ID" that the shelf will reference, and it may be that it not be finding it. In my case, both branches involved are in the same shared repository, so the revision should be available regardless of the branch that is currently checked out. So it may be that it is only looking at revisions in the branch ancestry.

Another way of looking at it is that what I was basically trying to do was perform a merge --uncommitted from the original branch (with the shelved content as uncommitted changes) to the second branch. I'm not sure if that implies that unshelve may need to potentially use another code path or not in some cases.

Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

Quick confirmations:
- the steps to reproduce are similar in my case, shelves changes to a directory and then remove it before unshelving
- the suggested patch from John A Meinel in comment #3 do indeed solve the issue for my cases (actual patch attached)

My work has been freed from the shelve, thank you John! :-)

Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

Wow that was quite a lot of typos in my previous comment, doesn't even look like english. Sorry about that! (wish LP would allow editing comments during some sort of grace period)

Revision history for this message
John A Meinel (jameinel) wrote :

2 things

1) I would probably pull the path2id() check out of the loop with a "root_id = tree.path2id('')" that way it doesn't have
  to happen over and over.
2) Could you submit this as a merge proposal rather than just a patch?

John A Meinel (jameinel)
Changed in bzr:
assignee: nobody → John A Meinel (jameinel)
status: Confirmed → In Progress
John A Meinel (jameinel)
Changed in bzr:
milestone: none → 2.3b5
status: In Progress → Fix Released
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.