def revision_diff(request, slug):
    if request.GET.get('a', '').isdigit() and request.GET.get('b', '').isdigit():
        a = int(request.GET.get('a'))
        b = int(request.GET.get('b'))
    else:
        return HttpResponseBadRequest(u'You must select two revisions.')

    try:
        page = Page.objects.filter(slug=slug).get()
        revisionA = Revision.objects.filter(page=page, pk=a).get()
        revisionB = Revision.objects.filter(page=page, pk=b).get()
    except __HOLE__:
        raise Http404, "No revision found matching the query"

    if not page.has_read_permission(request.user):
        if request.user.is_anonymous():
            return HttpResponseRedirect('%s?%s=%s' % (settings.LOGIN_URL, REDIRECT_FIELD_NAME, urlquote(request.get_full_path())))
        else:
            return render_to_response('wiki/permission_denied.html', context_instance=RequestContext(request))

    if revisionA.content != revisionB.content:
        d = difflib.unified_diff(
            revisionA.content.splitlines(),
            revisionB.content.splitlines(),
            'Revision %s' % revisionA.pk,
            'Revision %s' % revisionB.pk,
            lineterm=''
        )
    
        difftext = '\n'.join(d)
        difftext = pygments_diff(difftext)
    else:
        difftext = _('No changes were made between this two revisions.')
    
    template_context = {
        'page': page,
        'revisionA': revisionA,
        'revisionB': revisionB,
        'difftext': difftext,
    }
    
    return render_to_response('wiki/revision_diff.html', template_context, RequestContext(request))
dataset/ETHPy150Open kylef-archive/lithium/lithium/wiki/views.py/revision_diff