Bug#908992: diffoscope: side-by-side diff for terminal output

Chris Lamb lamby at debian.org
Mon Nov 26 21:58:18 GMT 2018


Hi Paul,

> The HTML output uses a side-by-side diff but the terminal output uses
> `diff -u` style output. It would be nice to have an option for
> side-by-side diffs with the terminal output. The icdiff package
> contains a Python 3 module that could be used for this.

I think this could be made to work. As a demo, I just knocked
together:

  --- a/diffoscope/diff.py
  +++ b/diffoscope/diff.py
  @@ -324,7 +324,11 @@ def diff(feeder1, feeder2):
       fifo2_path = os.path.join(tmpdir, 'fifo2')
       with FIFOFeeder(feeder1, fifo1_path) as fifo1, \
               FIFOFeeder(feeder2, fifo2_path) as fifo2:
  -        return run_diff(fifo1_path, fifo2_path, fifo1.end_nl_q, fifo2.end_nl_q)
  +        from icdiff import ConsoleDiff
  +        cd = ConsoleDiff(cols=100)
  +        lines_1 = open(fifo1_path).readlines()
  +        lines_2 = open(fifo2_path).readlines()
  +        return '\n'.join(cd.make_table(lines_1, lines_2, '', '', numlines=7))
   
... which resulted in the attached.

One difficulty however will be in passing in a sane value of `cols` to
ConsoleDiff; not because it's difficult to obtain (see icdiff.py for
this terminal foo) but rather we need to subtract 2 or 3 for each
indentation/recursion level and we may not know that at the time we
run icdiff.


Best wishes,

-- 
      ,''`.
     : :'  :     Chris Lamb
     `. `'`      lamby at debian.org / chris-lamb.co.uk
       `-
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 2018-11-26_22-55.png
Type: image/png
Size: 6700 bytes
Desc: not available
URL: <http://alioth-lists.debian.net/pipermail/reproducible-builds/attachments/20181126/9a716939/attachment.png>


More information about the Reproducible-builds mailing list