annotate pylons_app/controllers/changeset.py @ 279:ba0523f440d2

#2: proposed changes to shortlog added header table description
author Marcin Kuzminski <marcin@python-works.com>
date Sun, 13 Jun 2010 16:33:22 +0200
parents cad478edb1c7
children 42f5c36820ef
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
252
3782a6d698af licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 245
diff changeset
1 #!/usr/bin/env python
3782a6d698af licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 245
diff changeset
2 # encoding: utf-8
3782a6d698af licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 245
diff changeset
3 # changeset controller for pylons
3782a6d698af licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 245
diff changeset
4 # Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
3782a6d698af licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 245
diff changeset
5
3782a6d698af licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 245
diff changeset
6 # This program is free software; you can redistribute it and/or
3782a6d698af licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 245
diff changeset
7 # modify it under the terms of the GNU General Public License
3782a6d698af licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 245
diff changeset
8 # as published by the Free Software Foundation; version 2
3782a6d698af licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 245
diff changeset
9 # of the License or (at your opinion) any later version of the license.
3782a6d698af licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 245
diff changeset
10 #
3782a6d698af licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 245
diff changeset
11 # This program is distributed in the hope that it will be useful,
3782a6d698af licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 245
diff changeset
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
3782a6d698af licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 245
diff changeset
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3782a6d698af licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 245
diff changeset
14 # GNU General Public License for more details.
3782a6d698af licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 245
diff changeset
15 #
3782a6d698af licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 245
diff changeset
16 # You should have received a copy of the GNU General Public License
3782a6d698af licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 245
diff changeset
17 # along with this program; if not, write to the Free Software
3782a6d698af licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 245
diff changeset
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
3782a6d698af licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 245
diff changeset
19 # MA 02110-1301, USA.
3782a6d698af licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 245
diff changeset
20 """
3782a6d698af licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 245
diff changeset
21 Created on April 25, 2010
3782a6d698af licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 245
diff changeset
22 changeset controller for pylons
3782a6d698af licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 245
diff changeset
23 @author: marcink
3782a6d698af licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 245
diff changeset
24 """
245
a83a1799480c Reimplemented way of caching repos list, hg model now get's repos objects right from cached dict, this way we skipp creating instances of MercurialRepository and gain performance. Some import cleanup
Marcin Kuzminski <marcin@python-works.com>
parents: 218
diff changeset
25 from pylons import tmpl_context as c
193
50a39f923f31 Added file annotation template. Bumped version to 0.6.8. Changelog and changeset are now cleaned with js, it's still very beta.
Marcin Kuzminski <marcin@python-works.com>
parents: 103
diff changeset
26 from pylons_app.lib.auth import LoginRequired
103
665b344927f4 Added changeset controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
27 from pylons_app.lib.base import BaseController, render
665b344927f4 Added changeset controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
28 from pylons_app.model.hg_model import HgModel
218
58b46f9194c3 version bump. Made changesets work as should, but vcs had to be fixed for that.
Marcin Kuzminski <marcin@python-works.com>
parents: 193
diff changeset
29 from vcs.utils import diffs as differ
193
50a39f923f31 Added file annotation template. Bumped version to 0.6.8. Changelog and changeset are now cleaned with js, it's still very beta.
Marcin Kuzminski <marcin@python-works.com>
parents: 103
diff changeset
30 import logging
218
58b46f9194c3 version bump. Made changesets work as should, but vcs had to be fixed for that.
Marcin Kuzminski <marcin@python-works.com>
parents: 193
diff changeset
31 from vcs.nodes import FileNode
193
50a39f923f31 Added file annotation template. Bumped version to 0.6.8. Changelog and changeset are now cleaned with js, it's still very beta.
Marcin Kuzminski <marcin@python-works.com>
parents: 103
diff changeset
32
50a39f923f31 Added file annotation template. Bumped version to 0.6.8. Changelog and changeset are now cleaned with js, it's still very beta.
Marcin Kuzminski <marcin@python-works.com>
parents: 103
diff changeset
33
103
665b344927f4 Added changeset controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
34 log = logging.getLogger(__name__)
665b344927f4 Added changeset controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
35
665b344927f4 Added changeset controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
36 class ChangesetController(BaseController):
193
50a39f923f31 Added file annotation template. Bumped version to 0.6.8. Changelog and changeset are now cleaned with js, it's still very beta.
Marcin Kuzminski <marcin@python-works.com>
parents: 103
diff changeset
37
50a39f923f31 Added file annotation template. Bumped version to 0.6.8. Changelog and changeset are now cleaned with js, it's still very beta.
Marcin Kuzminski <marcin@python-works.com>
parents: 103
diff changeset
38 @LoginRequired()
103
665b344927f4 Added changeset controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
39 def __before__(self):
193
50a39f923f31 Added file annotation template. Bumped version to 0.6.8. Changelog and changeset are now cleaned with js, it's still very beta.
Marcin Kuzminski <marcin@python-works.com>
parents: 103
diff changeset
40 super(ChangesetController, self).__before__()
103
665b344927f4 Added changeset controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
41
193
50a39f923f31 Added file annotation template. Bumped version to 0.6.8. Changelog and changeset are now cleaned with js, it's still very beta.
Marcin Kuzminski <marcin@python-works.com>
parents: 103
diff changeset
42 def index(self, revision):
50a39f923f31 Added file annotation template. Bumped version to 0.6.8. Changelog and changeset are now cleaned with js, it's still very beta.
Marcin Kuzminski <marcin@python-works.com>
parents: 103
diff changeset
43 hg_model = HgModel()
50a39f923f31 Added file annotation template. Bumped version to 0.6.8. Changelog and changeset are now cleaned with js, it's still very beta.
Marcin Kuzminski <marcin@python-works.com>
parents: 103
diff changeset
44 c.changeset = hg_model.get_repo(c.repo_name).get_changeset(revision)
218
58b46f9194c3 version bump. Made changesets work as should, but vcs had to be fixed for that.
Marcin Kuzminski <marcin@python-works.com>
parents: 193
diff changeset
45 c.changeset_old = c.changeset.parents[0]
58b46f9194c3 version bump. Made changesets work as should, but vcs had to be fixed for that.
Marcin Kuzminski <marcin@python-works.com>
parents: 193
diff changeset
46 c.changes = []
58b46f9194c3 version bump. Made changesets work as should, but vcs had to be fixed for that.
Marcin Kuzminski <marcin@python-works.com>
parents: 193
diff changeset
47
58b46f9194c3 version bump. Made changesets work as should, but vcs had to be fixed for that.
Marcin Kuzminski <marcin@python-works.com>
parents: 193
diff changeset
48
58b46f9194c3 version bump. Made changesets work as should, but vcs had to be fixed for that.
Marcin Kuzminski <marcin@python-works.com>
parents: 193
diff changeset
49 for node in c.changeset.added:
58b46f9194c3 version bump. Made changesets work as should, but vcs had to be fixed for that.
Marcin Kuzminski <marcin@python-works.com>
parents: 193
diff changeset
50 filenode_old = FileNode(node.path, '')
273
cad478edb1c7 added support for binary files, and, protection again unicode decode errors that might occure in changesets views
Marcin Kuzminski <marcin@python-works.com>
parents: 252
diff changeset
51 if filenode_old.is_binary or node.is_binary:
cad478edb1c7 added support for binary files, and, protection again unicode decode errors that might occure in changesets views
Marcin Kuzminski <marcin@python-works.com>
parents: 252
diff changeset
52 diff = 'binary file'
cad478edb1c7 added support for binary files, and, protection again unicode decode errors that might occure in changesets views
Marcin Kuzminski <marcin@python-works.com>
parents: 252
diff changeset
53 else:
cad478edb1c7 added support for binary files, and, protection again unicode decode errors that might occure in changesets views
Marcin Kuzminski <marcin@python-works.com>
parents: 252
diff changeset
54 f_udiff = differ.get_udiff(filenode_old, node)
cad478edb1c7 added support for binary files, and, protection again unicode decode errors that might occure in changesets views
Marcin Kuzminski <marcin@python-works.com>
parents: 252
diff changeset
55 diff = differ.DiffProcessor(f_udiff).as_html()
cad478edb1c7 added support for binary files, and, protection again unicode decode errors that might occure in changesets views
Marcin Kuzminski <marcin@python-works.com>
parents: 252
diff changeset
56 try:
cad478edb1c7 added support for binary files, and, protection again unicode decode errors that might occure in changesets views
Marcin Kuzminski <marcin@python-works.com>
parents: 252
diff changeset
57 diff = unicode(diff)
cad478edb1c7 added support for binary files, and, protection again unicode decode errors that might occure in changesets views
Marcin Kuzminski <marcin@python-works.com>
parents: 252
diff changeset
58 except:
cad478edb1c7 added support for binary files, and, protection again unicode decode errors that might occure in changesets views
Marcin Kuzminski <marcin@python-works.com>
parents: 252
diff changeset
59 log.warning('Decoding failed of %s', filenode_old)
cad478edb1c7 added support for binary files, and, protection again unicode decode errors that might occure in changesets views
Marcin Kuzminski <marcin@python-works.com>
parents: 252
diff changeset
60 log.warning('Decoding failed of %s', node)
cad478edb1c7 added support for binary files, and, protection again unicode decode errors that might occure in changesets views
Marcin Kuzminski <marcin@python-works.com>
parents: 252
diff changeset
61 diff = 'unsupported type'
cad478edb1c7 added support for binary files, and, protection again unicode decode errors that might occure in changesets views
Marcin Kuzminski <marcin@python-works.com>
parents: 252
diff changeset
62 cs1 = None
cad478edb1c7 added support for binary files, and, protection again unicode decode errors that might occure in changesets views
Marcin Kuzminski <marcin@python-works.com>
parents: 252
diff changeset
63 cs2 = node.last_changeset.raw_id
cad478edb1c7 added support for binary files, and, protection again unicode decode errors that might occure in changesets views
Marcin Kuzminski <marcin@python-works.com>
parents: 252
diff changeset
64 c.changes.append(('added', node, diff, cs1, cs2))
218
58b46f9194c3 version bump. Made changesets work as should, but vcs had to be fixed for that.
Marcin Kuzminski <marcin@python-works.com>
parents: 193
diff changeset
65
58b46f9194c3 version bump. Made changesets work as should, but vcs had to be fixed for that.
Marcin Kuzminski <marcin@python-works.com>
parents: 193
diff changeset
66 for node in c.changeset.changed:
58b46f9194c3 version bump. Made changesets work as should, but vcs had to be fixed for that.
Marcin Kuzminski <marcin@python-works.com>
parents: 193
diff changeset
67 filenode_old = c.changeset_old.get_node(node.path)
273
cad478edb1c7 added support for binary files, and, protection again unicode decode errors that might occure in changesets views
Marcin Kuzminski <marcin@python-works.com>
parents: 252
diff changeset
68 if filenode_old.is_binary or node.is_binary:
cad478edb1c7 added support for binary files, and, protection again unicode decode errors that might occure in changesets views
Marcin Kuzminski <marcin@python-works.com>
parents: 252
diff changeset
69 diff = 'binary file'
cad478edb1c7 added support for binary files, and, protection again unicode decode errors that might occure in changesets views
Marcin Kuzminski <marcin@python-works.com>
parents: 252
diff changeset
70 else:
cad478edb1c7 added support for binary files, and, protection again unicode decode errors that might occure in changesets views
Marcin Kuzminski <marcin@python-works.com>
parents: 252
diff changeset
71 f_udiff = differ.get_udiff(filenode_old, node)
cad478edb1c7 added support for binary files, and, protection again unicode decode errors that might occure in changesets views
Marcin Kuzminski <marcin@python-works.com>
parents: 252
diff changeset
72 diff = differ.DiffProcessor(f_udiff).as_html()
cad478edb1c7 added support for binary files, and, protection again unicode decode errors that might occure in changesets views
Marcin Kuzminski <marcin@python-works.com>
parents: 252
diff changeset
73 try:
cad478edb1c7 added support for binary files, and, protection again unicode decode errors that might occure in changesets views
Marcin Kuzminski <marcin@python-works.com>
parents: 252
diff changeset
74 diff = unicode(diff)
cad478edb1c7 added support for binary files, and, protection again unicode decode errors that might occure in changesets views
Marcin Kuzminski <marcin@python-works.com>
parents: 252
diff changeset
75 except:
cad478edb1c7 added support for binary files, and, protection again unicode decode errors that might occure in changesets views
Marcin Kuzminski <marcin@python-works.com>
parents: 252
diff changeset
76 log.warning('Decoding failed of %s', filenode_old)
cad478edb1c7 added support for binary files, and, protection again unicode decode errors that might occure in changesets views
Marcin Kuzminski <marcin@python-works.com>
parents: 252
diff changeset
77 log.warning('Decoding failed of %s', node)
cad478edb1c7 added support for binary files, and, protection again unicode decode errors that might occure in changesets views
Marcin Kuzminski <marcin@python-works.com>
parents: 252
diff changeset
78 diff = 'unsupported type'
cad478edb1c7 added support for binary files, and, protection again unicode decode errors that might occure in changesets views
Marcin Kuzminski <marcin@python-works.com>
parents: 252
diff changeset
79 cs1 = filenode_old.last_changeset.raw_id
cad478edb1c7 added support for binary files, and, protection again unicode decode errors that might occure in changesets views
Marcin Kuzminski <marcin@python-works.com>
parents: 252
diff changeset
80 cs2 = node.last_changeset.raw_id
cad478edb1c7 added support for binary files, and, protection again unicode decode errors that might occure in changesets views
Marcin Kuzminski <marcin@python-works.com>
parents: 252
diff changeset
81 c.changes.append(('changed', node, diff, cs1, cs2))
218
58b46f9194c3 version bump. Made changesets work as should, but vcs had to be fixed for that.
Marcin Kuzminski <marcin@python-works.com>
parents: 193
diff changeset
82
58b46f9194c3 version bump. Made changesets work as should, but vcs had to be fixed for that.
Marcin Kuzminski <marcin@python-works.com>
parents: 193
diff changeset
83 for node in c.changeset.removed:
273
cad478edb1c7 added support for binary files, and, protection again unicode decode errors that might occure in changesets views
Marcin Kuzminski <marcin@python-works.com>
parents: 252
diff changeset
84 c.changes.append(('removed', node, None, None, None))
218
58b46f9194c3 version bump. Made changesets work as should, but vcs had to be fixed for that.
Marcin Kuzminski <marcin@python-works.com>
parents: 193
diff changeset
85
193
50a39f923f31 Added file annotation template. Bumped version to 0.6.8. Changelog and changeset are now cleaned with js, it's still very beta.
Marcin Kuzminski <marcin@python-works.com>
parents: 103
diff changeset
86 return render('changeset/changeset.html')