Changeset - 42f5c36820ef
[Not reviewed]
default
0 3 0
Marcin Kuzminski - 15 years ago 2010-06-14 01:16:57
marcin@python-works.com
few validation bugfixes/ new repo changesets, first commit changesets
3 files changed with 20 insertions and 10 deletions:
0 comments (0 inline, 0 general)
pylons_app/controllers/changeset.py
Show inline comments
 
#!/usr/bin/env python
 
# encoding: utf-8
 
# changeset controller for pylons
 
# Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
 
from pylons import tmpl_context as c, url
 
from pylons.controllers.util import redirect
 
from pylons_app.lib.auth import LoginRequired
 
from pylons_app.lib.base import BaseController, render
 
from pylons_app.model.hg_model import HgModel
 
from vcs.exceptions import RepositoryError
 
from vcs.nodes import FileNode
 
from vcs.utils import diffs as differ
 
import logging
 
import traceback
 
 
 
# This program is free software; you can redistribute it and/or
 
# modify it under the terms of the GNU General Public License
 
# as published by the Free Software Foundation; version 2
 
# of the License or (at your opinion) any later version of the license.
 
# 
 
# This program is distributed in the hope that it will be useful,
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
# GNU General Public License for more details.
 
# 
 
# You should have received a copy of the GNU General Public License
 
# along with this program; if not, write to the Free Software
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 
# MA  02110-1301, USA.
 
"""
 
Created on April 25, 2010
 
changeset controller for pylons
 
@author: marcink
 
"""
 
from pylons import tmpl_context as c
 
from pylons_app.lib.auth import LoginRequired
 
from pylons_app.lib.base import BaseController, render
 
from pylons_app.model.hg_model import HgModel
 
from vcs.utils import diffs as differ
 
import logging
 
from vcs.nodes import FileNode
 

	
 

	
 
log = logging.getLogger(__name__)
 

	
 
class ChangesetController(BaseController):
 
    
 
    @LoginRequired()
 
    def __before__(self):
 
        super(ChangesetController, self).__before__()
 
        
 
    def index(self, revision):
 
        hg_model = HgModel()
 
        try:
 
        c.changeset = hg_model.get_repo(c.repo_name).get_changeset(revision)
 
        except RepositoryError:
 
            log.error(traceback.format_exc())
 
            return redirect(url('hg_home'))
 
        else:
 
            try:
 
        c.changeset_old = c.changeset.parents[0]
 
            except IndexError:
 
                c.changeset_old = None
 
        c.changes = []
 
        
 
                
 
        for node in c.changeset.added:
 
            filenode_old = FileNode(node.path, '')
 
            if filenode_old.is_binary or node.is_binary:
 
                diff = 'binary file'
 
            else:    
 
                f_udiff = differ.get_udiff(filenode_old, node)
 
                diff = differ.DiffProcessor(f_udiff).as_html()
 
                try:
 
                    diff = unicode(diff)
 
                except:
 
                    log.warning('Decoding failed of %s', filenode_old)
 
                    log.warning('Decoding failed of %s', node)
pylons_app/templates/changeset/changeset.html
Show inline comments
 
@@ -17,25 +17,25 @@
 
<link rel="stylesheet" href="/css/monoblue_custom.css" type="text/css" />
 
<link rel="stylesheet" href="/css/diff.css" type="text/css" />
 
</%def>
 
<%def name="main()">
 
    <h2 class="no-link no-border">${_('Changeset')} - r${c.changeset.revision}:${c.changeset.raw_id}</h2>
 
    
 
    <div id="changeset_content">
 
		<div class="container">
 
			<div class="left">
 
				<div class="date">${_('Date')}: ${c.changeset.date}</div>
 
				<div class="author">${_('Author')}: ${c.changeset.author}</div>
 
				<div class="message">
 
					${c.changeset.message}
 
					${h.wrap_paragraphs(c.changeset.message)}
 
				</div>
 
			</div>	
 
			<div class="right">
 
				<span class="logtags">
 
					<span class="branchtag">${c.changeset.branch}</span>
 
					%for tag in c.changeset.tags:
 
						<span class="tagtag">${tag}</span>
 
					%endfor
 
				</span>					
 
				%if len(c.changeset.parents)>1:
 
				<div class="merge">		
 
				${_('merge')}
pylons_app/templates/index.html
Show inline comments
 
@@ -27,25 +27,25 @@
 
	    <td>${get_sort(_('Last change'))}</td>
 
	    <td>${get_sort(_('Tip'))}</td>
 
	    <td>${get_sort(_('Contact'))}</td>
 
	    <td>${_('RSS')}</td>
 
	    <td>${_('Atom')}</td>
 
	  </tr>	
 
	%for cnt,repo in enumerate(c.repos_list):
 
 		<tr class="parity${cnt%2}">
 
		    <td>${h.link_to(repo['name'],
 
		    	h.url('summary_home',repo_name=repo['name']))}</td>
 
		    <td title="${repo['description']}">${h.truncate(repo['description'],60)}</td>
 
	        <td>${h.age(repo['last_change'])}</td>
 
	        <td>${h.link_to('r%s:%s' % (repo['rev'],repo['tip']),
 
	        <td>${h.link_to_if(repo['rev']>=0,'r%s:%s' % (repo['rev'],repo['tip']),
 
		        h.url('changeset_home',repo_name=repo['name'],revision=repo['tip']),
 
	        	class_="tooltip",
 
		    	tooltip_title=h.tooltip(repo['last_msg']))}</td>
 
	        <td title="${repo['contact']}">${h.person(repo['contact'])}</td>
 
			<td>
 
				<a title="${_('Subscribe to %s rss feed')%repo['name']}" class="rss_logo"  href="${h.url('rss_feed_home',repo_name=repo['name'])}"></a>
 
			</td>        
 
			<td>
 
				<a title="${_('Subscribe to %s atom feed')%repo['name']}"  class="atom_logo" href="${h.url('atom_feed_home',repo_name=repo['name'])}"></a>
 
			</td>
 
		</tr>
 
	%endfor
0 comments (0 inline, 0 general)