bzr send => "File is binary but should be text"

Bug #665662 reported by Johan Walles on 2010-10-23
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Bazaar Subversion Plugin
Medium
Jelmer Vernooij

Bug Description

johan@johansdator:~/src/ScandinavianKeyboard$ bzr send -o /tmp/markov-proof-of-concept.patch
Using saved parent location "http://scandinavian-keyboard.googlecode.com/svn/trunk" to determine what changes to submit.
bzr: ERROR: File is binary but should be text.

Which file is binary? How did things get this way? What could I potentially do about it?

johan@johansdator:~/src/ScandinavianKeyboard$ bzr --version
Bazaar (bzr) 2.1.2
  Python interpreter: /usr/bin/python 2.6.6
  Python standard library: /usr/lib/python2.6
  Platform: Linux-2.6.32-5-686-i686-with-debian-squeeze-sid
  bzrlib: /usr/lib/python2.6/dist-packages/bzrlib
  Bazaar configuration: /home/johan/.bazaar
  Bazaar log file: /home/johan/.bzr.log

johan@johansdator:~/src/ScandinavianKeyboard$ bzr send -Derror -o /tmp/markov-proof-of-concept.patch
Using saved parent location "http://scandinavian-keyboard.googlecode.com/svn/trunk" to determine what changes to submit.
bzr: ERROR: bzrlib.errors.BinaryFile: File is binary but should be text.

Traceback (most recent call last):
  File "/usr/lib/python2.6/dist-packages/bzrlib/commands.py", line 853, in exception_to_return_code
    return the_callable(*args, **kwargs)
  File "/usr/lib/python2.6/dist-packages/bzrlib/commands.py", line 1055, in run_bzr
    ret = run(*run_argv)
  File "/usr/lib/python2.6/dist-packages/bzrlib/commands.py", line 661, in run_argv_aliases
    return self.run_direct(**all_cmd_args)
  File "/usr/lib/python2.6/dist-packages/bzrlib/commands.py", line 665, in run_direct
    return self._operation.run_simple(*args, **kwargs)
  File "/usr/lib/python2.6/dist-packages/bzrlib/cleanup.py", line 122, in run_simple
    self.cleanups, self.func, *args, **kwargs)
  File "/usr/lib/python2.6/dist-packages/bzrlib/cleanup.py", line 156, in _do_with_cleanups
    result = func(*args, **kwargs)
  File "/usr/lib/python2.6/dist-packages/bzrlib/builtins.py", line 5146, in run
    strict=strict)
  File "/usr/lib/python2.6/dist-packages/bzrlib/send.py", line 133, in send
    public_branch, no_patch, no_bundle, message, base_revision_id)
  File "/usr/lib/python2.6/dist-packages/bzrlib/plugins/svn/send.py", line 206, in send_svn
    public_branch=public_branch, message=message)
  File "/usr/lib/python2.6/dist-packages/bzrlib/plugins/svn/send.py", line 194, in from_objects
    revision_id, ancestor_id)
  File "/usr/lib/python2.6/dist-packages/bzrlib/plugins/svn/send.py", line 174, in _generate_diff
    differ.show_diff(None, None)
  File "/usr/lib/python2.6/dist-packages/bzrlib/diff.py", line 889, in show_diff
    return self._show_diff(specific_files, extra_trees)
  File "/usr/lib/python2.6/dist-packages/bzrlib/plugins/svn/send.py", line 154, in _show_diff
    self._write_contents_diff(newpath_encoded, old_version, [], new_version, new_contents)
  File "/usr/lib/python2.6/dist-packages/bzrlib/plugins/svn/send.py", line 78, in _write_contents_diff
    self.to_file)
  File "/usr/lib/python2.6/dist-packages/bzrlib/diff.py", line 93, in internal_diff
    textfile.check_text_lines(newlines)
  File "/usr/lib/python2.6/dist-packages/bzrlib/textfile.py", line 42, in check_text_lines
    raise BinaryFile()
BinaryFile: File is binary but should be text.

Related branches

Andrew Bennetts (spiv) wrote :

I see the bzr-svn plugin is significantly involved in that traceback, e.g.:

> File "/usr/lib/python2.6/dist-packages/bzrlib/plugins/svn/send.py", line 78, in _write_contents_diff

What happens if you try “bzr --no-plugins send -o /tmp/markov-proof-of-concept.patch”?

Changed in bzr:
status: New → Incomplete
Johan Walles (walles) wrote :

Hi Andrew!

See below for the result of your command line. If you want to do further tests, the complete project is attached to this issue:
https://bugs.launchpad.net/bzr/+bug/665662/+attachment/1708411/+files/repro.tar.gz

johan@johansdator:~/src/ScandinavianKeyboard$ bzr -Derror --no-plugins send -o /tmp/markov-proof-of-concept.patch
Using saved parent location "http://scandinavian-keyboard.googlecode.com/svn/trunk" to determine what changes to submit.
bzr: ERROR: bzrlib.errors.NotBranchError: Not a branch: "http://scandinavian-keyboard.googlecode.com/svn/trunk/".

