'bzr annotate file.OTHER' during contents conflict gives traceback

Bug #246573 reported by Sven Sandberg
2
Affects Status Importance Assigned to Milestone
Bazaar
Fix Released
Medium
Robert Collins

Bug Description

If I modify 'file' in branch_a and delete 'file' in branch_b, then go to branch_b and merge, it gives me 'file.BASE' and 'file.OTHER'. Then, if I run 'bzr annotate file.OTHER', it crashes with a stacktrace.

######## BEGIN SCRIPT TO REPRODUCE ########
echo ==== system info ====
bzr version

echo ==== init ===
rm -rf test-area
mkdir test-area
cd test-area
mkdir a
cd a
bzr init

echo ==== first version of foo ===
echo 1 > foo
bzr add foo
bzr commit -m 'first version of foo'

echo ==== create branch b ===
cd ..
bzr branch a b

echo ==== modify foo in a ===
cd a
echo 2 >> foo
bzr commit -m 'second version of foo'

echo ==== remove foo in b ===
cd ../b
bzr rm foo
bzr commit -m 'removed foo'

echo ==== merge ====
bzr merge ../a
ls
echo ==== annotating foo ====
bzr annotate foo
echo ==== annotating foo.OTHER ====
bzr annotate foo.OTHER
######## END SCRIPT TO REPRODUCE ########

######## BEGIN OUTPUT OF SCRIPT ########
==== system info ====
Bazaar (bzr) 1.5
  Python interpreter: /usr/bin/python 2.5.2
  Python standard library: /usr/lib/python2.5
  bzrlib: /usr/lib/python2.5/site-packages/bzrlib
  Bazaar configuration: /home/sven/.bazaar
  Bazaar log file: /home/sven/.bzr.log

Copyright 2005, 2006, 2007, 2008 Canonical Ltd.
http://bazaar-vcs.org/

bzr comes with ABSOLUTELY NO WARRANTY. bzr is free software, and
you may use, modify and redistribute it under the terms of the GNU
General Public License version 2 or later.

==== init ===
==== first version of foo ===
added foo
Committing to: /home/sven/bzr/bzrtest/bzr-annotate-crash/test-area/a/
added foo
Committed revision 1.
==== create branch b ===
Branched 1 revision(s).
==== modify foo in a ===
Committing to: /home/sven/bzr/bzrtest/bzr-annotate-crash/test-area/a/
modified foo
Committed revision 2.
==== remove foo in b ===
deleted foo
Committing to: /home/sven/bzr/bzrtest/bzr-annotate-crash/test-area/b/
deleted foo
Committed revision 2.
==== merge ====
+N foo.OTHER
Contents conflict in foo
1 conflicts encountered.
foo.BASE foo.OTHER
==== annotating foo ====
bzr: ERROR: foo is not versioned.
==== annotating foo.OTHER ====
bzr: ERROR: The file id "foo-20080708125540-yojm5a17not7rn14-1" is not present in the tree <Inventory object at 8b02e6c, contents={'TREE_ROOT': InventoryDirectory('TREE_ROOT', u'', parent_id=None, <email address hidden>')}>.
######## END OUTPUT OF SCRIPT ########

######## BEGIN ~/.bzr.log ########
0.231 encoding stdout as sys.stdout encoding 'UTF-8'
0.231 bzr arguments: [u'annotate', u'foo.OTHER']
0.231 looking for plugins in /home/sven/.bazaar/plugins
0.393 looking for plugins in /usr/lib/python2.5/site-packages/bzrlib/plugins
0.393 Plugin name __init__ already loaded
0.393 Plugin name bzrtools already loaded
0.393 Plugin name __init__ already loaded
0.547 opening working tree '/home/sven/bzr/bzrtest/bzr-annotate-crash/test-area/b'
0.601 Traceback (most recent call last):
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 846, in run_bzr_catch_errors
    return run_bzr(argv)
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 797, in run_bzr
    ret = run(*run_argv)
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 499, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 807, in ignore_pipe
    result = func(*args, **kwargs)
  File "/usr/lib/python2.5/site-packages/bzrlib/builtins.py", line 3516, in run
    file_version = tree.inventory[file_id].revision
  File "/usr/lib/python2.5/site-packages/bzrlib/inventory.py", line 1047, in __getitem__
    raise errors.NoSuchId(self, file_id)
NoSuchId: The file id "foo-20080708125540-yojm5a17not7rn14-1" is not present in the tree <Inventory object at 8b02e6c, contents={'TREE_ROOT': InventoryDirectory('TREE_ROOT', u'', parent_id=None, <email address hidden>')}>.

0.602 return code 3
######## END ~/.bzr.log ########

Tags: mysql
Revision history for this message
James Westby (james-w) wrote :

Hi,

Thanks for the test script, I can reproduce easily, and it's half way
to a test case.

This will either be really easy to fix, or pretty tricky. Hopefully the
former.

Thanks,

James

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

If I was to make a quick guess...

The problem is that "bzr annotate foo" actually annotates the last committed version, and not the working tree. (Note that 'bzr gannotate' does the right thing.) We have all the functionality to do the right thing, just the cmd_annotate code is a bit crufty, so it was hard to switch it to call the right api, without breaking backwards compatibility. (When I've started a couple times, I always ended up trying to rewrite too much, which meant it never progressed when other things needed to be done.)

So my guess is that the file is deleted in the basis tree, and so it has no text to annotate.

Revision history for this message
Sven Sandberg (sven-mysql) wrote :

The problem exists also in 'bzr cat'. I.e., if you replace 'bzr annotate' by 'bzr cat' in the script above, it crashes in the same way.

If you could make 'bzr annotate' annotate the working tree, that would be a huge improvement. Not just because it fixes this bug, but because it would annotate conflicted files during a merge. That is extremely useful when resolving conflicts caused by other people, as you can just copy and paste the annotated conflict to an email and send that to the persons responsible for the conflict. This is something I need every time I merge over here at MySQL. (I'm currently achieving this in a dirty way, using a perl script that merges, commits the files with conflict markers and everything, annotates the conflicted files, uncommits, reverts, and merges again. Would be great if I didn't have to do that.)

Revision history for this message
Martin Pool (mbp) wrote :

This may now be fixed in bzr.dev (pre 1.8) at least for annotate because of the change to include the working copy in the annotation. We should re-test it.

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

If you want to open another bug for 'bzr cat' you can. In 1.8, bzr will annotate the working tree directly.
Note also that 'bzr gannotate' was already annotating the working tree, in case that helps before 1.8 is released.

Changed in bzr:
assignee: nobody → lifeless
milestone: none → 1.8
status: Confirmed → 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.