Added paths to log view

This commit is contained in:
Correl Roush 2010-11-22 01:13:50 -05:00
parent e7285b2324
commit 981150f901
3 changed files with 10 additions and 4 deletions

View file

@ -1,6 +1,6 @@
from django.conf.urls.defaults import * from django.conf.urls.defaults import *
urlpatterns = patterns('', urlpatterns = patterns('',
(r'^(?P<repository>.*?)/log/$', 'codereview.browser.views.log'), (r'^(?P<repository>.*?)/log/(?P<path>(.*?/)+)?$', 'codereview.browser.views.log'),
(r'^(?P<repository>.*?)/view/(?P<ref>.*?)/$', 'codereview.browser.views.view'), (r'^(?P<repository>.*?)/view/(?P<ref>.*?)/$', 'codereview.browser.views.view'),
) )

View file

@ -144,7 +144,7 @@ class Git(VCS):
def log(self, commit=None, path=None, max=50, offset=0): def log(self, commit=None, path=None, max=50, offset=0):
commit = commit if commit else self._ref commit = commit if commit else self._ref
result = [] 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): skip=offset):
result.append(self.commit(c)) result.append(self.commit(c))
return result return result

View file

@ -1,9 +1,10 @@
import os
from django.http import Http404 from django.http import Http404
from django.shortcuts import render_to_response from django.shortcuts import render_to_response
from codereview.dashboard.models import Repository from codereview.dashboard.models import Repository
from codereview.browser import vcs from codereview.browser import vcs
def log(request,repository): def log(request,repository, path=None):
try: try:
repository = Repository.objects.get(name=repository) repository = Repository.objects.get(name=repository)
except: except:
@ -12,7 +13,10 @@ def log(request,repository):
ref = request.GET['c'] if 'c' in request.GET else repo.ref() ref = request.GET['c'] if 'c' in request.GET else repo.ref()
offset = int(request.GET['o']) if 'o' in request.GET else 0 offset = int(request.GET['o']) if 'o' in request.GET else 0
limit = 20 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 newer = offset - limit if offset > limit else 0
# Inspect the last commit. If it has no parents, we can't go any further # 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', return render_to_response('browser/log.html',
{ {
'repository': repository, 'repository': repository,
'path': path,
'repo': repo, 'repo': repo,
'log': log, 'log': log,
'navigation': navigation,
'ref': ref, 'ref': ref,
'offset': offset, 'offset': offset,
'newer': newer, 'newer': newer,