Mercurial > public > src > rhodecode
annotate pylons_app/controllers/changeset.py @ 592:a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
fixed _hex ! for raw changeset
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Tue, 05 Oct 2010 17:56:06 +0200 |
parents | d945c95ba4ac |
children | d8778cde98f0 |
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 # 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
|
6 # 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
|
7 # as published by the Free Software Foundation; version 2 |
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
245
diff
changeset
|
8 # 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
|
9 # |
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
245
diff
changeset
|
10 # 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
|
11 # 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
|
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
245
diff
changeset
|
13 # GNU General Public License for more details. |
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
245
diff
changeset
|
14 # |
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
245
diff
changeset
|
15 # 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
|
16 # 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
|
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
245
diff
changeset
|
18 # MA 02110-1301, USA. |
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
245
diff
changeset
|
19 """ |
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
245
diff
changeset
|
20 Created on April 25, 2010 |
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
245
diff
changeset
|
21 changeset controller for pylons |
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
245
diff
changeset
|
22 @author: marcink |
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
245
diff
changeset
|
23 """ |
509
183cee110578
first implementation of #34 changeset raw diff based on udiff from python
Marcin Kuzminski <marcin@python-works.com>
parents:
331
diff
changeset
|
24 from pylons import tmpl_context as c, url, request, response |
592
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
25 from pylons.i18n.translation import _ |
331
fdf9f6ee5217
Implemented permissions into hg app, secured admin controllers, templates and repository specific controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
294
diff
changeset
|
26 from pylons.controllers.util import redirect |
fdf9f6ee5217
Implemented permissions into hg app, secured admin controllers, templates and repository specific controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
294
diff
changeset
|
27 from pylons_app.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator |
fdf9f6ee5217
Implemented permissions into hg app, secured admin controllers, templates and repository specific controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
294
diff
changeset
|
28 from pylons_app.lib.base import BaseController, render |
fdf9f6ee5217
Implemented permissions into hg app, secured admin controllers, templates and repository specific controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
294
diff
changeset
|
29 from pylons_app.model.hg_model import HgModel |
592
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
30 from vcs.exceptions import RepositoryError, ChangesetError |
331
fdf9f6ee5217
Implemented permissions into hg app, secured admin controllers, templates and repository specific controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
294
diff
changeset
|
31 from vcs.nodes import FileNode |
fdf9f6ee5217
Implemented permissions into hg app, secured admin controllers, templates and repository specific controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
294
diff
changeset
|
32 from vcs.utils import diffs as differ |
fdf9f6ee5217
Implemented permissions into hg app, secured admin controllers, templates and repository specific controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
294
diff
changeset
|
33 import logging |
fdf9f6ee5217
Implemented permissions into hg app, secured admin controllers, templates and repository specific controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
294
diff
changeset
|
34 import traceback |
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
|
35 |
103
665b344927f4
Added changeset controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
36 log = logging.getLogger(__name__) |
665b344927f4
Added changeset controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
37 |
665b344927f4
Added changeset controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
38 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
|
39 |
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 @LoginRequired() |
331
fdf9f6ee5217
Implemented permissions into hg app, secured admin controllers, templates and repository specific controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
294
diff
changeset
|
41 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', |
fdf9f6ee5217
Implemented permissions into hg app, secured admin controllers, templates and repository specific controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
294
diff
changeset
|
42 'repository.admin') |
103
665b344927f4
Added changeset controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
43 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
|
44 super(ChangesetController, self).__before__() |
103
665b344927f4
Added changeset controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
45 |
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
|
46 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
|
47 hg_model = HgModel() |
592
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
48 cut_off_limit = 1024 * 100 |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
49 |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
50 def wrap_to_table(str): |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
51 |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
52 return '''<table class="code-difftable"> |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
53 <tr class="line"> |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
54 <td class="lineno new"></td> |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
55 <td class="code"><pre>%s</pre></td> |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
56 </tr> |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
57 </table>''' % str |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
58 |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
59 try: |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
60 c.changeset = hg_model.get_repo(c.repo_name).get_changeset(revision) |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
61 except RepositoryError: |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
62 log.error(traceback.format_exc()) |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
63 return redirect(url('hg_home')) |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
64 else: |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
65 try: |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
66 c.changeset_old = c.changeset.parents[0] |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
67 except IndexError: |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
68 c.changeset_old = None |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
69 c.changes = [] |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
70 c.sum_added = 0 |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
71 for node in c.changeset.added: |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
72 |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
73 filenode_old = FileNode(node.path, '') |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
74 if filenode_old.is_binary or node.is_binary: |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
75 diff = wrap_to_table(_('binary file')) |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
76 else: |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
77 c.sum_added += len(node.content) |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
78 if c.sum_added < cut_off_limit: |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
79 f_udiff = differ.get_udiff(filenode_old, node) |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
80 diff = differ.DiffProcessor(f_udiff).as_html() |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
81 else: |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
82 diff = wrap_to_table(_('Changeset is to big see raw changeset')) |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
83 |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
84 cs1 = None |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
85 cs2 = node.last_changeset.short_id |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
86 c.changes.append(('added', node, diff, cs1, cs2)) |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
87 |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
88 c.sum_removed = 0 |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
89 for node in c.changeset.changed: |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
90 try: |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
91 filenode_old = c.changeset_old.get_node(node.path) |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
92 except ChangesetError: |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
93 filenode_old = FileNode(node.path, '') |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
94 |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
95 if filenode_old.is_binary or node.is_binary: |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
96 diff = wrap_to_table(_('binary file')) |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
97 else: |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
98 c.sum_removed += len(node.content) |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
99 if c.sum_removed < cut_off_limit: |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
100 f_udiff = differ.get_udiff(filenode_old, node) |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
101 diff = differ.DiffProcessor(f_udiff).as_html() |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
102 else: |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
103 diff = wrap_to_table(_('Changeset is to big see raw changeset')) |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
104 |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
105 cs1 = filenode_old.last_changeset.short_id |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
106 cs2 = node.last_changeset.short_id |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
107 c.changes.append(('changed', node, diff, cs1, cs2)) |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
108 |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
109 for node in c.changeset.removed: |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
110 c.changes.append(('removed', node, None, None, None)) |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
111 |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
112 return render('changeset/changeset.html') |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
113 |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
114 def raw_changeset(self, revision): |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
115 |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
116 hg_model = HgModel() |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
117 method = request.GET.get('diff', 'show') |
294
42f5c36820ef
few validation bugfixes/ new repo changesets, first commit changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
276
diff
changeset
|
118 try: |
42f5c36820ef
few validation bugfixes/ new repo changesets, first commit changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
276
diff
changeset
|
119 c.changeset = hg_model.get_repo(c.repo_name).get_changeset(revision) |
42f5c36820ef
few validation bugfixes/ new repo changesets, first commit changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
276
diff
changeset
|
120 except RepositoryError: |
42f5c36820ef
few validation bugfixes/ new repo changesets, first commit changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
276
diff
changeset
|
121 log.error(traceback.format_exc()) |
42f5c36820ef
few validation bugfixes/ new repo changesets, first commit changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
276
diff
changeset
|
122 return redirect(url('hg_home')) |
42f5c36820ef
few validation bugfixes/ new repo changesets, first commit changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
276
diff
changeset
|
123 else: |
42f5c36820ef
few validation bugfixes/ new repo changesets, first commit changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
276
diff
changeset
|
124 try: |
42f5c36820ef
few validation bugfixes/ new repo changesets, first commit changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
276
diff
changeset
|
125 c.changeset_old = c.changeset.parents[0] |
42f5c36820ef
few validation bugfixes/ new repo changesets, first commit changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
276
diff
changeset
|
126 except IndexError: |
42f5c36820ef
few validation bugfixes/ new repo changesets, first commit changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
276
diff
changeset
|
127 c.changeset_old = None |
42f5c36820ef
few validation bugfixes/ new repo changesets, first commit changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
276
diff
changeset
|
128 c.changes = [] |
42f5c36820ef
few validation bugfixes/ new repo changesets, first commit changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
276
diff
changeset
|
129 |
42f5c36820ef
few validation bugfixes/ new repo changesets, first commit changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
276
diff
changeset
|
130 for node in c.changeset.added: |
42f5c36820ef
few validation bugfixes/ new repo changesets, first commit changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
276
diff
changeset
|
131 filenode_old = FileNode(node.path, '') |
42f5c36820ef
few validation bugfixes/ new repo changesets, first commit changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
276
diff
changeset
|
132 if filenode_old.is_binary or node.is_binary: |
592
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
133 diff = _('binary file') |
509
183cee110578
first implementation of #34 changeset raw diff based on udiff from python
Marcin Kuzminski <marcin@python-works.com>
parents:
331
diff
changeset
|
134 else: |
183cee110578
first implementation of #34 changeset raw diff based on udiff from python
Marcin Kuzminski <marcin@python-works.com>
parents:
331
diff
changeset
|
135 f_udiff = differ.get_udiff(filenode_old, node) |
183cee110578
first implementation of #34 changeset raw diff based on udiff from python
Marcin Kuzminski <marcin@python-works.com>
parents:
331
diff
changeset
|
136 diff = differ.DiffProcessor(f_udiff).raw_diff() |
183cee110578
first implementation of #34 changeset raw diff based on udiff from python
Marcin Kuzminski <marcin@python-works.com>
parents:
331
diff
changeset
|
137 |
183cee110578
first implementation of #34 changeset raw diff based on udiff from python
Marcin Kuzminski <marcin@python-works.com>
parents:
331
diff
changeset
|
138 cs1 = None |
559
d945c95ba4ac
refactoring for new vcs implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
511
diff
changeset
|
139 cs2 = node.last_changeset.short_id |
509
183cee110578
first implementation of #34 changeset raw diff based on udiff from python
Marcin Kuzminski <marcin@python-works.com>
parents:
331
diff
changeset
|
140 c.changes.append(('added', node, diff, cs1, cs2)) |
183cee110578
first implementation of #34 changeset raw diff based on udiff from python
Marcin Kuzminski <marcin@python-works.com>
parents:
331
diff
changeset
|
141 |
183cee110578
first implementation of #34 changeset raw diff based on udiff from python
Marcin Kuzminski <marcin@python-works.com>
parents:
331
diff
changeset
|
142 for node in c.changeset.changed: |
183cee110578
first implementation of #34 changeset raw diff based on udiff from python
Marcin Kuzminski <marcin@python-works.com>
parents:
331
diff
changeset
|
143 filenode_old = c.changeset_old.get_node(node.path) |
183cee110578
first implementation of #34 changeset raw diff based on udiff from python
Marcin Kuzminski <marcin@python-works.com>
parents:
331
diff
changeset
|
144 if filenode_old.is_binary or node.is_binary: |
592
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
145 diff = _('binary file') |
509
183cee110578
first implementation of #34 changeset raw diff based on udiff from python
Marcin Kuzminski <marcin@python-works.com>
parents:
331
diff
changeset
|
146 else: |
183cee110578
first implementation of #34 changeset raw diff based on udiff from python
Marcin Kuzminski <marcin@python-works.com>
parents:
331
diff
changeset
|
147 f_udiff = differ.get_udiff(filenode_old, node) |
183cee110578
first implementation of #34 changeset raw diff based on udiff from python
Marcin Kuzminski <marcin@python-works.com>
parents:
331
diff
changeset
|
148 diff = differ.DiffProcessor(f_udiff).raw_diff() |
183cee110578
first implementation of #34 changeset raw diff based on udiff from python
Marcin Kuzminski <marcin@python-works.com>
parents:
331
diff
changeset
|
149 |
559
d945c95ba4ac
refactoring for new vcs implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
511
diff
changeset
|
150 cs1 = filenode_old.last_changeset.short_id |
d945c95ba4ac
refactoring for new vcs implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
511
diff
changeset
|
151 cs2 = node.last_changeset.short_id |
509
183cee110578
first implementation of #34 changeset raw diff based on udiff from python
Marcin Kuzminski <marcin@python-works.com>
parents:
331
diff
changeset
|
152 c.changes.append(('changed', node, diff, cs1, cs2)) |
183cee110578
first implementation of #34 changeset raw diff based on udiff from python
Marcin Kuzminski <marcin@python-works.com>
parents:
331
diff
changeset
|
153 |
183cee110578
first implementation of #34 changeset raw diff based on udiff from python
Marcin Kuzminski <marcin@python-works.com>
parents:
331
diff
changeset
|
154 response.content_type = 'text/plain' |
511
9dd372c7166c
added menu for changeset raw diff and download diff
Marcin Kuzminski <marcin@python-works.com>
parents:
509
diff
changeset
|
155 if method == 'download': |
9dd372c7166c
added menu for changeset raw diff and download diff
Marcin Kuzminski <marcin@python-works.com>
parents:
509
diff
changeset
|
156 response.content_disposition = 'attachment; filename=%s.patch' % revision |
509
183cee110578
first implementation of #34 changeset raw diff based on udiff from python
Marcin Kuzminski <marcin@python-works.com>
parents:
331
diff
changeset
|
157 parent = True if len(c.changeset.parents) > 0 else False |
592
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
559
diff
changeset
|
158 c.parent_tmpl = 'Parent %s' % c.changeset.parents[0].raw_id if parent else '' |
509
183cee110578
first implementation of #34 changeset raw diff based on udiff from python
Marcin Kuzminski <marcin@python-works.com>
parents:
331
diff
changeset
|
159 |
183cee110578
first implementation of #34 changeset raw diff based on udiff from python
Marcin Kuzminski <marcin@python-works.com>
parents:
331
diff
changeset
|
160 c.diffs = '' |
183cee110578
first implementation of #34 changeset raw diff based on udiff from python
Marcin Kuzminski <marcin@python-works.com>
parents:
331
diff
changeset
|
161 for x in c.changes: |
183cee110578
first implementation of #34 changeset raw diff based on udiff from python
Marcin Kuzminski <marcin@python-works.com>
parents:
331
diff
changeset
|
162 c.diffs += x[2] |
183cee110578
first implementation of #34 changeset raw diff based on udiff from python
Marcin Kuzminski <marcin@python-works.com>
parents:
331
diff
changeset
|
163 |
183cee110578
first implementation of #34 changeset raw diff based on udiff from python
Marcin Kuzminski <marcin@python-works.com>
parents:
331
diff
changeset
|
164 return render('changeset/raw_changeset.html') |