Traceback (most recent call last):
  File "/usr/lib/python2.6/dist-packages/bzrlib/commands.py", line 853, in exception_to_return_code
    return the_callable(*args, **kwargs)
  File "/usr/lib/python2.6/dist-packages/bzrlib/commands.py", line 1055, in run_bzr
    ret = run(*run_argv)
  File "/usr/lib/python2.6/dist-packages/bzrlib/commands.py", line 661, in run_argv_aliases
    return self.run_direct(**all_cmd_args)
  File "/usr/lib/python2.6/dist-packages/bzrlib/commands.py", line 665, in run_direct
    return self._operation.run_simple(*args, **kwargs)
  File "/usr/lib/python2.6/dist-packages/bzrlib/cleanup.py", line 122, in run_simple
    self.cleanups, self.func, *args, **kwargs)
  File "/usr/lib/python2.6/dist-packages/bzrlib/cleanup.py", line 156, in _do_with_cleanups
    result = func(*args, **kwargs)
  File "/usr/lib/python2.6/dist-packages/bzrlib/builtins.py", line 5146, in run
    strict=strict)
  File "/usr/lib/python2.6/dist-packages/bzrlib/send.py", line 83, in send
    submit_br = Branch.open(submit_branch)
  File "/usr/lib/python2.6/dist-packages/bzrlib/branch.py", line 169, in open
    possible_transports=possible_transports)
  File "/usr/lib/python2.6/dist-packages/bzrlib/bzrdir.py", line 841, in open
    return BzrDir.open_from_transport(t, _unsupported=_unsupported)
  File "/usr/lib/python2.6/dist-packages/bzrlib/bzrdir.py", line 871, in open_from_transport
    redirected)
  File "/usr/lib/python2.6/dist-packages/bzrlib/transport/__init__.py", line 1648, in do_catching_redirections
    return action(transport)
  File "/usr/lib/python2.6/dist-packages/bzrlib/bzrdir.py", line 858, in find_format
    transport, _server_formats=_server_formats)
  File "/usr/lib/python2.6/dist-packages/bzrlib/bzrdir.py", line 1822, in find_format
    raise errors.NotBranchError(path=transport.base)
NotBranchError: Not a branch: "http://scandinavian-keyboard.googlecode.com/svn/trunk/".

Changed in bzr:
status: Incomplete → New
Andrew Bennetts (spiv) on 2010-11-07
affects: bzr → bzr-svn

On Sun, 2010-11-07 at 23:48 +0000, Launchpad Bug Tracker wrote:
> You have been subscribed to a public bug:
>
> johan@johansdator:~/src/ScandinavianKeyboard$ bzr send -o /tmp/markov-proof-of-concept.patch
> Using saved parent location "http://scandinavian-keyboard.googlecode.com/svn/trunk" to determine what changes to submit.
> bzr: ERROR: File is binary but should be text.
>
> Which file is binary? How did things get this way? What could I
> potentially do about it?
This is a bug in bzr-svn's implementation. We're trying to generate
svn-compatible diffs, but we don't support binary files yet. What does
svn do when asked to generate a diff for a file that contains binary
data?

Cheers,

Jelmer

Johan Walles (walles) wrote :

Hi Jelmer!

First of all, which of the files I have changed is it that is binary? If the error message could tell me that that would be awesome! My repo is attached to this issue in case that helps.

To answer your question I tried setting up a repo with a binary file in it (called "binary"), replaced it with some other binary and asked for a diff:

"
johan@transwarp:/tmp/hej/svnrepo$ LANG= svn diff
Index: binary
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
"

Jelmer Vernooij (jelmer) wrote :

Thanks for the followup. This is now fixed in bzr-svn trunk.

Changed in bzr-svn:
status: New → Fix Committed
importance: Undecided → Medium
assignee: nobody → Jelmer Vernooij (jelmer)
Johan Walles (walles) wrote :

Do you have a link to the diff? I looked at https://code.launchpad.net/bzr-svn but none of the branches had any commits more recent than a week.

On Mon, 2010-11-15 at 15:45 +0000, Johan Walles wrote:
> Do you have a link to the diff? I looked at https://code.launchpad.net
> /bzr-svn but none of the branches had any commits more recent than a
> week.
I forgot to push. It should be in bzr-svn trunk now, sorry. r3488

Cheers,

Jelmer

Jelmer Vernooij (jelmer) on 2011-01-28
Changed in bzr-svn:
milestone: none → 1.1.0
Johan Walles (walles) wrote :

Hi Jelmer!

Thanks for the fix! I did verify that it works and I'm happy; this fix did resolve my problem.

For future generations though, how about printing a warning on stderr when handling binary files this way? Otherwise it's really easy to miss that the binary files don't in fact end up in the diff.

  Regards /Johan

Jelmer Vernooij (jelmer) wrote :

Hi Johan,

On Fri, 2011-01-28 at 16:00 +0000, Johan Walles wrote:
> Thanks for the fix! I did verify that it works and I'm happy; this fix
> did resolve my problem.
>
> For future generations though, how about printing a warning on stderr
> when handling binary files this way? Otherwise it's really easy to miss
> that the binary files don't in fact end up in the diff.
The "bzr send" mode really is intended to be compatible with "svn diff"
which doesn't warn either.

That said, I'm open to adding a warning, but I'm not sure how well that
works with the various GUI's out there.

Cheers,

Jelmer

Jelmer Vernooij (jelmer) on 2011-08-26
Changed in bzr-svn:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers