[darcs-users] Binary data

David Roundy droundy at abridgegame.org
Mon May 19 10:54:12 UTC 2003


On Sun, May 18, 2003 at 10:13:31PM +0200, Peter Simons wrote:
> Pardon me in case I missed this topic in the manual, but does darcs
> handle binary files correctly? Stuff like a tar.gz archive?

The answer is probably no.  Darcs would treat the file as a text file... if
you're lucky the worst you'll get is unreadable patches, but I don't think
it would be a good plan, as darcs may do something weird to the newlines.
Plus you don't want merging on binary files, as that would make things
unreadable.

I haven't gotten around to this largely because I haven't had need of it,
but also because I haven't decided the best way to deal with binary files.
For example, I could treat a tar.gz archive as a directory, which would
provide version control of the files within the archive (assuming they are
text).  Similarly, with a simple gzipped text file I could provide version
control of the text within the file.  If these sorts of features were
interesting I could provide them, but then I'm not sure where the benefit
of having it as a gzipped tarball would be, since in the repository it
would then take as much space as uncompressed files, since the patches
would all be on the content itself.

A more normal (and more general) solution would be to introduce binary
deltas, which would still be a bit of a pain, and much less entertaining.
It also has the disadvantage that you lose a lot of the benefits of version
control, since you can't merge binary patches that don't understand their
content.

Another interesting type of patch I've considered is an image change patch
for images files (I'd have to find a good image reading library) that
change in content but not in size.  In that case you could perform rather
interesting merges of changes, but while it might be fun to code, I'm not
sure how useful it would actually be.

So in summary, support for binary files has been postponed until either I
have nothing else to do (unlikely to happen) or they are needed.  So if you
have need of binary file support, we can talk about which of the above
methods seems best for you.  The tar.gz-as-a-directory approach is probably
one of the tougher, but is really cool.  :) So if you have a situation that
justifies, it, that would be a fun one to implement.  On the other hand, I
don't like implementing things that won't be used immediately, since then
they wouldn't get tested well.

> P. S.: How the heck do I explain my bash to use this competion thing
>        of yours? It doesn't seem to care about the contents of the
>        directory you install it in and I have idea how to run it
>        otherwise.

You can edit the darcs completion script removing the two lines that have
the word "have" in them (which I think is provided by the bash_completion
package) and then source it in your .bashrc.  On my mac, I call it
~/.darcs_completion, and have the following line in my .bashrc:

. ~/.darcs_completion
-- 
David Roundy
http://www.abridgegame.org




More information about the darcs-users mailing list