Mercurial > evolve
changeset 3399:4adf46158b9b
obslog: colorize the description diff shown in obslog -p
This patch colorizes the description diff shown in `hg obslog -p`. The labels
for the header are different from that of the patch as the main header which
says `diff -r <somehash> -r <somehash> <filename>`. Next patch will hack to add
that.
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Thu, 11 Jan 2018 16:30:46 +0530 |
parents | d67e6080e11b |
children | 6d345d7ca682 |
files | hgext3rd/evolve/obshistory.py tests/test-evolve-obshistory.t |
diffstat | 2 files changed, 22 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/evolve/obshistory.py Wed Jan 10 19:47:43 2018 +0530 +++ b/hgext3rd/evolve/obshistory.py Thu Jan 11 16:30:46 2018 +0530 @@ -189,7 +189,7 @@ # Copied from patch.diff text = ''.join(sum((list(hlines) for hrange, hlines in hunks), [])) patch = "\n".join(uheaders + [text]) - return _indent(patch) + return patch class missingchangectx(object): ''' a minimal object mimicking changectx for change contexts @@ -501,9 +501,19 @@ # Description patch descriptionpatch = getmarkerdescriptionpatch(repo, node, succ) + if descriptionpatch: fm.plain("\n") - fm.plain(descriptionpatch) + + def tolist(text): + return [text] + + for chunk, label in patch.difflabel(tolist, descriptionpatch): + if chunk == '\t': + continue + if chunk != '\n': + fm.plain(' ') + fm.write('desc-diff', '%s', chunk, label=label) # Content patch diffopts = patch.diffallopts(repo.ui, {})
--- a/tests/test-evolve-obshistory.t Wed Jan 10 19:47:43 2018 +0530 +++ b/tests/test-evolve-obshistory.t Thu Jan 11 16:30:46 2018 +0530 @@ -77,13 +77,13 @@ | x [evolve.node|471f378eab4c] [evolve.rev|(1)] [evolve.short_description|A0] [evolve.verb|rewritten](description, content) as [evolve.node|4ae3a4151de9] by [evolve.user|test] [evolve.date|(Thu Jan 01 00:00:00 1970 +0000)] - --- a/471f378eab4c-changeset-description - +++ b/4ae3a4151de9-changeset-description - @@ -1,1 +1,3 @@ - -A0 - +A1 - + - +Better commit message + [diff.deleted|--- a/471f378eab4c-changeset-description] + [diff.inserted|+++ b/4ae3a4151de9-changeset-description] + [diff.hunk|@@ -1,1 +1,3 @@] + [diff.deleted|-A0] + [diff.inserted|+A1] + [diff.inserted|+] + [diff.inserted|+Better commit message] [diff.diffline|diff -r 471f378eab4c -r 4ae3a4151de9 A0] [diff.file_a|--- a/A0 Thu Jan 01 00:00:00 1970 +0000] @@ -98,14 +98,14 @@ 4ae3a4151de9 (2) A1 471f378eab4c (1) A0 rewritten(description, content) as 4ae3a4151de9 by test (Thu Jan 01 00:00:00 1970 +0000) - --- a/471f378eab4c-changeset-description - +++ b/4ae3a4151de9-changeset-description + --- a/471f378eab4c-changeset-description + +++ b/4ae3a4151de9-changeset-description @@ -1,1 +1,3 @@ -A0 +A1 + +Better commit message - + diff -r 471f378eab4c -r 4ae3a4151de9 A0 --- a/A0 Thu Jan 01 00:00:00 1970 +0000 +++ b/A0 Thu Jan 01 00:00:00 1970 +0000