Skip to content

Commit 5e08694

Browse files
mpickeringbgamari
authored andcommittedApr 11, 2017
Add delta to ticket modification notification
Instead of the previously useless notification which displayed both the new and old description. We now display the delta and the new description.
1 parent 5208d6a commit 5e08694

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed
 

‎trac/ticket/notification.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
shorten_line, text_width, wrap
3838
from trac.util.translation import _
3939
from trac.web.chrome import Chrome
40+
from trac.versioncontrol.diff import unified_diff
4041

4142

4243
class TicketNotificationSystem(Component):
@@ -573,14 +574,13 @@ def _prepare_body(self, ticket, newticket, modtime):
573574
if field == 'description':
574575
new_descr = wrap(new, self.COLS, ' ', ' ', '\n',
575576
self.ambiwidth)
576-
old_descr = wrap(old, self.COLS, '> ', '> ', '\n',
577+
old_descr = wrap(old, self.COLS, ' ', ' ', '\n',
577578
self.ambiwidth)
578-
old_descr = old_descr.replace(2 * '\n', '\n' + '>' +
579-
'\n')
579+
diff = unified_diff(old_descr.split('\n'), new_descr.split('\n'), context=0)
580+
580581
cdescr = '\n'
581-
cdescr += 'Old description:' + 2 * '\n' + old_descr + \
582-
2 * '\n'
583-
cdescr += 'New description:' + 2 * '\n' + new_descr + \
582+
cdescr += '\n'.join(diff)
583+
cdescr += '\n\nNew description:' + 2 * '\n' + new_descr + \
584584
'\n'
585585
changes_descr = cdescr
586586
elif field == 'summary':

0 commit comments

Comments
 (0)
Please sign in to comment.