views:

300

answers:

3

I've recently started using Mercurial and when I reverted one of my .SQL files, Mercurial performed a binary comparison. This obviously limits the visibility of the changes that were made, as there is no diff.

Is there an option to set file types to do a string compare?

I'm using Tortioise Hg 0.8.1 with Mercurial 1.3.1.

A: 

You should try adding these lines to ~/.hgrc:

[diff]
git=1

The git diff format works for binary files.

joeforker
I think he's saying he wants the files considered as text and not binaries.
Ry4an
True. In that case the answer is 'you should consider not having any null bytes in the first 1,000 bytes of your file'.
joeforker
+4  A: 

Mercurial doesn't actually handle text and binaries at all differently with respect to actual storage. It does however try to guess "would visually showing this diff be meaningful" when asked to show a diff to a user with 'hg diff', 'hg log -p', or when viewing a changeset in the web interface. When it's trying to make the "should I show this as if it's text" decision the test applied is "Is there a NUL byte (0x00) within the first 1000 bytes of a file.

So your file isn't being treated any differently except in how it's displayed to user output, but if you can find a NUL byte in there you can probably get that to stop too.

Alternately, the extdiff extension can be used to take total control of how diffs are displayed.

Ry4an
The test in util.binary now looks for a NUL byte in the entire file.
Martin Geisler
+1  A: 

I don't know about the graphical part of TortoiseHg, but if you use the command line, then the --text flag to hg diff should do the trick: it makes Mercurial treat all files as text.

Martin Geisler