mercurial & binary files

Matt Mackall mpm at selenic.com
Thu Jul 17 11:44:12 CDT 2008


On Thu, 2008-07-17 at 14:40 +0200, Marko Käning wrote:
> Hi Paul,
> 
> well, I don't expect it to merge my binary files.
> 
> I just wanted to double check that I can commit binary files to a repo, 
> without taking extra care about defining that they are binary files.

Short answer: yes, this just works.

Long answer: it may break sometimes, but it will do so much less often
than systems like CVS which require you to flag binary files.

In theory, CVS always gets it right because you tell it exactly which
files it can merge. In practice, CVS always gets it *wrong*, because you
always forget to tell it about binary files until after a problem
arises.

Mercurial gets it right almost always automatically. If properly
configured, it will not attempt to merge files it detects as binary
unless you specifically tell it to. And you can in fact configure it to
attempt a 3-way merge of a JPEG in the GIMP if you so desire.

The 'almost always' is due to the fact that detection of binaries is not
perfect because 'binary file' is not well-defined. We use a simple
heuristic: any file that contains a 0-byte is binary. That will be right
in most cases, but wrong in a couple. For one, it will fail on UTF-16
text files. And it can also fail on things like PPM images. But it
generally works fine.

-- 
Mathematics is the supreme nostalgia of our time.



More information about the Mercurial mailing list