comparison mercurial/cmdutil.py @ 35277:6ba79cf34f5e

patch: add within-line color diff capacity The `diff' command usually writes deletion in red and insertions in green. This patch adds within-line colors, to highlight which part of the lines differ. Lines to compare are decided based on their similarity ratio, as computed by difflib SequenceMatcher, with an arbitrary threshold (0.7) to decide at which point two lines are considered entirely different (therefore no inline-diff required). The current implementation is kept behind an experimental flag in order to test the effect on performance. In order to activate it, set inline-color-diff to true in [experimental].
author Matthieu Laneuville <matthieu.laneuville@octobus.net>
date Thu, 26 Oct 2017 00:13:38 +0900
parents c7b45db8f317
children 82ee401135dd
comparison
equal deleted inserted replaced
35276:205c3c6c1a51 35277:6ba79cf34f5e
1516 if stat: 1516 if stat:
1517 diffopts = diffopts.copy(context=0) 1517 diffopts = diffopts.copy(context=0)
1518 width = 80 1518 width = 80
1519 if not ui.plain(): 1519 if not ui.plain():
1520 width = ui.termwidth() 1520 width = ui.termwidth()
1521 chunks = patch.diff(repo, node1, node2, match, changes, diffopts, 1521 chunks = patch.diff(repo, node1, node2, match, changes, opts=diffopts,
1522 prefix=prefix, relroot=relroot, 1522 prefix=prefix, relroot=relroot,
1523 hunksfilterfn=hunksfilterfn) 1523 hunksfilterfn=hunksfilterfn)
1524 for chunk, label in patch.diffstatui(util.iterlines(chunks), 1524 for chunk, label in patch.diffstatui(util.iterlines(chunks),
1525 width=width): 1525 width=width):
1526 write(chunk, label=label) 1526 write(chunk, label=label)
1527 else: 1527 else:
1528 for chunk, label in patch.diffui(repo, node1, node2, match, 1528 for chunk, label in patch.diffui(repo, node1, node2, match,
1529 changes, diffopts, prefix=prefix, 1529 changes, opts=diffopts, prefix=prefix,
1530 relroot=relroot, 1530 relroot=relroot,
1531 hunksfilterfn=hunksfilterfn): 1531 hunksfilterfn=hunksfilterfn):
1532 write(chunk, label=label) 1532 write(chunk, label=label)
1533 1533
1534 if listsubrepos: 1534 if listsubrepos: