Mercurial > kallithea
annotate rhodecode/controllers/changeset.py @ 658:4ecb2ffcc110 beta
fixed imports
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Fri, 05 Nov 2010 18:47:00 +0100 |
parents | 0c065f793d0e |
children | 7486da5f0628 |
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 """ |
466
183cee110578
first implementation of #34 changeset raw diff based on udiff from python
Marcin Kuzminski <marcin@python-works.com>
parents:
318
diff
changeset
|
24 from pylons import tmpl_context as c, url, request, response |
543
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
512
diff
changeset
|
25 from pylons.i18n.translation import _ |
318
fdf9f6ee5217
Implemented permissions into hg app, secured admin controllers, templates and repository specific controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
285
diff
changeset
|
26 from pylons.controllers.util import redirect |
547
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
544
diff
changeset
|
27 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator |
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
544
diff
changeset
|
28 from rhodecode.lib.base import BaseController, render |
649
3765f0f479a2
fixed raw diff as purly raw without html
Marcin Kuzminski <marcin@python-works.com>
parents:
648
diff
changeset
|
29 from rhodecode.lib.utils import EmptyChangeset |
644
c8bd0e6cc3da
some changes for #45.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
30 import rhodecode.lib.helpers as h |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
566
diff
changeset
|
31 from rhodecode.model.hg import HgModel |
543
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
512
diff
changeset
|
32 from vcs.exceptions import RepositoryError, ChangesetError |
318
fdf9f6ee5217
Implemented permissions into hg app, secured admin controllers, templates and repository specific controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
285
diff
changeset
|
33 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:
285
diff
changeset
|
34 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:
285
diff
changeset
|
35 import logging |
fdf9f6ee5217
Implemented permissions into hg app, secured admin controllers, templates and repository specific controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
285
diff
changeset
|
36 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
|
37 |
103
665b344927f4
Added changeset controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
38 log = logging.getLogger(__name__) |
665b344927f4
Added changeset controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
39 |
665b344927f4
Added changeset controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
40 class ChangesetController(BaseController): |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
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 @LoginRequired() |
318
fdf9f6ee5217
Implemented permissions into hg app, secured admin controllers, templates and repository specific controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
285
diff
changeset
|
43 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
44 'repository.admin') |
103
665b344927f4
Added changeset controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
45 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
|
46 super(ChangesetController, self).__before__() |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
47 |
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
|
48 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
|
49 hg_model = HgModel() |
566
7fcc539e20b1
large initial commits fixup
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
50 cut_off_limit = 1024 * 250 |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
51 |
543
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
512
diff
changeset
|
52 def wrap_to_table(str): |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
53 |
543
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
512
diff
changeset
|
54 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:
512
diff
changeset
|
55 <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:
512
diff
changeset
|
56 <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:
512
diff
changeset
|
57 <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:
512
diff
changeset
|
58 </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:
512
diff
changeset
|
59 </table>''' % str |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
60 |
543
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
512
diff
changeset
|
61 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:
512
diff
changeset
|
62 c.changeset = hg_model.get_repo(c.repo_name).get_changeset(revision) |
644
c8bd0e6cc3da
some changes for #45.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
63 except RepositoryError, e: |
543
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
512
diff
changeset
|
64 log.error(traceback.format_exc()) |
644
c8bd0e6cc3da
some changes for #45.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
65 h.flash(str(e), category='warning') |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
66 return redirect(url('home')) |
543
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
512
diff
changeset
|
67 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:
512
diff
changeset
|
68 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:
512
diff
changeset
|
69 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:
512
diff
changeset
|
70 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:
512
diff
changeset
|
71 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:
512
diff
changeset
|
72 c.changes = [] |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
73 |
544
d8778cde98f0
added limits to single file diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
543
diff
changeset
|
74 #=================================================================== |
d8778cde98f0
added limits to single file diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
543
diff
changeset
|
75 # ADDED FILES |
d8778cde98f0
added limits to single file diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
543
diff
changeset
|
76 #=================================================================== |
543
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
512
diff
changeset
|
77 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:
512
diff
changeset
|
78 for node in c.changeset.added: |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
79 |
566
7fcc539e20b1
large initial commits fixup
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
80 filenode_old = FileNode(node.path, '', EmptyChangeset()) |
543
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
512
diff
changeset
|
81 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:
512
diff
changeset
|
82 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:
512
diff
changeset
|
83 else: |
544
d8778cde98f0
added limits to single file diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
543
diff
changeset
|
84 c.sum_added += node.size |
543
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
512
diff
changeset
|
85 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:
512
diff
changeset
|
86 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:
512
diff
changeset
|
87 diff = differ.DiffProcessor(f_udiff).as_html() |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
88 |
543
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
512
diff
changeset
|
89 else: |
544
d8778cde98f0
added limits to single file diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
543
diff
changeset
|
90 diff = wrap_to_table(_('Changeset is to big and was cut' |
d8778cde98f0
added limits to single file diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
543
diff
changeset
|
91 ' off, see raw changeset instead')) |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
92 |
543
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
512
diff
changeset
|
93 cs1 = None |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
94 cs2 = node.last_changeset.raw_id |
543
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
512
diff
changeset
|
95 c.changes.append(('added', node, diff, cs1, cs2)) |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
96 |
544
d8778cde98f0
added limits to single file diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
543
diff
changeset
|
97 #=================================================================== |
d8778cde98f0
added limits to single file diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
543
diff
changeset
|
98 # CHANGED FILES |
d8778cde98f0
added limits to single file diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
543
diff
changeset
|
99 #=================================================================== |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
100 c.sum_removed = 0 |
543
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
512
diff
changeset
|
101 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:
512
diff
changeset
|
102 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:
512
diff
changeset
|
103 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:
512
diff
changeset
|
104 except ChangesetError: |
566
7fcc539e20b1
large initial commits fixup
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
105 filenode_old = FileNode(node.path, '', EmptyChangeset()) |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
106 |
543
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
512
diff
changeset
|
107 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:
512
diff
changeset
|
108 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:
512
diff
changeset
|
109 else: |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
110 |
543
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
512
diff
changeset
|
111 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:
512
diff
changeset
|
112 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:
512
diff
changeset
|
113 diff = differ.DiffProcessor(f_udiff).as_html() |
566
7fcc539e20b1
large initial commits fixup
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
114 if diff: |
7fcc539e20b1
large initial commits fixup
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
115 c.sum_removed += len(diff) |
543
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
512
diff
changeset
|
116 else: |
544
d8778cde98f0
added limits to single file diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
543
diff
changeset
|
117 diff = wrap_to_table(_('Changeset is to big and was cut' |
d8778cde98f0
added limits to single file diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
543
diff
changeset
|
118 ' off, see raw changeset instead')) |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
119 |
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
120 |
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
121 cs1 = filenode_old.last_changeset.raw_id |
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
122 cs2 = node.last_changeset.raw_id |
543
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
512
diff
changeset
|
123 c.changes.append(('changed', node, diff, cs1, cs2)) |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
124 |
544
d8778cde98f0
added limits to single file diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
543
diff
changeset
|
125 #=================================================================== |
d8778cde98f0
added limits to single file diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
543
diff
changeset
|
126 # REMOVED FILES |
d8778cde98f0
added limits to single file diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
543
diff
changeset
|
127 #=================================================================== |
543
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
512
diff
changeset
|
128 for node in c.changeset.removed: |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
129 c.changes.append(('removed', node, None, None, None)) |
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
130 |
543
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
512
diff
changeset
|
131 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:
512
diff
changeset
|
132 |
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
512
diff
changeset
|
133 def raw_changeset(self, revision): |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
134 |
543
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
512
diff
changeset
|
135 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:
512
diff
changeset
|
136 method = request.GET.get('diff', 'show') |
285
42f5c36820ef
few validation bugfixes/ new repo changesets, first commit changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
273
diff
changeset
|
137 try: |
648
74bbfdd47884
Small fixes for style.
Marcin Kuzminski <marcin@python-works.com>
parents:
644
diff
changeset
|
138 r = hg_model.get_repo(c.repo_name) |
74bbfdd47884
Small fixes for style.
Marcin Kuzminski <marcin@python-works.com>
parents:
644
diff
changeset
|
139 c.scm_type = r.alias |
74bbfdd47884
Small fixes for style.
Marcin Kuzminski <marcin@python-works.com>
parents:
644
diff
changeset
|
140 c.changeset = r.get_changeset(revision) |
285
42f5c36820ef
few validation bugfixes/ new repo changesets, first commit changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
273
diff
changeset
|
141 except RepositoryError: |
42f5c36820ef
few validation bugfixes/ new repo changesets, first commit changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
273
diff
changeset
|
142 log.error(traceback.format_exc()) |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
143 return redirect(url('home')) |
285
42f5c36820ef
few validation bugfixes/ new repo changesets, first commit changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
273
diff
changeset
|
144 else: |
42f5c36820ef
few validation bugfixes/ new repo changesets, first commit changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
273
diff
changeset
|
145 try: |
42f5c36820ef
few validation bugfixes/ new repo changesets, first commit changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
273
diff
changeset
|
146 c.changeset_old = c.changeset.parents[0] |
42f5c36820ef
few validation bugfixes/ new repo changesets, first commit changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
273
diff
changeset
|
147 except IndexError: |
42f5c36820ef
few validation bugfixes/ new repo changesets, first commit changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
273
diff
changeset
|
148 c.changeset_old = None |
42f5c36820ef
few validation bugfixes/ new repo changesets, first commit changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
273
diff
changeset
|
149 c.changes = [] |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
150 |
285
42f5c36820ef
few validation bugfixes/ new repo changesets, first commit changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
273
diff
changeset
|
151 for node in c.changeset.added: |
42f5c36820ef
few validation bugfixes/ new repo changesets, first commit changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
273
diff
changeset
|
152 filenode_old = FileNode(node.path, '') |
42f5c36820ef
few validation bugfixes/ new repo changesets, first commit changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
273
diff
changeset
|
153 if filenode_old.is_binary or node.is_binary: |
650
0c065f793d0e
fixed raw diff breakline bug
Marcin Kuzminski <marcin@python-works.com>
parents:
649
diff
changeset
|
154 diff = _('binary file') +'\n' |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
155 else: |
466
183cee110578
first implementation of #34 changeset raw diff based on udiff from python
Marcin Kuzminski <marcin@python-works.com>
parents:
318
diff
changeset
|
156 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:
318
diff
changeset
|
157 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:
318
diff
changeset
|
158 |
183cee110578
first implementation of #34 changeset raw diff based on udiff from python
Marcin Kuzminski <marcin@python-works.com>
parents:
318
diff
changeset
|
159 cs1 = None |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
160 cs2 = node.last_changeset.raw_id |
466
183cee110578
first implementation of #34 changeset raw diff based on udiff from python
Marcin Kuzminski <marcin@python-works.com>
parents:
318
diff
changeset
|
161 c.changes.append(('added', node, diff, cs1, cs2)) |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
162 |
466
183cee110578
first implementation of #34 changeset raw diff based on udiff from python
Marcin Kuzminski <marcin@python-works.com>
parents:
318
diff
changeset
|
163 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:
318
diff
changeset
|
164 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:
318
diff
changeset
|
165 if filenode_old.is_binary or node.is_binary: |
543
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
512
diff
changeset
|
166 diff = _('binary file') |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
167 else: |
466
183cee110578
first implementation of #34 changeset raw diff based on udiff from python
Marcin Kuzminski <marcin@python-works.com>
parents:
318
diff
changeset
|
168 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:
318
diff
changeset
|
169 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:
318
diff
changeset
|
170 |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
171 cs1 = filenode_old.last_changeset.raw_id |
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
172 cs2 = node.last_changeset.raw_id |
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
173 c.changes.append(('changed', node, diff, cs1, cs2)) |
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
174 |
466
183cee110578
first implementation of #34 changeset raw diff based on udiff from python
Marcin Kuzminski <marcin@python-works.com>
parents:
318
diff
changeset
|
175 response.content_type = 'text/plain' |
650
0c065f793d0e
fixed raw diff breakline bug
Marcin Kuzminski <marcin@python-works.com>
parents:
649
diff
changeset
|
176 |
468
9dd372c7166c
added menu for changeset raw diff and download diff
Marcin Kuzminski <marcin@python-works.com>
parents:
466
diff
changeset
|
177 if method == 'download': |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
178 response.content_disposition = 'attachment; filename=%s.patch' % revision |
650
0c065f793d0e
fixed raw diff breakline bug
Marcin Kuzminski <marcin@python-works.com>
parents:
649
diff
changeset
|
179 |
466
183cee110578
first implementation of #34 changeset raw diff based on udiff from python
Marcin Kuzminski <marcin@python-works.com>
parents:
318
diff
changeset
|
180 parent = True if len(c.changeset.parents) > 0 else False |
543
a99e23e6c1e8
fixes #13 large initial commits and changesets are cut of now to not freeze the application.
Marcin Kuzminski <marcin@python-works.com>
parents:
512
diff
changeset
|
181 c.parent_tmpl = 'Parent %s' % c.changeset.parents[0].raw_id if parent else '' |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
182 |
466
183cee110578
first implementation of #34 changeset raw diff based on udiff from python
Marcin Kuzminski <marcin@python-works.com>
parents:
318
diff
changeset
|
183 c.diffs = '' |
183cee110578
first implementation of #34 changeset raw diff based on udiff from python
Marcin Kuzminski <marcin@python-works.com>
parents:
318
diff
changeset
|
184 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:
318
diff
changeset
|
185 c.diffs += x[2] |
649
3765f0f479a2
fixed raw diff as purly raw without html
Marcin Kuzminski <marcin@python-works.com>
parents:
648
diff
changeset
|
186 |
466
183cee110578
first implementation of #34 changeset raw diff based on udiff from python
Marcin Kuzminski <marcin@python-works.com>
parents:
318
diff
changeset
|
187 return render('changeset/raw_changeset.html') |