From 981150f90177d2d904d3e4776497bef3af264169 Mon Sep 17 00:00:00 2001 From: Correl Roush Date: Mon, 22 Nov 2010 01:13:50 -0500 Subject: [PATCH] Added paths to log view --- browser/urls.py | 2 +- browser/vcs.py | 2 +- browser/views.py | 10 ++++++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/browser/urls.py b/browser/urls.py index 8e2468a..92f3d6f 100644 --- a/browser/urls.py +++ b/browser/urls.py @@ -1,6 +1,6 @@ from django.conf.urls.defaults import * urlpatterns = patterns('', - (r'^(?P.*?)/log/$', 'codereview.browser.views.log'), + (r'^(?P.*?)/log/(?P(.*?/)+)?$', 'codereview.browser.views.log'), (r'^(?P.*?)/view/(?P.*?)/$', 'codereview.browser.views.view'), ) diff --git a/browser/vcs.py b/browser/vcs.py index 9b69158..782da36 100644 --- a/browser/vcs.py +++ b/browser/vcs.py @@ -144,7 +144,7 @@ class Git(VCS): def log(self, commit=None, path=None, max=50, offset=0): commit = commit if commit else self._ref result = [] - for c in self._repo.iter_commits(commit, path, max_count=max, + for c in self._repo.iter_commits(rev=commit, paths=path, max_count=max, skip=offset): result.append(self.commit(c)) return result diff --git a/browser/views.py b/browser/views.py index 7c929f9..61f4f84 100755 --- a/browser/views.py +++ b/browser/views.py @@ -1,9 +1,10 @@ +import os from django.http import Http404 from django.shortcuts import render_to_response from codereview.dashboard.models import Repository from codereview.browser import vcs -def log(request,repository): +def log(request,repository, path=None): try: repository = Repository.objects.get(name=repository) except: @@ -12,7 +13,10 @@ def log(request,repository): ref = request.GET['c'] if 'c' in request.GET else repo.ref() offset = int(request.GET['o']) if 'o' in request.GET else 0 limit = 20 - log = repo.log(ref, max=limit, offset=offset) + + path = os.path.dirname(path) if path else '' + log = repo.log(ref, path=path, max=limit, offset=offset) + navigation = dict(zip(('dirs', 'files'), repo.browse())) newer = offset - limit if offset > limit else 0 # Inspect the last commit. If it has no parents, we can't go any further @@ -23,8 +27,10 @@ def log(request,repository): return render_to_response('browser/log.html', { 'repository': repository, + 'path': path, 'repo': repo, 'log': log, + 'navigation': navigation, 'ref': ref, 'offset': offset, 'newer': newer,