diff --git a/browser/urls.py b/browser/urls.py index 9607843..7c70d21 100644 --- a/browser/urls.py +++ b/browser/urls.py @@ -10,4 +10,7 @@ urlpatterns = patterns('', # Commit view (r'^(?P.*?)/commit/(?P.*?)/$', 'codereview.browser.views.commit'), + # Diff view + (r'^(?P.*?)/diff/$', + 'codereview.browser.views.diff'), ) diff --git a/browser/views.py b/browser/views.py index 1491552..6728133 100755 --- a/browser/views.py +++ b/browser/views.py @@ -74,6 +74,34 @@ def commit(request, repository, ref): }) return render_to_response('browser/view.html', data) @permission_required('dashboard.browse') +def diff(request, repository): + if not request.GET: + raise Http404 + if not request.GET['a']: + raise Http404 + try: + repository = Repository.objects.get(name=repository) + repo = vcs.create(repository.type, repository.path) + a = request.GET['a'] + commit_a = repo.commit(a) + b = None + if request.GET['b']: + b = request.GET['b'] + elif commit_a.parents: + b = commit_a.parents[0] + commit_b = repo.commit(b) + diffs = repo.diff(b, a) + except: + raise Http404 + data = RequestContext(request, { + 'repository': repository, + 'repo': repo, + 'a': commit_a, + 'b': commit_b, + 'diffs': diffs, + }) + return render_to_response('browser/diff.html', data) +@permission_required('dashboard.browse') def blob(request, repository, path): repo, ref = _repo(request, repository) data = RequestContext(request, { diff --git a/templates/browser/diff.html b/templates/browser/diff.html new file mode 100644 index 0000000..89c009f --- /dev/null +++ b/templates/browser/diff.html @@ -0,0 +1,27 @@ +{% extends "layouts/default.html" %} +{% load gravatar %} +{% load vcs %} + +{% block navigation %} +{% include "browser/navigation.html" %} +{% endblock %} + +{% block content %} +

Diff View

+{{ a.id }} => {{ b.id }} +{% comment %} +** ADD THIS WHEN REVIEWS SUPPORT MANUAL A/B DIFFS ** +
+ {{ form }} + {% csrf_token %} + +
+{% endcomment %} +
+
+ {% for diff in diffs %} + {% include "components/diff.html" %} + {% endfor %} +
+
+{% endblock %} diff --git a/templates/browser/log.html b/templates/browser/log.html index 4b11b26..92fb92e 100644 --- a/templates/browser/log.html +++ b/templates/browser/log.html @@ -5,5 +5,11 @@ {% endblock %} {% block content %} +
+ + + + +
{% include "browser/commitlog.html" %} {% endblock %}