##// END OF EJS Templates
fixes #79 cut off limit was added into .ini config files
marcink -
r812:30ad41c7 beta
parent child Browse files
Show More
@@ -45,6 +45,7 b' static_files = true'
45 lang=en
45 lang=en
46 cache_dir = %(here)s/data
46 cache_dir = %(here)s/data
47 index_dir = %(here)s/data/index
47 index_dir = %(here)s/data/index
48 cut_off_limit = 256000
48
49
49 ####################################
50 ####################################
50 ### CELERY CONFIG ####
51 ### CELERY CONFIG ####
@@ -45,6 +45,7 b' static_files = false'
45 lang=en
45 lang=en
46 cache_dir = %(here)s/data
46 cache_dir = %(here)s/data
47 index_dir = %(here)s/data/index
47 index_dir = %(here)s/data/index
48 cut_off_limit = 256000
48
49
49 ####################################
50 ####################################
50 ### CELERY CONFIG ####
51 ### CELERY CONFIG ####
@@ -46,6 +46,7 b' lang=en'
46 cache_dir = %(here)s/data
46 cache_dir = %(here)s/data
47 index_dir = %(here)s/data/index
47 index_dir = %(here)s/data/index
48 app_instance_uuid = ${app_instance_uuid}
48 app_instance_uuid = ${app_instance_uuid}
49 cut_off_limit = 256000
49
50
50 ####################################
51 ####################################
51 ### CELERY CONFIG ####
52 ### CELERY CONFIG ####
@@ -1,7 +1,15 b''
1 #!/usr/bin/env python
1 # -*- coding: utf-8 -*-
2 # encoding: utf-8
2 """
3 # changeset controller for pylons
3 rhodecode.controllers.changeset
4 # Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5
6 changeset controller for pylons
7
8 :created_on: Apr 25, 2010
9 :author: marcink
10 :copyright: (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
11 :license: GPLv3, see COPYING for more details.
12 """
5 # This program is free software; you can redistribute it and/or
13 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
14 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; version 2
15 # as published by the Free Software Foundation; version 2
@@ -16,24 +24,22 b''
16 # along with this program; if not, write to the Free Software
24 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
25 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18 # MA 02110-1301, USA.
26 # MA 02110-1301, USA.
19 """
27 import logging
20 Created on April 25, 2010
28 import traceback
21 changeset controller for pylons
29
22 @author: marcink
23 """
24 from pylons import tmpl_context as c, url, request, response
30 from pylons import tmpl_context as c, url, request, response
25 from pylons.i18n.translation import _
31 from pylons.i18n.translation import _
26 from pylons.controllers.util import redirect
32 from pylons.controllers.util import redirect
33
34 import rhodecode.lib.helpers as h
27 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
35 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
28 from rhodecode.lib.base import BaseController, render
36 from rhodecode.lib.base import BaseController, render
29 from rhodecode.lib.utils import EmptyChangeset
37 from rhodecode.lib.utils import EmptyChangeset
30 import rhodecode.lib.helpers as h
31 from rhodecode.model.scm import ScmModel
38 from rhodecode.model.scm import ScmModel
39
32 from vcs.exceptions import RepositoryError, ChangesetError
40 from vcs.exceptions import RepositoryError, ChangesetError
33 from vcs.nodes import FileNode
41 from vcs.nodes import FileNode
34 from vcs.utils import diffs as differ
42 from vcs.utils import diffs as differ
35 import logging
36 import traceback
37
43
38 log = logging.getLogger(__name__)
44 log = logging.getLogger(__name__)
39
45
@@ -47,7 +53,6 b' class ChangesetController(BaseController'
47
53
48 def index(self, revision):
54 def index(self, revision):
49 hg_model = ScmModel()
55 hg_model = ScmModel()
50 cut_off_limit = 1024 * 250
51
56
52 def wrap_to_table(str):
57 def wrap_to_table(str):
53
58
@@ -82,7 +87,7 b' class ChangesetController(BaseController'
82 diff = wrap_to_table(_('binary file'))
87 diff = wrap_to_table(_('binary file'))
83 else:
88 else:
84 c.sum_added += node.size
89 c.sum_added += node.size
85 if c.sum_added < cut_off_limit:
90 if c.sum_added < self.cut_off_limit:
86 f_udiff = differ.get_udiff(filenode_old, node)
91 f_udiff = differ.get_udiff(filenode_old, node)
87 diff = differ.DiffProcessor(f_udiff).as_html()
92 diff = differ.DiffProcessor(f_udiff).as_html()
88
93
@@ -108,7 +113,7 b' class ChangesetController(BaseController'
108 diff = wrap_to_table(_('binary file'))
113 diff = wrap_to_table(_('binary file'))
109 else:
114 else:
110
115
111 if c.sum_removed < cut_off_limit:
116 if c.sum_removed < self.cut_off_limit:
112 f_udiff = differ.get_udiff(filenode_old, node)
117 f_udiff = differ.get_udiff(filenode_old, node)
113 diff = differ.DiffProcessor(f_udiff).as_html()
118 diff = differ.DiffProcessor(f_udiff).as_html()
114 if diff:
119 if diff:
@@ -151,7 +156,7 b' class ChangesetController(BaseController'
151 for node in c.changeset.added:
156 for node in c.changeset.added:
152 filenode_old = FileNode(node.path, '')
157 filenode_old = FileNode(node.path, '')
153 if filenode_old.is_binary or node.is_binary:
158 if filenode_old.is_binary or node.is_binary:
154 diff = _('binary file') +'\n'
159 diff = _('binary file') + '\n'
155 else:
160 else:
156 f_udiff = differ.get_udiff(filenode_old, node)
161 f_udiff = differ.get_udiff(filenode_old, node)
157 diff = differ.DiffProcessor(f_udiff).raw_diff()
162 diff = differ.DiffProcessor(f_udiff).raw_diff()
@@ -173,15 +178,15 b' class ChangesetController(BaseController'
173 c.changes.append(('changed', node, diff, cs1, cs2))
178 c.changes.append(('changed', node, diff, cs1, cs2))
174
179
175 response.content_type = 'text/plain'
180 response.content_type = 'text/plain'
176
181
177 if method == 'download':
182 if method == 'download':
178 response.content_disposition = 'attachment; filename=%s.patch' % revision
183 response.content_disposition = 'attachment; filename=%s.patch' % revision
179
184
180 parent = True if len(c.changeset.parents) > 0 else False
185 parent = True if len(c.changeset.parents) > 0 else False
181 c.parent_tmpl = 'Parent %s' % c.changeset.parents[0].raw_id if parent else ''
186 c.parent_tmpl = 'Parent %s' % c.changeset.parents[0].raw_id if parent else ''
182
187
183 c.diffs = ''
188 c.diffs = ''
184 for x in c.changes:
189 for x in c.changes:
185 c.diffs += x[2]
190 c.diffs += x[2]
186
191
187 return render('changeset/raw_changeset.html')
192 return render('changeset/raw_changeset.html')
@@ -1,8 +1,15 b''
1 #!/usr/bin/env python
1 # -*- coding: utf-8 -*-
2 # encoding: utf-8
2 """
3 # files controller for pylons
3 rhodecode.controllers.files
4 # Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
5
5
6 Files controller for RhodeCode
7
8 :created_on: Apr 21, 2010
9 :author: marcink
10 :copyright: (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
11 :license: GPLv3, see COPYING for more details.
12 """
6 # This program is free software; you can redistribute it and/or
13 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
14 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; version 2
15 # as published by the Free Software Foundation; version 2
@@ -17,25 +24,24 b''
17 # along with this program; if not, write to the Free Software
24 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
25 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 # MA 02110-1301, USA.
26 # MA 02110-1301, USA.
20 """
27 import tempfile
21 Created on April 21, 2010
28 import logging
22 files controller for pylons
29 import rhodecode.lib.helpers as h
23 @author: marcink
30
24 """
25 from mercurial import archival
31 from mercurial import archival
32
26 from pylons import request, response, session, tmpl_context as c, url
33 from pylons import request, response, session, tmpl_context as c, url
27 from pylons.i18n.translation import _
34 from pylons.i18n.translation import _
28 from pylons.controllers.util import redirect
35 from pylons.controllers.util import redirect
36
29 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
37 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
30 from rhodecode.lib.base import BaseController, render
38 from rhodecode.lib.base import BaseController, render
31 from rhodecode.lib.utils import EmptyChangeset
39 from rhodecode.lib.utils import EmptyChangeset
32 from rhodecode.model.scm import ScmModel
40 from rhodecode.model.scm import ScmModel
41
33 from vcs.exceptions import RepositoryError, ChangesetError
42 from vcs.exceptions import RepositoryError, ChangesetError
34 from vcs.nodes import FileNode
43 from vcs.nodes import FileNode
35 from vcs.utils import diffs as differ
44 from vcs.utils import diffs as differ
36 import logging
37 import rhodecode.lib.helpers as h
38 import tempfile
39
45
40 log = logging.getLogger(__name__)
46 log = logging.getLogger(__name__)
41
47
@@ -46,7 +52,6 b' class FilesController(BaseController):'
46 'repository.admin')
52 'repository.admin')
47 def __before__(self):
53 def __before__(self):
48 super(FilesController, self).__before__()
54 super(FilesController, self).__before__()
49 c.file_size_limit = 250 * 1024 #limit of file size to display
50
55
51 def index(self, repo_name, revision, f_path):
56 def index(self, repo_name, revision, f_path):
52 hg_model = ScmModel()
57 hg_model = ScmModel()
@@ -197,13 +202,13 b' class FilesController(BaseController):'
197 return diff.raw_diff()
202 return diff.raw_diff()
198
203
199 elif c.action == 'diff':
204 elif c.action == 'diff':
200 if node1.size > c.file_size_limit or node2.size > c.file_size_limit:
205 if node1.size > self.cut_off_limit or node2.size > self.cut_off_limit:
201 c.cur_diff = _('Diff is to big to display')
206 c.cur_diff = _('Diff is to big to display')
202 else:
207 else:
203 c.cur_diff = diff.as_html()
208 c.cur_diff = diff.as_html()
204 else:
209 else:
205 #default option
210 #default option
206 if node1.size > c.file_size_limit or node2.size > c.file_size_limit:
211 if node1.size > self.cut_off_limit or node2.size > self.cut_off_limit:
207 c.cur_diff = _('Diff is to big to display')
212 c.cur_diff = _('Diff is to big to display')
208 else:
213 else:
209 c.cur_diff = diff.as_html()
214 c.cur_diff = diff.as_html()
@@ -20,7 +20,7 b' class BaseController(WSGIController):'
20 c.repo_name = get_repo_slug(request)
20 c.repo_name = get_repo_slug(request)
21 c.cached_repo_list = ScmModel().get_repos()
21 c.cached_repo_list = ScmModel().get_repos()
22 c.backends = BACKENDS.keys()
22 c.backends = BACKENDS.keys()
23
23 self.cut_off_limit = int(config['cut_off_limit'])
24 self.sa = meta.Session()
24 self.sa = meta.Session()
25 scm_model = ScmModel(self.sa)
25 scm_model = ScmModel(self.sa)
26 #c.unread_journal = scm_model.get_unread_journal()
26 #c.unread_journal = scm_model.get_unread_journal()
@@ -44,6 +44,7 b' static_files = true'
44 lang=en
44 lang=en
45 cache_dir = %(here)s/data
45 cache_dir = %(here)s/data
46 index_dir = /tmp/index
46 index_dir = /tmp/index
47 cut_off_limit = 256000
47
48
48 ####################################
49 ####################################
49 ### CELERY CONFIG ####
50 ### CELERY CONFIG ####
General Comments 0
You need to be logged in to leave comments. Login now