Crash (and corruption?) after reverting an added directory

Greg Ward greg-bzr at gerg.ca
Sun Apr 26 19:56:46 BST 2009


Hi all --

I just provoked a crash with a slightly confusing sequence of
add/mv/revert commands.  Here's the scenario: I have a project with
this layout:
  a.py
  b.py
  sub/c.py

I want to move the code into pkg/ and wind up like this:
  pkg/a.py
  pkg/b.py
  pkg/sub/c.py

Being a Bazaar newbie, I forgot to use "bzr mv" and used plain "mv" by
mistake.  When I tried to correct my mistake, I got in a horrible
sticky mess and now Bazaar is wedged: it always raises an exception in
this branch.

Here's how to reproduce the bug.  It fails the same way with 1.13 and
1.14rc2 (both on Ubuntu intrepid using packages from the bzr PPAs):

# setup initial layout:
bzr init bzrcrash
cd bzrcrash
touch a.py b.py
mkdir sub
touch sub/c.py
bzr add
bzr ci -m"initial revision"

# move code into pkg/, the wrong way
mkdir pkg
mv *.py pkg
mv sub pkg

# oops! I should have used "bzr mv"... try to fix my mistake, take 1
bzr revert .
bzr mv *.py pkg    # "ERROR: Could not move to pkg: pkg is not versioned."

# oops! bzr tracks directories, so I have to add the directory first
bzr add pkg

# oops! that recursively adds all the files already in pkg, so now I have
# a.py and pkg/a.py -- get rid of the duplicates in pkg/
rm pkg/*.py
rm -r pkg/sub

# ok, *now* I can get bzr to move my files, right?
bzr mv *.py pkg          # ERROR: Could not move a.py => a.py: Target
is already versioned.

# argh: just rm'ing the files did not remove them from bzr's radar, of
course. duh.
# rewind again.
bzr revert .

This last "revert" seems to be where everything goes off the rails.
Specifically, the output from that command is

-D  pkg/
-   pkg/a.py
-   pkg/b.py
-   pkg/sub
bzr: ERROR: An inconsistent delta was supplied involving 'pkg/sub',
'sub-20090426182712-gp9wgeideu9o5x1f-4'
reason: The file id was deleted but its children were not deleted.

That's a pretty inscrutable error message to a newbie like me.  But it
gets worse:

bzr status
bzr: ERROR: exceptions.TypeError: 'NoneType' object is unsubscriptable

Traceback (most recent call last):
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line
727, in exception_to_return_code
    return the_callable(*args, **kwargs)
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line
922, in run_bzr
    ret = run(*run_argv)
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line
559, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line
937, in ignore_pipe
    result = func(*args, **kwargs)
  File "/usr/lib/python2.5/site-packages/bzrlib/builtins.py", line 300, in run
    show_pending=(not no_pending), verbose=verbose)
  File "/usr/lib/python2.5/site-packages/bzrlib/status.py", line 118,
in show_tree_status
    want_unversioned=want_unversioned)
  File "/usr/lib/python2.5/site-packages/bzrlib/tree.py", line 97, in
changes_from
    want_unversioned=want_unversioned,
  File "/usr/lib/python2.5/site-packages/bzrlib/decorators.py", line
138, in read_locked
    result = unbound(self, *args, **kwargs)
  File "/usr/lib/python2.5/site-packages/bzrlib/tree.py", line 876, in compare
    want_unversioned=want_unversioned)
  File "/usr/lib/python2.5/site-packages/bzrlib/delta.py", line 230,
in _compare_trees
    want_unversioned=want_unversioned):
  File "_dirstate_helpers_c.pyx", line 1350, in
_dirstate_helpers_c.ProcessEntryC.__next__
  File "_dirstate_helpers_c.pyx", line 1609, in
_dirstate_helpers_c.ProcessEntryC._iter_next
  File "_dirstate_helpers_c.pyx", line 1263, in
_dirstate_helpers_c.ProcessEntryC._process_entry
TypeError: 'NoneType' object is unsubscriptable

bzr 1.14rc2 on python 2.5.2 (linux2)
arguments: ['/usr/bin/bzr', 'st']
encoding: 'UTF-8', fsenc: 'UTF-8', lang: 'en_CA.utf8'
plugins:
  launchpad
/usr/lib/python2.5/site-packages/bzrlib/plugins/launchpad [unknown]
  netrc_credential_store
/usr/lib/python2.5/site-packages/bzrlib/plugins/netrc_credential_store
[unknown]
*** Bazaar has encountered an internal error.
    Please report a bug at https://bugs.launchpad.net/bzr/+filebug
    including this traceback, and a description of what you
    were doing when the error occurred.

Now this branch is hosed: most commands fail with the above stack
trace.  "bzr check" blows up with

Checking working tree at 'file:///tmp/bzr-fastimport/'.
bzr: ERROR: exceptions.AssertionError: no parent entry for:
fastimport/__init__.py in tree 0

Traceback (most recent call last):
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line
727, in exception_to_return_code
    return the_callable(*args, **kwargs)
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line
922, in run_bzr
    ret = run(*run_argv)
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line
559, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/usr/lib/python2.5/site-packages/bzrlib/builtins.py", line 2956, in run
    check_dwim(path, verbose, do_branch=branch, do_repo=repo, do_tree=tree)
  File "/usr/lib/python2.5/site-packages/bzrlib/check.py", line 299,
in check_dwim
    tree._check()
  File "/usr/lib/python2.5/site-packages/bzrlib/decorators.py", line
138, in read_locked
    result = unbound(self, *args, **kwargs)
  File "/usr/lib/python2.5/site-packages/bzrlib/workingtree.py", line
2525, in _check
    self._validate()
  File "/usr/lib/python2.5/site-packages/bzrlib/decorators.py", line
138, in read_locked
    result = unbound(self, *args, **kwargs)
  File "/usr/lib/python2.5/site-packages/bzrlib/workingtree_4.py",
line 1283, in _validate
    self._dirstate._validate()
  File "/usr/lib/python2.5/site-packages/bzrlib/dirstate.py", line
2790, in _validate
    check_valid_parent()
  File "/usr/lib/python2.5/site-packages/bzrlib/dirstate.py", line
2724, in check_valid_parent
    % (this_path, tree_index))
AssertionError: no parent entry for: fastimport/__init__.py in tree 0

Questions:
  * is this a known bug? or should I file a bug report?
  * how can I recover my working branch and get back to work?

Thanks!

Greg



More information about the bazaar mailing list