##// END OF EJS Templates
added limits to single file diffs...
marcink -
r544:d8778cde default
parent child Browse files
Show More
@@ -67,6 +67,10 b' class ChangesetController(BaseController'
67 except IndexError:
67 except IndexError:
68 c.changeset_old = None
68 c.changeset_old = None
69 c.changes = []
69 c.changes = []
70
71 #===================================================================
72 # ADDED FILES
73 #===================================================================
70 c.sum_added = 0
74 c.sum_added = 0
71 for node in c.changeset.added:
75 for node in c.changeset.added:
72
76
@@ -74,17 +78,21 b' class ChangesetController(BaseController'
74 if filenode_old.is_binary or node.is_binary:
78 if filenode_old.is_binary or node.is_binary:
75 diff = wrap_to_table(_('binary file'))
79 diff = wrap_to_table(_('binary file'))
76 else:
80 else:
77 c.sum_added += len(node.content)
81 c.sum_added += node.size
78 if c.sum_added < cut_off_limit:
82 if c.sum_added < cut_off_limit:
79 f_udiff = differ.get_udiff(filenode_old, node)
83 f_udiff = differ.get_udiff(filenode_old, node)
80 diff = differ.DiffProcessor(f_udiff).as_html()
84 diff = differ.DiffProcessor(f_udiff).as_html()
81 else:
85 else:
82 diff = wrap_to_table(_('Changeset is to big see raw changeset'))
86 diff = wrap_to_table(_('Changeset is to big and was cut'
87 ' off, see raw changeset instead'))
83
88
84 cs1 = None
89 cs1 = None
85 cs2 = node.last_changeset.short_id
90 cs2 = node.last_changeset.short_id
86 c.changes.append(('added', node, diff, cs1, cs2))
91 c.changes.append(('added', node, diff, cs1, cs2))
87
92
93 #===================================================================
94 # CHANGED FILES
95 #===================================================================
88 c.sum_removed = 0
96 c.sum_removed = 0
89 for node in c.changeset.changed:
97 for node in c.changeset.changed:
90 try:
98 try:
@@ -95,17 +103,21 b' class ChangesetController(BaseController'
95 if filenode_old.is_binary or node.is_binary:
103 if filenode_old.is_binary or node.is_binary:
96 diff = wrap_to_table(_('binary file'))
104 diff = wrap_to_table(_('binary file'))
97 else:
105 else:
98 c.sum_removed += len(node.content)
106 c.sum_removed += node.size
99 if c.sum_removed < cut_off_limit:
107 if c.sum_removed < cut_off_limit:
100 f_udiff = differ.get_udiff(filenode_old, node)
108 f_udiff = differ.get_udiff(filenode_old, node)
101 diff = differ.DiffProcessor(f_udiff).as_html()
109 diff = differ.DiffProcessor(f_udiff).as_html()
102 else:
110 else:
103 diff = wrap_to_table(_('Changeset is to big see raw changeset'))
111 diff = wrap_to_table(_('Changeset is to big and was cut'
112 ' off, see raw changeset instead'))
104
113
105 cs1 = filenode_old.last_changeset.short_id
114 cs1 = filenode_old.last_changeset.short_id
106 cs2 = node.last_changeset.short_id
115 cs2 = node.last_changeset.short_id
107 c.changes.append(('changed', node, diff, cs1, cs2))
116 c.changes.append(('changed', node, diff, cs1, cs2))
108
117
118 #===================================================================
119 # REMOVED FILES
120 #===================================================================
109 for node in c.changeset.removed:
121 for node in c.changeset.removed:
110 c.changes.append(('removed', node, None, None, None))
122 c.changes.append(('removed', node, None, None, None))
111
123
@@ -24,6 +24,7 b' files controller for pylons'
24 """
24 """
25 from mercurial import archival
25 from mercurial import archival
26 from pylons import request, response, session, tmpl_context as c, url
26 from pylons import request, response, session, tmpl_context as c, url
27 from pylons.i18n.translation import _
27 from pylons.controllers.util import redirect
28 from pylons.controllers.util import redirect
28 from pylons_app.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
29 from pylons_app.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
29 from pylons_app.lib.base import BaseController, render
30 from pylons_app.lib.base import BaseController, render
@@ -155,26 +156,27 b' class FilesController(BaseController):'
155 c.repo = hg_model.get_repo(c.repo_name)
156 c.repo = hg_model.get_repo(c.repo_name)
156
157
157 try:
158 try:
158 if diff1 not in ['', None, 'None', '0' * 12]:
159 if diff1 not in ['', None, 'None', '0' * 12, '0' * 40]:
159 c.changeset_1 = c.repo.get_changeset(diff1)
160 c.changeset_1 = c.repo.get_changeset(diff1)
160 node1 = c.changeset_1.get_node(f_path)
161 node1 = c.changeset_1.get_node(f_path)
161 else:
162 else:
162 c.changeset_1 = EmptyChangeset()
163 c.changeset_1 = EmptyChangeset()
163 node1 = FileNode('.', '')
164 node1 = FileNode('.', '', changeset=c.changeset_1)
164 if diff2 not in ['', None, 'None', '0' * 12]:
165
166 if diff2 not in ['', None, 'None', '0' * 12, '0' * 40]:
165 c.changeset_2 = c.repo.get_changeset(diff2)
167 c.changeset_2 = c.repo.get_changeset(diff2)
166 node2 = c.changeset_2.get_node(f_path)
168 node2 = c.changeset_2.get_node(f_path)
167 else:
169 else:
168 c.changeset_2 = EmptyChangeset()
170 c.changeset_2 = EmptyChangeset()
169 node2 = FileNode('.', '')
171 node2 = FileNode('.', '', changeset=c.changeset_2)
170 except RepositoryError:
172 except RepositoryError:
171 return redirect(url('files_home',
173 return redirect(url('files_home',
172 repo_name=c.repo_name, f_path=f_path))
174 repo_name=c.repo_name, f_path=f_path))
173
175
174 c.diff1 = 'r%s:%s' % (c.changeset_1.revision, c.changeset_1.short_id)
176 c.diff1 = 'r%s:%s' % (c.changeset_1.revision, c.changeset_1.short_id)
175 c.diff2 = 'r%s:%s' % (c.changeset_2.revision, c.changeset_2.short_id)
177 c.diff2 = 'r%s:%s' % (c.changeset_2.revision, c.changeset_2.short_id)
178
176 f_udiff = differ.get_udiff(node1, node2)
179 f_udiff = differ.get_udiff(node1, node2)
177
178 diff = differ.DiffProcessor(f_udiff)
180 diff = differ.DiffProcessor(f_udiff)
179
181
180 if c.action == 'download':
182 if c.action == 'download':
@@ -187,10 +189,16 b' class FilesController(BaseController):'
187 elif c.action == 'raw':
189 elif c.action == 'raw':
188 c.cur_diff = '<pre class="raw">%s</pre>' % h.escape(diff.raw_diff())
190 c.cur_diff = '<pre class="raw">%s</pre>' % h.escape(diff.raw_diff())
189 elif c.action == 'diff':
191 elif c.action == 'diff':
190 c.cur_diff = diff.as_html()
192 if node1.size > c.file_size_limit or node2.size > c.file_size_limit:
193 c.cur_diff = _('Diff is to big to display')
194 else:
195 c.cur_diff = diff.as_html()
191 else:
196 else:
192 #default option
197 #default option
193 c.cur_diff = diff.as_html()
198 if node1.size > c.file_size_limit or node2.size > c.file_size_limit:
199 c.cur_diff = _('Diff is to big to display')
200 else:
201 c.cur_diff = diff.as_html()
194
202
195 if not c.cur_diff: c.no_changes = True
203 if not c.cur_diff: c.no_changes = True
196 return render('files/file_diff.html')
204 return render('files/file_diff.html')
@@ -251,11 +251,14 b' def invalidate_cache(name, *args):'
251 region_invalidate(_full_changelog_cached, None, *args)
251 region_invalidate(_full_changelog_cached, None, *args)
252
252
253 class EmptyChangeset(BaseChangeset):
253 class EmptyChangeset(BaseChangeset):
254 """
255 An dummy empty changeset.
256 """
254
257
255 revision = -1
258 revision = -1
256 message = ''
259 message = ''
257 author = ''
260 author = ''
258
261 date = ''
259 @LazyProperty
262 @LazyProperty
260 def raw_id(self):
263 def raw_id(self):
261 """
264 """
@@ -268,6 +271,15 b' class EmptyChangeset(BaseChangeset):'
268 def short_id(self):
271 def short_id(self):
269 return self.raw_id[:12]
272 return self.raw_id[:12]
270
273
274 def get_file_changeset(self, path):
275 return self
276
277 def get_file_content(self, path):
278 return u''
279
280 def get_file_size(self, path):
281 return 0
282
271 def repo2db_mapper(initial_repo_list, remove_obsolete=False):
283 def repo2db_mapper(initial_repo_list, remove_obsolete=False):
272 """
284 """
273 maps all found repositories into db
285 maps all found repositories into db
General Comments 0
You need to be logged in to leave comments. Login now