From ea6aa1b50f50fa89de9116d25ce8d8e33040c485 Mon Sep 17 00:00:00 2001 From: Alex Kotliarskyi Date: Thu, 28 Dec 2017 11:41:30 -0800 Subject: [PATCH] Mercurial support --- README.md | 15 +++++++++++++++ diff-so-fancy | 10 ++++++++++ 2 files changed, 25 insertions(+) diff --git a/README.md b/README.md index ae5ff9a..9a7b519 100644 --- a/README.md +++ b/README.md @@ -17,11 +17,26 @@ Installation is as simple as downloading the [diff-so-fancy](https://raw.githubu ## Usage +### Git + Configure git to use `diff-so-fancy` for all diff output: ```shell git config --global core.pager "diff-so-fancy | less --tabs=4 -RFX" ``` +### Mercurial + +```shell +hg config --edit +``` + +Add + +``` +[pager] +pager = diff-so-fancy | less --tabs=4 -RFX +``` + ### Improved colors for the highlighted bits The default Git colors are not optimal. We suggest the following colors instead. diff --git a/diff-so-fancy b/diff-so-fancy index be81d6e..9b5f168 100755 --- a/diff-so-fancy +++ b/diff-so-fancy @@ -145,6 +145,16 @@ sub do_dsf_stuff { # Look for the filename # ######################### } elsif ($line =~ /^${ansi_color_regex}diff --(git|cc) (.*?)(\s|\e|$)/) { + $last_file_seen = $5; + $last_file_seen =~ s|^\w/||; # Remove a/ (and handle diff.mnemonicPrefix). + $in_hunk = 0; + ################################################################### + # Mercurial prints git's equivalent of diff and index in one line # + ################################################################### + } elsif ($line =~ /^${ansi_color_regex}diff -r (.*?)(\s|\e|$)/) { + $meta_color = $1 || DiffHighlight::color_config('color.diff.meta',"\e[38;5;11m"); + print horizontal_rule($meta_color); + $last_file_seen = $5; $last_file_seen =~ s|^\w/||; # Remove a/ (and handle diff.mnemonicPrefix). $in_hunk = 0;