@library.global_function
def revisions_unified_diff(from_revision, to_revision):
 if ((from_revision is None) or (to_revision is None)):
  return 'Diff is unavailable.'
 fromfile = ('[%s] #%s' % (from_revision.document.locale, from_revision.id))
 tofile = ('[%s] #%s' % (to_revision.document.locale, to_revision.id))
 tidy_from = from_revision.get_tidied_content()
 tidy_to = to_revision.get_tidied_content()
 return u'\n'.join(difflib.unified_diff(tidy_from.splitlines(), tidy_to.splitlines(), fromfile=fromfile, tofile=tofile))

@ library . global_function def revisions_unified_diff ( from_revision , to_revision ) : if ( ( from_revision is None ) or ( to_revision is None ) ) : return 'Diff is unavailable.' fromfile = ( '[%s] #%s' % ( from_revision . document . locale , from_revision . id ) ) tofile = ( '[%s] #%s' % ( to_revision . document . locale , to_revision . id ) ) tidy_from = from_revision . get_tidied_content ( ) tidy_to = to_revision . get_tidied_content ( ) return u'\n' . join ( difflib . unified_diff ( tidy_from . splitlines ( ) , tidy_to . splitlines ( ) , fromfile = fromfile , tofile = tofile ) )
given the two revisions generate a diff between their tidied content in the unified diff format .