From 66cc688282b437266682f3dec211e84efc331721 Mon Sep 17 00:00:00 2001
From: Matthew Pickering <matthewtpickering@gmail.com>
Date: Wed, 20 Jan 2016 14:09:14 +0100
Subject: [PATCH] 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.
---
 trac/ticket/notification.py | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/trac/ticket/notification.py b/trac/ticket/notification.py
index 8d7e963..7d6598e 100644
--- a/trac/ticket/notification.py
+++ b/trac/ticket/notification.py
@@ -40,6 +40,7 @@ from trac.util.text import exception_to_unicode, obfuscate_email_address, \
                            shorten_line, text_width, wrap
 from trac.util.translation import _, deactivate, reactivate
 from trac.web.chrome import Chrome
+from trac.versioncontrol.diff import unified_diff


 class TicketNotificationSystem(Component):
@@ -557,14 +558,13 @@ class TicketNotifyEmail(NotifyEmail):
                     if field == 'description':
                         new_descr = wrap(new, self.COLS, ' ', ' ', '\n',
                                          self.ambiwidth)
-                        old_descr = wrap(old, self.COLS, '> ', '> ', '\n',
+
+                        old_descr = wrap(old, self.COLS, ' ', ' ', '\n',
                                          self.ambiwidth)
-                        old_descr = old_descr.replace(2 * '\n', '\n' + '>' +
-                                                      '\n')
+                        diff = unified_diff(old_descr.split('\n'), new_descr.split('\n'), context=0)
                         cdescr = '\n'
-                        cdescr += 'Old description:' + 2 * '\n' + old_descr + \
-                                  2 * '\n'
-                        cdescr += 'New description:' + 2 * '\n' + new_descr + \
+                        cdescr += '\n'.join(diff)
+                        cdescr += '\n\nNew description:' + 2 * '\n' + new_descr + \
                                   '\n'
                         changes_descr = cdescr
                     elif field == 'summary':
--
2.1.4

