+
+class DiffHandler(BaseHandler):
+ allowed_methods = ('GET',)
+
+ @hglibrary
+ def read(self, request, docid, lib):
+ '''Return diff between source_revision and target_revision)'''
+ revision = request.GET.get('revision')
+ if not revision:
+ return ''
+ source_document = lib.document(docid)
+ target_document = lib.document_for_revision(revision)
+ print source_document, target_document
+
+ diff = difflib.unified_diff(
+ source_document.data('xml').splitlines(True),
+ target_document.data('xml').splitlines(True),
+ 'source',
+ 'target')
+
+ s = ''.join(list(diff))
+ return highlight(s, DiffLexer(), HtmlFormatter(cssclass="pastie"))
+
+