changeset 145:3f01d02c2cc6

fixed error when browsing revisions on path that doesn't exist. Fixed files browsing. Fixed templates in branches and tags
author Marcin Kuzminski <marcin@python-works.com>
date Mon, 10 May 2010 23:12:45 +0200
parents ea89ac73bef8
children 8bd3ce1dace3
files pylons_app/controllers/files.py pylons_app/templates/branches/branches.html pylons_app/templates/files/files.html pylons_app/templates/files/files_browser.html pylons_app/templates/tags/tags.html
diffstat 5 files changed, 14 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/pylons_app/controllers/files.py	Sun May 09 17:35:51 2010 +0200
+++ b/pylons_app/controllers/files.py	Mon May 10 23:12:45 2010 +0200
@@ -8,7 +8,7 @@
 from pylons_app.model.hg_model import HgModel
 from difflib import unified_diff
 from pylons_app.lib.differ import render_udiff
-from vcs.exceptions import RepositoryError
+from vcs.exceptions import RepositoryError, ChangesetError
         
 log = logging.getLogger(__name__)
 
@@ -18,9 +18,18 @@
         c.repo_name = get_repo_slug(request)
 
     def index(self, repo_name, revision, f_path):
-        revision = request.POST.get('at_rev', None) or revision
         hg_model = HgModel()
         c.repo = repo = hg_model.get_repo(c.repo_name)
+        
+        revision = request.POST.get('at_rev', None) or revision
+        if request.POST.get('view_low'):
+            revision = int(revision) - 1
+        if request.POST.get('view_high'):
+            revision = int(revision) + 1
+            max_rev = len(c.repo.revisions) - 1
+            if revision > max_rev:
+                revision = max_rev
+                
         c.f_path = f_path
         try:
             c.changeset = repo.get_changeset(repo._get_revision(revision))
@@ -28,7 +37,7 @@
             c.rev_nr = c.changeset.revision
             c.files_list = c.changeset.get_node(f_path)
             c.file_history = self._get_history(repo, c.files_list, f_path)
-        except RepositoryError:
+        except (RepositoryError, ChangesetError):
             c.files_list = None
         
         return render('files/files.html')
--- a/pylons_app/templates/branches/branches.html	Sun May 09 17:35:51 2010 +0200
+++ b/pylons_app/templates/branches/branches.html	Mon May 10 23:12:45 2010 +0200
@@ -28,7 +28,6 @@
 		%for cnt,branch in enumerate(c.repo_branches):
 		<tr class="parity${cnt%2}">
 			<td>${branch._ctx.date()|n,filters.age}</td>
-			<td></td>
 			<td>
 				<span class="logtags">
 					<span class="branchtag">${h.link_to(branch.branch,h.url('changeset_home',repo_name=c.repo_name,revision=branch._short))}</span>
--- a/pylons_app/templates/files/files.html	Sun May 09 17:35:51 2010 +0200
+++ b/pylons_app/templates/files/files.html	Mon May 10 23:12:45 2010 +0200
@@ -36,7 +36,7 @@
 				<%include file='files_source.html'/>			
 			%endif	
 	%else:
-		<h2>${_('No files')}</h2>
+		<h2><a href="#" onClick="javascript:parent.history.back();" target="main">${_('Go back')}</a> ${_('No files at given path')}: "${c.f_path or "/"}" </h2>
 	%endif
 
 	</div>
--- a/pylons_app/templates/files/files_browser.html	Sun May 09 17:35:51 2010 +0200
+++ b/pylons_app/templates/files/files_browser.html	Mon May 10 23:12:45 2010 +0200
@@ -8,7 +8,7 @@
 <div id="body" class="browserblock">
 	<div class="browser-header">
 		${h.form(h.url.current())}
-		<span>${_('view')}@rev:${h.text('at_rev',value=c.rev_nr,size='5')}</span>
+		<span>${_('view')}@rev ${h.submit('view_low','-')}${h.text('at_rev',value=c.rev_nr,size='5')}${h.submit('view_high','+')}</span>
 		${h.submit('view','view')}
 		${h.end_form()}
 	</div>
--- a/pylons_app/templates/tags/tags.html	Sun May 09 17:35:51 2010 +0200
+++ b/pylons_app/templates/tags/tags.html	Mon May 10 23:12:45 2010 +0200
@@ -30,7 +30,6 @@
 		%for cnt,tag in enumerate(c.repo_tags):
 		<tr class="parity${cnt%2}">
 			<td>${tag._ctx.date()|n,filters.age}</td>
-			<td></td>
 			<td>
 				<span class="logtags">
 					<span class="tagtag">${h.link_to(tag.tags[-1],h.url('changeset_home',repo_name=c.repo_name,revision=tag._short))}</span>