Mercurial > evolve
changeset 3400:6d345d7ca682
obslog: add header to the changeset description diff
This patch adds `diff -r <hash> -r <hash> <filename>` header to the output of
the changeset description diff which is shown using the --patch flag of obslog
command.
This fixes the label/color issue for description diff also.
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Thu, 11 Jan 2018 17:11:10 +0530 |
parents | 4adf46158b9b |
children | 43b7773e00ae |
files | hgext3rd/evolve/obshistory.py tests/test-evolve-obshistory.t |
diffstat | 2 files changed, 96 insertions(+), 63 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/evolve/obshistory.py Thu Jan 11 16:30:46 2018 +0530 +++ b/hgext3rd/evolve/obshistory.py Thu Jan 11 17:11:10 2018 +0530 @@ -176,8 +176,8 @@ succdesc = succctx.description() + '\n' # fake file name - basename = "%s-changeset-description" % basectx - succname = "%s-changeset-description" % succctx + basename = "changeset-description" + succname = "changeset-description" d = mdiff.unidiff(basedesc, '', succdesc, '', basename, succname) # mercurial 4.1 and before return the patch directly @@ -189,6 +189,7 @@ # Copied from patch.diff text = ''.join(sum((list(hlines) for hrange, hlines in hunks), [])) patch = "\n".join(uheaders + [text]) + return patch class missingchangectx(object): @@ -503,15 +504,19 @@ descriptionpatch = getmarkerdescriptionpatch(repo, node, succ) if descriptionpatch: - fm.plain("\n") + # add the diffheader + diffheader = "diff -r %s -r %s changeset-description\n" % \ + (repo[node], repo[succ]) + descriptionpatch = diffheader + descriptionpatch def tolist(text): return [text] + fm.plain("\n") + for chunk, label in patch.difflabel(tolist, descriptionpatch): - if chunk == '\t': - continue - if chunk != '\n': + chunk = chunk.strip('\t') + if chunk and chunk != '\n': fm.plain(' ') fm.write('desc-diff', '%s', chunk, label=label)
--- a/tests/test-evolve-obshistory.t Thu Jan 11 16:30:46 2018 +0530 +++ b/tests/test-evolve-obshistory.t Thu Jan 11 17:11:10 2018 +0530 @@ -56,8 +56,9 @@ | x 471f378eab4c (1) A0 rewritten(description, content) as 4ae3a4151de9 by test (*) (glob) - --- a/471f378eab4c-changeset-description - +++ b/4ae3a4151de9-changeset-description + diff -r 471f378eab4c -r 4ae3a4151de9 changeset-description + --- a/changeset-description + +++ b/changeset-description @@ -1,1 +1,3 @@ -A0 +A1 @@ -77,8 +78,9 @@ | 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)] - [diff.deleted|--- a/471f378eab4c-changeset-description] - [diff.inserted|+++ b/4ae3a4151de9-changeset-description] + [diff.diffline|diff -r 471f378eab4c -r 4ae3a4151de9 changeset-description] + [diff.file_a|--- a/changeset-description] + [diff.file_b|+++ b/changeset-description] [diff.hunk|@@ -1,1 +1,3 @@] [diff.deleted|-A0] [diff.inserted|+A1] @@ -98,14 +100,15 @@ 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 + diff -r 471f378eab4c -r 4ae3a4151de9 changeset-description + --- a/changeset-description + +++ b/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 @@ -153,8 +156,9 @@ $ hg obslog --hidden --patch 471f378eab4c x 471f378eab4c (1) A0 rewritten(description, content) as 4ae3a4151de9 by test (*) (glob) - --- a/471f378eab4c-changeset-description - +++ b/4ae3a4151de9-changeset-description + diff -r 471f378eab4c -r 4ae3a4151de9 changeset-description + --- a/changeset-description + +++ b/changeset-description @@ -1,1 +1,3 @@ -A0 +A1 @@ -844,8 +848,9 @@ $ hg obslog --hidden 471f378eab4c --patch x 471f378eab4c (1) A0 rewritten(description, content) as eb5a0daa2192 by test (*) (glob) - --- a/471f378eab4c-changeset-description - +++ b/eb5a0daa2192-changeset-description + diff -r 471f378eab4c -r eb5a0daa2192 changeset-description + --- a/changeset-description + +++ b/changeset-description @@ -1,1 +1,1 @@ -A0 +C0 @@ -867,8 +872,9 @@ | x 471f378eab4c (1) A0 rewritten(description, content) as eb5a0daa2192 by test (*) (glob) - --- a/471f378eab4c-changeset-description - +++ b/eb5a0daa2192-changeset-description + diff -r 471f378eab4c -r eb5a0daa2192 changeset-description + --- a/changeset-description + +++ b/changeset-description @@ -1,1 +1,1 @@ -A0 +C0 @@ -897,8 +903,9 @@ | x 471f378eab4c (1) A0 rewritten(description, content) as eb5a0daa2192 by test (*) (glob) - --- a/471f378eab4c-changeset-description - +++ b/eb5a0daa2192-changeset-description + diff -r 471f378eab4c -r eb5a0daa2192 changeset-description + --- a/changeset-description + +++ b/changeset-description @@ -1,1 +1,1 @@ -A0 +C0 @@ -921,8 +928,9 @@ | x 471f378eab4c (1) A0 rewritten(description, content) as eb5a0daa2192 by test (*) (glob) - --- a/471f378eab4c-changeset-description - +++ b/eb5a0daa2192-changeset-description + diff -r 471f378eab4c -r eb5a0daa2192 changeset-description + --- a/changeset-description + +++ b/changeset-description @@ -1,1 +1,1 @@ -A0 +C0 @@ -1079,15 +1087,17 @@ $ hg obslog --hidden 471f378eab4c --patch x 471f378eab4c (1) A0 rewritten(description) as 65b757b745b9 by test (*) (glob) - --- a/471f378eab4c-changeset-description - +++ b/65b757b745b9-changeset-description + diff -r 471f378eab4c -r 65b757b745b9 changeset-description + --- a/changeset-description + +++ b/changeset-description @@ -1,1 +1,1 @@ -A0 +A2 rewritten(description) as fdf9bde5129a by test (*) (glob) - --- a/471f378eab4c-changeset-description - +++ b/fdf9bde5129a-changeset-description + diff -r 471f378eab4c -r fdf9bde5129a changeset-description + --- a/changeset-description + +++ b/changeset-description @@ -1,1 +1,1 @@ -A0 +A1 @@ -1102,15 +1112,17 @@ |/ x 471f378eab4c (1) A0 rewritten(description) as 65b757b745b9 by test (*) (glob) - --- a/471f378eab4c-changeset-description - +++ b/65b757b745b9-changeset-description + diff -r 471f378eab4c -r 65b757b745b9 changeset-description + --- a/changeset-description + +++ b/changeset-description @@ -1,1 +1,1 @@ -A0 +A2 rewritten(description) as fdf9bde5129a by test (*) (glob) - --- a/471f378eab4c-changeset-description - +++ b/fdf9bde5129a-changeset-description + diff -r 471f378eab4c -r fdf9bde5129a changeset-description + --- a/changeset-description + +++ b/changeset-description @@ -1,1 +1,1 @@ -A0 +A1 @@ -1161,15 +1173,17 @@ | x 471f378eab4c (1) A0 rewritten(description) as 65b757b745b9 by test (*) (glob) - --- a/471f378eab4c-changeset-description - +++ b/65b757b745b9-changeset-description + diff -r 471f378eab4c -r 65b757b745b9 changeset-description + --- a/changeset-description + +++ b/changeset-description @@ -1,1 +1,1 @@ -A0 +A2 rewritten(description) as fdf9bde5129a by test (*) (glob) - --- a/471f378eab4c-changeset-description - +++ b/fdf9bde5129a-changeset-description + diff -r 471f378eab4c -r fdf9bde5129a changeset-description + --- a/changeset-description + +++ b/changeset-description @@ -1,1 +1,1 @@ -A0 +A1 @@ -1184,15 +1198,17 @@ |/ x 471f378eab4c (1) A0 rewritten(description) as 65b757b745b9 by test (*) (glob) - --- a/471f378eab4c-changeset-description - +++ b/65b757b745b9-changeset-description + diff -r 471f378eab4c -r 65b757b745b9 changeset-description + --- a/changeset-description + +++ b/changeset-description @@ -1,1 +1,1 @@ -A0 +A2 rewritten(description) as fdf9bde5129a by test (*) (glob) - --- a/471f378eab4c-changeset-description - +++ b/fdf9bde5129a-changeset-description + diff -r 471f378eab4c -r fdf9bde5129a changeset-description + --- a/changeset-description + +++ b/changeset-description @@ -1,1 +1,1 @@ -A0 +A1 @@ -1205,15 +1221,17 @@ | x 471f378eab4c (1) A0 rewritten(description) as 65b757b745b9 by test (*) (glob) - --- a/471f378eab4c-changeset-description - +++ b/65b757b745b9-changeset-description + diff -r 471f378eab4c -r 65b757b745b9 changeset-description + --- a/changeset-description + +++ b/changeset-description @@ -1,1 +1,1 @@ -A0 +A2 rewritten(description) as fdf9bde5129a by test (*) (glob) - --- a/471f378eab4c-changeset-description - +++ b/fdf9bde5129a-changeset-description + diff -r 471f378eab4c -r fdf9bde5129a changeset-description + --- a/changeset-description + +++ b/changeset-description @@ -1,1 +1,1 @@ -A0 +A1 @@ -1227,15 +1245,17 @@ |/ x 471f378eab4c (1) A0 rewritten(description) as 65b757b745b9 by test (*) (glob) - --- a/471f378eab4c-changeset-description - +++ b/65b757b745b9-changeset-description + diff -r 471f378eab4c -r 65b757b745b9 changeset-description + --- a/changeset-description + +++ b/changeset-description @@ -1,1 +1,1 @@ -A0 +A2 rewritten(description) as fdf9bde5129a by test (*) (glob) - --- a/471f378eab4c-changeset-description - +++ b/fdf9bde5129a-changeset-description + diff -r 471f378eab4c -r fdf9bde5129a changeset-description + --- a/changeset-description + +++ b/changeset-description @@ -1,1 +1,1 @@ -A0 +A1 @@ -1250,15 +1270,17 @@ |/ x 471f378eab4c (1) A0 rewritten(description) as 65b757b745b9 by test (*) (glob) - --- a/471f378eab4c-changeset-description - +++ b/65b757b745b9-changeset-description + diff -r 471f378eab4c -r 65b757b745b9 changeset-description + --- a/changeset-description + +++ b/changeset-description @@ -1,1 +1,1 @@ -A0 +A2 rewritten(description) as fdf9bde5129a by test (*) (glob) - --- a/471f378eab4c-changeset-description - +++ b/fdf9bde5129a-changeset-description + diff -r 471f378eab4c -r fdf9bde5129a changeset-description + --- a/changeset-description + +++ b/changeset-description @@ -1,1 +1,1 @@ -A0 +A1 @@ -1404,8 +1426,9 @@ |\ x | 471f378eab4c (1) A0 / rewritten(description, content) as eb5a0daa2192 by test (*) (glob) - | --- a/471f378eab4c-changeset-description - | +++ b/eb5a0daa2192-changeset-description + | diff -r 471f378eab4c -r eb5a0daa2192 changeset-description + | --- a/changeset-description + | +++ b/changeset-description | @@ -1,1 +1,1 @@ | -A0 | +C0 @@ -1423,8 +1446,9 @@ | x 0dec01379d3b (2) B0 rewritten(description) as b7ea6d14e664 by test (*) (glob) - --- a/0dec01379d3b-changeset-description - +++ b/b7ea6d14e664-changeset-description + diff -r 0dec01379d3b -r b7ea6d14e664 changeset-description + --- a/changeset-description + +++ b/changeset-description @@ -1,1 +1,1 @@ -B0 +B1 @@ -1436,8 +1460,9 @@ |\ x | 471f378eab4c (1) A0 / rewritten(description, content) as eb5a0daa2192 by test (*) (glob) - | --- a/471f378eab4c-changeset-description - | +++ b/eb5a0daa2192-changeset-description + | diff -r 471f378eab4c -r eb5a0daa2192 changeset-description + | --- a/changeset-description + | +++ b/changeset-description | @@ -1,1 +1,1 @@ | -A0 | +C0 @@ -1455,8 +1480,9 @@ | x 0dec01379d3b (2) B0 rewritten(description) as b7ea6d14e664 by test (*) (glob) - --- a/0dec01379d3b-changeset-description - +++ b/b7ea6d14e664-changeset-description + diff -r 0dec01379d3b -r b7ea6d14e664 changeset-description + --- a/changeset-description + +++ b/changeset-description @@ -1,1 +1,1 @@ -B0 +B1 @@ -1631,8 +1657,9 @@ | x fdf9bde5129a (2) A1 | rewritten(description) as 7a230b46bf61 by test (*) (glob) - | --- a/fdf9bde5129a-changeset-description - | +++ b/7a230b46bf61-changeset-description + | diff -r fdf9bde5129a -r 7a230b46bf61 changeset-description + | --- a/changeset-description + | +++ b/changeset-description | @@ -1,1 +1,1 @@ | -A1 | +A2 @@ -1640,8 +1667,9 @@ | x 471f378eab4c (1) A0 rewritten(description) as fdf9bde5129a by test (*) (glob) - --- a/471f378eab4c-changeset-description - +++ b/fdf9bde5129a-changeset-description + diff -r 471f378eab4c -r fdf9bde5129a changeset-description + --- a/changeset-description + +++ b/changeset-description @@ -1,1 +1,1 @@ -A0 +A1