##// END OF EJS Templates
few validation bugfixes/ new repo changesets, first commit changesets
marcink -
r285:42f5c368 default
parent child Browse files
Show More
@@ -2,6 +2,16 b''
2 # encoding: utf-8
2 # encoding: utf-8
3 # changeset controller for pylons
3 # changeset controller for pylons
4 # Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
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 # This program is free software; you can redistribute it and/or
16 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
17 # modify it under the terms of the GNU General Public License
@@ -22,13 +32,6 b' Created on April 25, 2010'
22 changeset controller for pylons
32 changeset controller for pylons
23 @author: marcink
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 log = logging.getLogger(__name__)
37 log = logging.getLogger(__name__)
@@ -41,46 +44,53 b' class ChangesetController(BaseController'
41
44
42 def index(self, revision):
45 def index(self, revision):
43 hg_model = HgModel()
46 hg_model = HgModel()
44 c.changeset = hg_model.get_repo(c.repo_name).get_changeset(revision)
47 try:
45 c.changeset_old = c.changeset.parents[0]
48 c.changeset = hg_model.get_repo(c.repo_name).get_changeset(revision)
46 c.changes = []
49 except RepositoryError:
47
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:
76 for node in c.changeset.changed:
50 filenode_old = FileNode(node.path, '')
77 filenode_old = c.changeset_old.get_node(node.path)
51 if filenode_old.is_binary or node.is_binary:
78 if filenode_old.is_binary or node.is_binary:
52 diff = 'binary file'
79 diff = 'binary file'
53 else:
80 else:
54 f_udiff = differ.get_udiff(filenode_old, node)
81 f_udiff = differ.get_udiff(filenode_old, node)
55 diff = differ.DiffProcessor(f_udiff).as_html()
82 diff = differ.DiffProcessor(f_udiff).as_html()
56 try:
83 try:
57 diff = unicode(diff)
84 diff = unicode(diff)
58 except:
85 except:
59 log.warning('Decoding failed of %s', filenode_old)
86 log.warning('Decoding failed of %s', filenode_old)
60 log.warning('Decoding failed of %s', node)
87 log.warning('Decoding failed of %s', node)
61 diff = 'unsupported type'
88 diff = 'unsupported type'
62 cs1 = None
89 cs1 = filenode_old.last_changeset.raw_id
63 cs2 = node.last_changeset.raw_id
90 cs2 = node.last_changeset.raw_id
64 c.changes.append(('added', node, diff, cs1, cs2))
91 c.changes.append(('changed', node, diff, cs1, cs2))
65
92
66 for node in c.changeset.changed:
93 for node in c.changeset.removed:
67 filenode_old = c.changeset_old.get_node(node.path)
94 c.changes.append(('removed', node, None, None, None))
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))
85
95
86 return render('changeset/changeset.html')
96 return render('changeset/changeset.html')
@@ -26,7 +26,7 b''
26 <div class="date">${_('Date')}: ${c.changeset.date}</div>
26 <div class="date">${_('Date')}: ${c.changeset.date}</div>
27 <div class="author">${_('Author')}: ${c.changeset.author}</div>
27 <div class="author">${_('Author')}: ${c.changeset.author}</div>
28 <div class="message">
28 <div class="message">
29 ${c.changeset.message}
29 ${h.wrap_paragraphs(c.changeset.message)}
30 </div>
30 </div>
31 </div>
31 </div>
32 <div class="right">
32 <div class="right">
@@ -36,7 +36,7 b''
36 h.url('summary_home',repo_name=repo['name']))}</td>
36 h.url('summary_home',repo_name=repo['name']))}</td>
37 <td title="${repo['description']}">${h.truncate(repo['description'],60)}</td>
37 <td title="${repo['description']}">${h.truncate(repo['description'],60)}</td>
38 <td>${h.age(repo['last_change'])}</td>
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 h.url('changeset_home',repo_name=repo['name'],revision=repo['tip']),
40 h.url('changeset_home',repo_name=repo['name'],revision=repo['tip']),
41 class_="tooltip",
41 class_="tooltip",
42 tooltip_title=h.tooltip(repo['last_msg']))}</td>
42 tooltip_title=h.tooltip(repo['last_msg']))}</td>
General Comments 0
You need to be logged in to leave comments. Login now