##// END OF EJS Templates
few validation bugfixes/ new repo changesets, first commit changesets
marcink -
r285:42f5c368 default
parent child Browse files
Show More
@@ -1,86 +1,96 b''
1 1 #!/usr/bin/env python
2 2 # encoding: utf-8
3 3 # changeset controller for pylons
4 4 # Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
5 from pylons import tmpl_context as c, url
6 from pylons.controllers.util import redirect
7 from pylons_app.lib.auth import LoginRequired
8 from pylons_app.lib.base import BaseController, render
9 from pylons_app.model.hg_model import HgModel
10 from vcs.exceptions import RepositoryError
11 from vcs.nodes import FileNode
12 from vcs.utils import diffs as differ
13 import logging
14 import traceback
5 15
6 16 # This program is free software; you can redistribute it and/or
7 17 # modify it under the terms of the GNU General Public License
8 18 # as published by the Free Software Foundation; version 2
9 19 # of the License or (at your opinion) any later version of the license.
10 20 #
11 21 # This program is distributed in the hope that it will be useful,
12 22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 24 # GNU General Public License for more details.
15 25 #
16 26 # You should have received a copy of the GNU General Public License
17 27 # along with this program; if not, write to the Free Software
18 28 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 29 # MA 02110-1301, USA.
20 30 """
21 31 Created on April 25, 2010
22 32 changeset controller for pylons
23 33 @author: marcink
24 34 """
25 from pylons import tmpl_context as c
26 from pylons_app.lib.auth import LoginRequired
27 from pylons_app.lib.base import BaseController, render
28 from pylons_app.model.hg_model import HgModel
29 from vcs.utils import diffs as differ
30 import logging
31 from vcs.nodes import FileNode
32 35
33 36
34 37 log = logging.getLogger(__name__)
35 38
36 39 class ChangesetController(BaseController):
37 40
38 41 @LoginRequired()
39 42 def __before__(self):
40 43 super(ChangesetController, self).__before__()
41 44
42 45 def index(self, revision):
43 46 hg_model = HgModel()
44 c.changeset = hg_model.get_repo(c.repo_name).get_changeset(revision)
45 c.changeset_old = c.changeset.parents[0]
46 c.changes = []
47
47 try:
48 c.changeset = hg_model.get_repo(c.repo_name).get_changeset(revision)
49 except RepositoryError:
50 log.error(traceback.format_exc())
51 return redirect(url('hg_home'))
52 else:
53 try:
54 c.changeset_old = c.changeset.parents[0]
55 except IndexError:
56 c.changeset_old = None
57 c.changes = []
58
59 for node in c.changeset.added:
60 filenode_old = FileNode(node.path, '')
61 if filenode_old.is_binary or node.is_binary:
62 diff = 'binary file'
63 else:
64 f_udiff = differ.get_udiff(filenode_old, node)
65 diff = differ.DiffProcessor(f_udiff).as_html()
66 try:
67 diff = unicode(diff)
68 except:
69 log.warning('Decoding failed of %s', filenode_old)
70 log.warning('Decoding failed of %s', node)
71 diff = 'unsupported type'
72 cs1 = None
73 cs2 = node.last_changeset.raw_id
74 c.changes.append(('added', node, diff, cs1, cs2))
48 75
49 for node in c.changeset.added:
50 filenode_old = FileNode(node.path, '')
51 if filenode_old.is_binary or node.is_binary:
52 diff = 'binary file'
53 else:
54 f_udiff = differ.get_udiff(filenode_old, node)
55 diff = differ.DiffProcessor(f_udiff).as_html()
56 try:
57 diff = unicode(diff)
58 except:
59 log.warning('Decoding failed of %s', filenode_old)
60 log.warning('Decoding failed of %s', node)
61 diff = 'unsupported type'
62 cs1 = None
63 cs2 = node.last_changeset.raw_id
64 c.changes.append(('added', node, diff, cs1, cs2))
65
66 for node in c.changeset.changed:
67 filenode_old = c.changeset_old.get_node(node.path)
68 if filenode_old.is_binary or node.is_binary:
69 diff = 'binary file'
70 else:
71 f_udiff = differ.get_udiff(filenode_old, node)
72 diff = differ.DiffProcessor(f_udiff).as_html()
73 try:
74 diff = unicode(diff)
75 except:
76 log.warning('Decoding failed of %s', filenode_old)
77 log.warning('Decoding failed of %s', node)
78 diff = 'unsupported type'
79 cs1 = filenode_old.last_changeset.raw_id
80 cs2 = node.last_changeset.raw_id
81 c.changes.append(('changed', node, diff, cs1, cs2))
82
83 for node in c.changeset.removed:
84 c.changes.append(('removed', node, None, None, None))
76 for node in c.changeset.changed:
77 filenode_old = c.changeset_old.get_node(node.path)
78 if filenode_old.is_binary or node.is_binary:
79 diff = 'binary file'
80 else:
81 f_udiff = differ.get_udiff(filenode_old, node)
82 diff = differ.DiffProcessor(f_udiff).as_html()
83 try:
84 diff = unicode(diff)
85 except:
86 log.warning('Decoding failed of %s', filenode_old)
87 log.warning('Decoding failed of %s', node)
88 diff = 'unsupported type'
89 cs1 = filenode_old.last_changeset.raw_id
90 cs2 = node.last_changeset.raw_id
91 c.changes.append(('changed', node, diff, cs1, cs2))
92
93 for node in c.changeset.removed:
94 c.changes.append(('removed', node, None, None, None))
85 95
86 96 return render('changeset/changeset.html')
@@ -1,92 +1,92 b''
1 1 <%inherit file="/base/base.html"/>
2 2
3 3 <%def name="title()">
4 4 ${_('Changeset')}
5 5 </%def>
6 6 <%def name="breadcrumbs()">
7 7 ${h.link_to(u'Home',h.url('/'))}
8 8 /
9 9 ${h.link_to(c.repo_name,h.url('changeset_home',repo_name=c.repo_name))}
10 10 /
11 11 ${_('changeset')}
12 12 </%def>
13 13 <%def name="page_nav()">
14 14 ${self.menu('changelog')}
15 15 </%def>
16 16 <%def name="css()">
17 17 <link rel="stylesheet" href="/css/monoblue_custom.css" type="text/css" />
18 18 <link rel="stylesheet" href="/css/diff.css" type="text/css" />
19 19 </%def>
20 20 <%def name="main()">
21 21 <h2 class="no-link no-border">${_('Changeset')} - r${c.changeset.revision}:${c.changeset.raw_id}</h2>
22 22
23 23 <div id="changeset_content">
24 24 <div class="container">
25 25 <div class="left">
26 26 <div class="date">${_('Date')}: ${c.changeset.date}</div>
27 27 <div class="author">${_('Author')}: ${c.changeset.author}</div>
28 28 <div class="message">
29 ${c.changeset.message}
29 ${h.wrap_paragraphs(c.changeset.message)}
30 30 </div>
31 31 </div>
32 32 <div class="right">
33 33 <span class="logtags">
34 34 <span class="branchtag">${c.changeset.branch}</span>
35 35 %for tag in c.changeset.tags:
36 36 <span class="tagtag">${tag}</span>
37 37 %endfor
38 38 </span>
39 39 %if len(c.changeset.parents)>1:
40 40 <div class="merge">
41 41 ${_('merge')}
42 42 <img alt="merge" src="/images/icons/arrow_join.png">
43 43 </div>
44 44 %endif
45 45 %for p_cs in reversed(c.changeset.parents):
46 46 <div class="parent">${_('Parent')} ${p_cs.revision}: ${h.link_to(p_cs.raw_id,
47 47 h.url('changeset_home',repo_name=c.repo_name,revision=p_cs.raw_id),title=p_cs.message)}
48 48 </div>
49 49 %endfor
50 50 </div>
51 51 </div>
52 52 </div>
53 53
54 54 <div style="clear:both;height:10px"></div>
55 55 <div class="cs_files">
56 56 %for change,filenode,diff,cs1,cs2 in c.changes:
57 57 <div class="cs_${change}">${h.link_to(filenode.path,h.url.current(anchor='CHANGE-%s'%filenode.path))}</div>
58 58 %endfor
59 59 </div>
60 60
61 61 %for change,filenode,diff,cs1,cs2 in c.changes:
62 62 %if change !='removed':
63 63 <div style="clear:both;height:10px"></div>
64 64 <div id="body" class="diffblock">
65 65 <div id="${'CHANGE-%s'%filenode.path}" class="code-header">
66 66 <div>
67 67 <span>
68 68 ${h.link_to_if(change!='removed',filenode.path,h.url('files_home',repo_name=c.repo_name,
69 69 revision=filenode.changeset.raw_id,f_path=filenode.path))}
70 70 </span>
71 71 %if 1:
72 72 &raquo; <span style="font-size:77%">${h.link_to(_('diff'),
73 73 h.url('files_diff_home',repo_name=c.repo_name,f_path=filenode.path,diff2=cs2,diff1=cs1,diff='diff'))}</span>
74 74 &raquo; <span style="font-size:77%">${h.link_to(_('raw diff'),
75 75 h.url('files_diff_home',repo_name=c.repo_name,f_path=filenode.path,diff2=cs2,diff1=cs1,diff='raw'))}</span>
76 76 &raquo; <span style="font-size:77%">${h.link_to(_('download diff'),
77 77 h.url('files_diff_home',repo_name=c.repo_name,f_path=filenode.path,diff2=cs2,diff1=cs1,diff='download'))}</span>
78 78 %endif
79 79 </div>
80 80 </div>
81 81 <div class="code-body">
82 82 %if diff:
83 83 ${diff|n}
84 84 %else:
85 85 ${_('No changes in this file')}
86 86 %endif
87 87 </div>
88 88 </div>
89 89 %endif
90 90 %endfor
91 91
92 92 </%def> No newline at end of file
@@ -1,53 +1,53 b''
1 1 ## -*- coding: utf-8 -*-
2 2 <%inherit file="base/base.html"/>
3 3 <%def name="title()">
4 4 ${c.repos_prefix} Mercurial Repositories
5 5 </%def>
6 6 <%def name="breadcrumbs()">
7 7 ${c.repos_prefix} Mercurial Repositories
8 8 </%def>
9 9 <%def name="page_nav()">
10 10 ${self.menu('home')}
11 11 </%def>
12 12 <%def name="main()">
13 13 <%def name="get_sort(name)">
14 14 <%name_slug = name.lower().replace(' ','_') %>
15 15 %if name_slug == c.cs_slug:
16 16 <span style="font-weight: bold;text-decoration: underline;">${name}</span>
17 17 %else:
18 18 <span style="font-weight: bold">${name}</span>
19 19 %endif
20 20 <a style="color:#FFF" href="?sort=${name_slug}">&darr;</a>
21 21 <a style="color:#FFF" href="?sort=-${name_slug}">&uarr;</a>
22 22 </%def>
23 23 <table class="table_disp">
24 24 <tr class="header">
25 25 <td>${get_sort(_('Name'))}</td>
26 26 <td>${get_sort(_('Description'))}</td>
27 27 <td>${get_sort(_('Last change'))}</td>
28 28 <td>${get_sort(_('Tip'))}</td>
29 29 <td>${get_sort(_('Contact'))}</td>
30 30 <td>${_('RSS')}</td>
31 31 <td>${_('Atom')}</td>
32 32 </tr>
33 33 %for cnt,repo in enumerate(c.repos_list):
34 34 <tr class="parity${cnt%2}">
35 35 <td>${h.link_to(repo['name'],
36 36 h.url('summary_home',repo_name=repo['name']))}</td>
37 37 <td title="${repo['description']}">${h.truncate(repo['description'],60)}</td>
38 38 <td>${h.age(repo['last_change'])}</td>
39 <td>${h.link_to('r%s:%s' % (repo['rev'],repo['tip']),
39 <td>${h.link_to_if(repo['rev']>=0,'r%s:%s' % (repo['rev'],repo['tip']),
40 40 h.url('changeset_home',repo_name=repo['name'],revision=repo['tip']),
41 41 class_="tooltip",
42 42 tooltip_title=h.tooltip(repo['last_msg']))}</td>
43 43 <td title="${repo['contact']}">${h.person(repo['contact'])}</td>
44 44 <td>
45 45 <a title="${_('Subscribe to %s rss feed')%repo['name']}" class="rss_logo" href="${h.url('rss_feed_home',repo_name=repo['name'])}"></a>
46 46 </td>
47 47 <td>
48 48 <a title="${_('Subscribe to %s atom feed')%repo['name']}" class="atom_logo" href="${h.url('atom_feed_home',repo_name=repo['name'])}"></a>
49 49 </td>
50 50 </tr>
51 51 %endfor
52 52 </table>
53 53 </%def>
General Comments 0
You need to be logged in to leave comments. Login now