Comment 6 for bug 295161

Revision history for this message
Mattias Jonsson (mattias-jonsson) wrote :

Hi, here is a repeatable scenario (at least on my setup):

Preparation:
Use a Mac OS X machine with bzr, bzr-gtk and bzrtools installed by macport
So that bzr gcommit is running under X11 on the Mac

send a mail consisting of these rows:
Aper-file

Bper-file

Cglobal

Dglobal

and open that in Thunderbird.

Create a change and run 'bzr gcommit'
(bzr init-repo test, cd test, mkdir testdir, cd testdir, bzr init, echo "simple file" > testfile, bzr add testfile, bzr gcommit)
Then mark and copy (cmd-c) the three rows in the mail open in Thunderbird:
Cglobal

Dglobal

and click in the Global Commit Message text area and paste with (ctrl-v).
Move the cursor to the empty row, and delete that empty row (by deleting the character to the right of the cursor, i.e. NOT using backspace)

Do the same with the "Aper-file.." rows to the Commit message for testfile.

press commit.

Explanation:
When copying from thunderbird, the string will be "Cglobal\r\rDglobal", and by deleting the empty row with 'forward delete' and add a new empty line in bzr gcommit/X11 it will become "Cglobal\r\nDglobal".

All seems well in the repository, when it displays as unicode, but when trying bzr visualize it will print out:
testdir$ bzr visualize
Traceback (most recent call last):
  File "/Users/mattiasj/.bazaar/plugins/gtk/revisionview.py", line 371, in do_set_property
    self._set_revision(value)
  File "/Users/mattiasj/.bazaar/plugins/gtk/revisionview.py", line 428, in _set_revision
    file_info = bdecode(file_info.encode('UTF-8'))
  File "/opt/local/lib/python2.5/site-packages/bzrlib/util/bencode.py", line 85, in bdecode
    r, l = decode_func[x[0]](x, 0)
  File "/opt/local/lib/python2.5/site-packages/bzrlib/util/bencode.py", line 53, in decode_list
    v, f = decode_func[x[f]](x, f)
  File "/opt/local/lib/python2.5/site-packages/bzrlib/util/bencode.py", line 61, in decode_dict
    k, f = decode_string(x, f)
  File "/opt/local/lib/python2.5/site-packages/bzrlib/util/bencode.py", line 44, in decode_string
    n = long(x[f:colon])
ValueError: invalid literal for long() with base 10: ''

when debuggin bzrlib/repository.py:
> /opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/bzrlib/repository.py(1148)_get_revisions()
-> revs[record.key[0]] = rev
(Pdb) p text
'<revision committer="Mattias Jonsson &lt;<hidden>@sun.com&gt;" format="5" inventory_sha1="3f7f86a25f3b78ec301ecb1a44c100bd617a1eeb" <email address hidden>" timestamp="1226403127.806" timezone="3600">\n<message>Cglobal\r\nDglobal</message>\n<properties><property name="branch-nick">testdir</property>\n<property name="file-info">ld7:file_id42:testfile-20081111112927-ubq1w7b7xonhsrzj-17:message20:Aper-file\r\nBper-file4:path8:testfileee</property>\n</properties>\n</revision>\n'
(Pdb) p rev
<Revision id <hidden>@sun.com-20081111113207-76v7wbhcppftz05x>

Here is the string as entered "Cglobal\r\nDglobal" and "Aper-file\r\nBper-file" with length 20.

(Pdb) p rev.properties
{'file-info': 'ld7:file_id42:testfile-20081111112927-ubq1w7b7xonhsrzj-17:message20:Aper-file\nBper-file4:path8:testfileee', 'branch-nick': 'testdir'}

Here has the file message been converted, but its length has not been updated! ("Aper-file\nBper-file" still has length 20, not 19!!! which causes failure later when trying to decode the list.

Versions:
Bazaar (bzr) 1.9
bzr plugins
bzrtools 1.9.1
    Various useful commands for working with bzr.

difftools 0.91.0
    External diff tools plugin for Bazaar

extmerge
    external merge plugin for bzr

gtk 0.96.0dev1
    Graphical support for Bazaar using GTK.

launchpad
    Launchpad.net integration plugin for Bazaar.