2
# Copyright (C) 2008 Canonical Ltd.
3
# (Authored by Martin Albisetti <argentina@gmail.com>)
2
4
# Copyright (C) 2006 Robey Pointer <robey@lag.net>
3
5
# Copyright (C) 2006 Goffredo Baroncelli <kreijack@inwind.it>
4
6
# Copyright (C) 2005 Jake Edge <jake@edge2.net>
91
93
out_chunk_list = []
92
94
for chunk in chunk_list:
94
97
delete_list, insert_list = [], []
95
98
for line in chunk.diff:
99
# Add <wbr/> every X characters so we can wrap properly
100
wrap_line = re.findall(r'.{%d}|.+$' % 78, line.line)
101
wrap_lines = [util.html_clean(_line) for _line in wrap_line]
102
wrapped_line = wrap_char.join(wrap_lines)
96
104
if line.type == 'context':
97
105
if len(delete_list) or len(insert_list):
98
_process_side_by_side_buffers(line_list, delete_list, insert_list)
106
_process_side_by_side_buffers(line_list, delete_list,
99
108
delete_list, insert_list = [], []
100
line_list.append(util.Container(old_lineno=line.old_lineno, new_lineno=line.new_lineno,
101
old_line=line.line, new_line=line.line,
102
old_type=line.type, new_type=line.type))
109
line_list.append(util.Container(old_lineno=line.old_lineno,
110
new_lineno=line.new_lineno,
111
old_line=wrapped_line,
112
new_line=wrapped_line,
103
115
elif line.type == 'delete':
104
delete_list.append((line.old_lineno, line.line, line.type))
116
delete_list.append((line.old_lineno, wrapped_line, line.type))
105
117
elif line.type == 'insert':
106
insert_list.append((line.new_lineno, line.line, line.type))
118
insert_list.append((line.new_lineno, wrapped_line, line.type))
107
119
if len(delete_list) or len(insert_list):
108
120
_process_side_by_side_buffers(line_list, delete_list, insert_list)
109
121
out_chunk_list.append(util.Container(diff=line_list))
686
698
old_lineno = lines[0]
687
699
new_lineno = lines[1]
688
700
elif line.startswith(' '):
689
chunk.diff.append(util.Container(old_lineno=old_lineno, new_lineno=new_lineno,
690
type='context', line=util.fixed_width(line[1:])))
701
chunk.diff.append(util.Container(old_lineno=old_lineno,
702
new_lineno=new_lineno,
693
707
elif line.startswith('+'):
694
chunk.diff.append(util.Container(old_lineno=None, new_lineno=new_lineno,
695
type='insert', line=util.fixed_width(line[1:])))
708
chunk.diff.append(util.Container(old_lineno=None,
709
new_lineno=new_lineno,
710
type='insert', line=line[1:]))
697
712
elif line.startswith('-'):
698
chunk.diff.append(util.Container(old_lineno=old_lineno, new_lineno=None,
699
type='delete', line=util.fixed_width(line[1:])))
713
chunk.diff.append(util.Container(old_lineno=old_lineno,
715
type='delete', line=line[1:]))
702
chunk.diff.append(util.Container(old_lineno=None, new_lineno=None,
703
type='unknown', line=util.fixed_width(repr(line))))
718
chunk.diff.append(util.Container(old_lineno=None,
704
722
if chunk is not None:
705
723
chunks.append(chunk)