AssertionError: empty revision for the inv_entry TREE_ROOT when doing "bzr branch -r 1 bzr.dev foo"

Bug #152360 reported by Andrew Bennetts
2
Affects Status Importance Assigned to Milestone
Bazaar
Fix Released
Critical
John A Meinel

Bug Description

With bzr.dev, I cannot branch the first revision of bzr.dev:

andrew@steerpike:~/code/bzr$ bzr --no-plugins branch . /tmp/r1 -r1
bzr: ERROR: exceptions.AssertionError: empty revision for the inv_entry TREE_ROOT.

Traceback (most recent call last):
  File "/home/andrew/code/bzr/bzrlib/commands.py", line 802, in run_bzr_catch_errors
    return run_bzr(argv)
  File "/home/andrew/code/bzr/bzrlib/commands.py", line 758, in run_bzr
    ret = run(*run_argv)
  File "/home/andrew/code/bzr/bzrlib/commands.py", line 492, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/home/andrew/code/bzr/bzrlib/builtins.py", line 893, in run
    possible_transports=[to_transport])
  File "/home/andrew/code/bzr/bzrlib/bzrdir.py", line 835, in sprout
    wt = result.create_workingtree()
  File "/home/andrew/code/bzr/bzrlib/bzrdir.py", line 1106, in create_workingtree
    return self._format.workingtree_format.initialize(self, revision_id)
  File "/home/andrew/code/bzr/bzrlib/workingtree_4.py", line 1289, in initialize
    wt.set_last_revision(revision_id)
  File "/home/andrew/code/bzr/bzrlib/mutabletree.py", line 51, in tree_write_locked
    return unbound(self, *args, **kwargs)
  File "/home/andrew/code/bzr/bzrlib/workingtree_4.py", line 1021, in set_last_revision
    allow_leftmost_as_ghost=True)
  File "/home/andrew/code/bzr/bzrlib/mutabletree.py", line 51, in tree_write_locked
    return unbound(self, *args, **kwargs)
  File "/home/andrew/code/bzr/bzrlib/workingtree_4.py", line 1048, in set_parent_ids
    allow_leftmost_as_ghost=allow_leftmost_as_ghost)
  File "/home/andrew/code/bzr/bzrlib/mutabletree.py", line 51, in tree_write_locked
    return unbound(self, *args, **kwargs)
  File "/home/andrew/code/bzr/bzrlib/workingtree_4.py", line 1074, in set_parent_trees
    dirstate.set_parent_trees(real_trees, ghosts=ghosts)
  File "/home/andrew/code/bzr/bzrlib/dirstate.py", line 1802, in set_parent_trees
    self._inv_entry_to_details(entry)
  File "/home/andrew/code/bzr/bzrlib/dirstate.py", line 1477, in _inv_entry_to_details
    inv_entry.file_id
AssertionError: empty revision for the inv_entry TREE_ROOT.

bzr 0.92.0.dev.0 on python 2.5.1.final.0 (linux2)
arguments: ['/home/andrew/code/bzr/bzr', '--no-plugins', 'branch', '.', '/tmp/r1', '-r1']
encoding: 'UTF-8', fsenc: 'UTF-8', lang: 'en_AU.UTF-8'
plugins:

** Please send this report to <email address hidden>
   with a description of what you were doing when the
   error occurred.
andrew@steerpike:~/code/bzr$

This is a regression from bzr 0.91.

Revision history for this message
Andrew Bennetts (spiv) wrote :

Marking critical because I think it's serious regression.

Changed in bzr:
importance: Undecided → Critical
milestone: none → 0.92
status: New → Confirmed
Revision history for this message
John A Meinel (jameinel) wrote :

Was this introduced by your changes?

I know KnitRepository1 does not have a knit associated with the tree root, while we have one for KnitRepository3.
It may be that when Robert removed the physical KnitRepository3 class, he didn't realize this difference between the two.

Actually, having a knit for the root revision is *why* KR3 is a watershed upgrade. Because once you have one and you do a commit, you start recording different data than you can represent in KR1.

I will agree that this is a critical issue. As it sounds like you cannot branch from a KR1 repo.

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

This isn't a Knit1 versus Knit3 issue. I think it is actually something to do with when the inventory format might have changed.

Doing a bit of manual bisecting the last failing revision seems to be revno 1677.
Specifically, I can do:
bzr branch -r1678 bzr.dev test-1678

but doing
bzr branch -r1677 bzr.dev test-1677

Fails with the same assertion error.
As near as I can tell, that is the first revision that started setting the overall Inventory.revision_id attribute. Specifically doing a diff:

@@ -1,1 +1,1 @@
-<inventory format="5">
+<inventory format="5" <email address hidden>">
...

So I think what is happening is that the deserializer is getting the root revision_id from the wrong location. (It is assuming that the revision_id was serialized and using that for inv.root.revision_id, rather than using the one passed in.)

I'll look into it briefly.

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

This was introduced by Robert's work to unify the RepositoryKnit1 with RepositoryKnit3.

This patch fixes it for me:

=== modified file 'bzrlib/repository.py'
--- bzrlib/repository.py 2007-10-19 04:28:39 +0000
+++ bzrlib/repository.py 2007-10-19 16:27:27 +0000
@@ -1211,7 +1211,10 @@
         :param revision_id: The expected revision id of the inventory.
         :param xml: A serialised inventory.
         """
- return self._serializer.read_inventory_from_string(xml, revision_id)
+ inv = self._serializer.read_inventory_from_string(xml, revision_id)
+ if inv.root.revision is None:
+ inv.root.revision = revision_id
+ return inv

     def serialise_inventory(self, inv):
         return self._serializer.write_inventory_to_string(inv)

We just need to put together a test which ensures that 'deserialise_inventory' handles the format 5a which didn't add the revision_id field for the whole inventory.
(By the way, it is my fault that there are two format 5 inventories, because the revision_id was meant as only a hint, and was not meant to be required. At the time it just fell out of wanting it for somewhere else, and it made sense to have inventories track what revision they were actually at.)

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

There is a fix in the associated branch (with tests).
I went for fixing it in the XML serializer rather than at the Repository level.
we were already passing a hint, we just unilaterally overrode it from the data.

Changed in bzr:
assignee: nobody → jameinel
status: Confirmed → Fix Committed
Revision history for this message
John A Meinel (jameinel) wrote :

submitted as bzr.dev 2924

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