diff -r 8aa3175fb6ae roundup/cgi/templating.py
--- a/roundup/cgi/templating.py Sat May 11 21:22:39 2013 +0530
+++ b/roundup/cgi/templating.py Thu May 16 21:58:55 2013 +0200
@@ -20,7 +20,7 @@
__docformat__ = 'restructuredtext'
-import cgi, urllib, re, os.path, mimetypes, csv
+import cgi, urllib, re, os.path, mimetypes, csv, difflib
import calendar, textwrap
from roundup import hyperdb, date, support
@@ -1043,12 +1043,13 @@
cell[-1] += ' -> %s'%current[k]
current[k] = val
- elif isinstance(prop, hyperdb.String) and args[k]:
- val = cgi.escape(args[k])
- cell.append('%s: %s'%(self._(k), val))
+ elif isinstance(prop, hyperdb.String):
if current.has_key(k):
- cell[-1] += ' -> %s'%current[k]
- current[k] = val
+ new_string = args[k] or ''
+ cell.append(self._string_history_diff(k,new_string,current[k]))
+ current[k] = new_string
+ else:
+ cell.append('%s: %s'%(self._(k), cgi.escape(args[k])))
elif isinstance(prop, hyperdb.Boolean) and args[k] is not None:
val = args[k] and ''"Yes" or ''"No"
@@ -1112,6 +1113,20 @@
l.append('')
return '\n'.join(l)
+ def _string_history_diff(self,k,new,current):
+ if '\n' in new or '\n' in current:
+ difftext = []
+ for diffline in difflib.ndiff(new.split('\n'),current.split('\n')):
+ try:
+ cls = _ndiff_classes[diffline[:1]]
+ except KeyError:
+ pass
+ else:
+ difftext.append("%s
" % (cls,cgi.escape(diffline[2:])))
+ return '%s: