[BUG] bundle cannot handle binary files

Alexander Belchenko bialix at ukr.net
Sat Jul 8 13:47:54 BST 2006


Alexander Belchenko пишет:
> I manually extract base-64 encoded bzr.ico's diff from my bundle. And 
> then decode it from base64. After that I save decoded string to file
> binary.diff (attached).
> 
> After that I copy this diff to empty directory and run:
> 
> D:\user\MyCode\bzr\__test\b>patch -p0 --binary < binary.diff
> patching file bzr.ico
> 
> And as result I have normal bzr.ico in this directory.
> 
> So, when I run all steps manually I ends with correct result.

I run merge process in debugger and I think I found where problem is.
Here the code in bundle_data.py:

def patched_file(file_patch, original):
     """Produce a file-like object with the patched version of a text"""
     from bzrlib.patches import iter_patched
     from bzrlib.iterablefile import IterableFile
     if file_patch == "":
         return IterableFile(())
     return IterableFile(iter_patched(original, 
file_patch.splitlines(True)))


Here file_patch is string that contain diff of binary file. 
Unfortunately inside this diff (i.e. inside binary file itself) there is 
'\r' character. And function

file_patch.splitlines(True)

split lines of patch by '\n' and '\r' *also*. And therefore this 
function breaks normal diff into malformed diff.

So, yes, I agree, it's win32-specific bug in string.splitlines().

In [3]: 'aaaa\rbbbb\r\nccc\nddd'.splitlines(True)
Out[3]: ['aaaa\r', 'bbbb\r\n', 'ccc\n', 'ddd']

BTW, in bundle_data.py inside function def _get_inventory() (approx. 
line 645) there is also potentially non-cross-platforming statement:

from os.path import dirname, basename

--
Alexander





More information about the bazaar mailing list