mercurial

Equivant of git's --color-words or --word-diff in Mercurial


Let's say I had this file with these contents:

One two three

And let's say I modified this file to look like this:

One TWO three

A typical diff output would be:

- One two three
+ One TWO three

However, Git offers options like --color-words or --word-diff=color to show this difference in one line, colouring the word deleted in red and colourig the word added in green:

diff in one line showing: One twoTWO three

Does Mercurial have an option like this? Something like hg diff --color-words?


Solution

  • Add this to your ~/.hgrc file:

    [diff]
    word-diff = true
    

    This effects the command-line hg diff command. In modified lines, added or removed characters will be underlined.

    Unfortunately, it seems TortoiseHG (on MS Windows) does not recognize this setting.

    Source: https://wiki.mercurial-scm.org/WordDiff