What would make hg diff see a txt file as binary?

Matt Mackall mpm at selenic.com
Thu Aug 28 14:43:19 UTC 2014


On Wed, 2014-08-27 at 15:07 -0400, Harry Putnam wrote:
> Setup: Debian testing (jessie)
> Mercurial: Mercurial Distributed SCM (version 3.0.2)
> 
> Ran into something I had not seen before.
> 
> Running `hg diff' on a plain text file with some changes produced this
> output:
> 
>    > hg diff common/0finaActy-snp 
>      diff -r 06e8b77a6271 common/0finaActy-snp
>      Binary file common/0finaActy-snp has changed
> 
> Just to make sure I quickly browsed the 3490 line file but did not
> notice anything but plain text.
> 
> The regular linux `diff' command sees nothing but txt.  
> 
> Checking with the `file' command I see:
>   > file common/0finaActy-snp 
>   common/0finaActy-snp: ASCII text, with CRLF, LF line terminators, 
>   with escape sequences

If any NUL byte appears in a file, Mercurial (and many other Unix tools
including file) will report it as non-text. This is _Mercurial's only
criterion_. Also, testing the version in your working copy might not be
sufficient to spot the problem.

Using -a will cause Mercurial to treat it as text anyway.

-- 
Mathematics is the supreme nostalgia of our time.





More information about the Mercurial mailing list