bzr-fastimport on Windows

Paul Moore p.f.moore at gmail.com
Sat Mar 8 15:59:47 GMT 2008


On 08/03/2008, SuperMMX <supermmx at gmail.com> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
>  Hash: SHA1
>
>
>  Hi, all
>
>  I am using fastimport to convert SVN to Bazaar with svn-fast-export,
>  but have two problems:
>
>  1) If some files in SVN repo are with DOS eol (CRLF), bzr-fastimport will
>    fail with invalid command XXX. I don't know much about python, but found out
>    that it reads more bytes than expected ( I suppose some CRLFs are ignored).
>    While with UNIX eol, it works well.
>
>  2) It doesn't work well with binaries. For example, PNG files contains ^Z (26),
>    but bzr-fastimport considers it as EOF and stop working.

That sounds like some file is being opened in text mode rather than
binary mode. As bzr-fastimport takes its data from stdin, it's
probably caused by the fact that Windows opens stdin by default.

I think all you need to do is to add

   msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)

at the top of the module. Wrap it round an "try: import msvcrt ...
except ImportError" block, so that it still works on non-Windows
platforms and you're away.

I've not tested this, so I could be completely wrong, of course...

Paul.



More information about the bazaar mailing list