Comment 9 for bug 3918

Revision history for this message
Andrew Bennetts (spiv) wrote : Re: bzr doesn't handle filenames with newlines

Michael Hudson points out that commit now fails if a file with a newline in the name is added, but that's when running with asserts.

If you are using python -O (or a bzr installed to use .pyo files), then instead of the assert, you get:
KnitCorrupt: Knit None corrupt: incorrect number of lines 4 != 3 for version {<email address hidden>}

I used this script:

---
set -e

BZR=bzr

mkdir test
cd test/
python -O $BZR init
touch foo
python -O $BZR add foo
python -O $BZR ci -m "Initial"
cd ..
python -O $BZR co test co-test
cd co-test/
echo "newline" > "file
name"
python -O $BZR add "file
name"
python -O $BZR ci -m "Commit"
---

And got this traceback with bzr.dev:

Traceback (most recent call last):
  File "/home/andrew/code/bzr/bzrlib/commands.py", line 836, in run_bzr_catch_errors
    return run_bzr(argv)
  File "/home/andrew/code/bzr/bzrlib/commands.py", line 791, 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 2329, in run
    author=author)
  File "/home/andrew/code/bzr/bzrlib/decorators.py", line 165, in write_locked
    return unbound(self, *args, **kwargs)
  File "/home/andrew/code/bzr/bzrlib/workingtree_4.py", line 246, in commit
    result = WorkingTree3.commit(self, message, revprops, *args, **kwargs)
  File "/home/andrew/code/bzr/bzrlib/decorators.py", line 165, in write_locked
    return unbound(self, *args, **kwargs)
  File "/home/andrew/code/bzr/bzrlib/mutabletree.py", line 187, in commit
    revprops=revprops, *args, **kwargs)
  File "/home/andrew/code/bzr/bzrlib/commit.py", line 389, in commit
    revision_id=self.rev_id)
  File "/home/andrew/code/bzr/bzrlib/repository.py", line 949, in fetch
    return inter.fetch(revision_id=revision_id, pb=pb, find_ghosts=find_ghosts)
  File "/home/andrew/code/bzr/bzrlib/decorators.py", line 165, in write_locked
    return unbound(self, *args, **kwargs)
  File "/home/andrew/code/bzr/bzrlib/repository.py", line 2737, in fetch
    revision_ids).pack()
  File "/home/andrew/code/bzr/bzrlib/repofmt/pack_repo.py", line 589, in pack
    return self._create_pack_from_packs()
  File "/home/andrew/code/bzr/bzrlib/repofmt/pack_repo.py", line 719, in _create_pack_from_packs
    self._copy_inventory_texts()
  File "/home/andrew/code/bzr/bzrlib/repofmt/pack_repo.py", line 649, in _copy_inventory_texts
    self._process_inventory_lines(inv_lines)
  File "/home/andrew/code/bzr/bzrlib/repofmt/pack_repo.py", line 904, in _process_inventory_lines
    inv_lines, self.revision_ids)
  File "/home/andrew/code/bzr/bzrlib/repository.py", line 1276, in _find_file_ids_from_xml_inventory_lines
    line_iterator).iterkeys():
  File "/home/andrew/code/bzr/bzrlib/repository.py", line 1216, in _find_text_key_references_from_xml_inventory_lines
    for line, version_id in line_iterator:
  File "/home/andrew/code/bzr/bzrlib/repofmt/pack_repo.py", line 805, in _copy_nodes_graph
    write_index, output_lines, pb, readv_group_iter, total_items):
  File "/home/andrew/code/bzr/bzrlib/repofmt/pack_repo.py", line 833, in _do_copy_nodes_graph
    content, _ = knit_data._parse_record(version_id, raw_data)
  File "/home/andrew/code/bzr/bzrlib/knit.py", line 2412, in _parse_record
    version_id))
KnitCorrupt: Knit None corrupt: incorrect number of lines 4 != 3 for version {<email address hidden>}