Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mercurial support #193

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 10 additions & 0 deletions diff-so-fancy
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down