##// END OF EJS Templates
Added extra check for very large diffs in changesets, sometimes for very large diffs the diff parser could kill CPU.
marcink -
r1274:7a0004ef beta
parent child Browse files
Show More
@@ -88,8 +88,9 b' class ChangesetController(BaseRepoContro'
88 88 c.sum_removed = 0
89 89 c.lines_added = 0
90 90 c.lines_deleted = 0
91 c.cut_off = False
91 c.cut_off = False # defines if cut off limit is reached
92 92
93 # Iterate over ranges (default changeset view is always one changeset)
93 94 for changeset in c.cs_ranges:
94 95 c.changes[changeset.raw_id] = []
95 96 try:
@@ -101,17 +102,23 b' class ChangesetController(BaseRepoContro'
101 102 # ADDED FILES
102 103 #==================================================================
103 104 for node in changeset.added:
105
104 106 filenode_old = FileNode(node.path, '', EmptyChangeset())
105 107 if filenode_old.is_binary or node.is_binary:
106 108 diff = wrap_to_table(_('binary file'))
107 109 st = (0, 0)
108 110 else:
111 # in this case node.size is good parameter since those are
112 # added nodes and their size defines how many changes were
113 # made
109 114 c.sum_added += node.size
110 115 if c.sum_added < self.cut_off_limit:
111 116 f_gitdiff = differ.get_gitdiff(filenode_old, node)
112 117 d = differ.DiffProcessor(f_gitdiff, format='gitdiff')
118
119 st = d.stat()
113 120 diff = d.as_html()
114 st = d.stat()
121
115 122 else:
116 123 diff = wrap_to_table(_('Changeset is to big and '
117 124 'was cut off, see raw '
@@ -134,6 +141,7 b' class ChangesetController(BaseRepoContro'
134 141 try:
135 142 filenode_old = changeset_parent.get_node(node.path)
136 143 except ChangesetError:
144 log.warning('Unable to fetch parent node for diff')
137 145 filenode_old = FileNode(node.path, '',
138 146 EmptyChangeset())
139 147
@@ -146,8 +154,15 b' class ChangesetController(BaseRepoContro'
146 154 f_gitdiff = differ.get_gitdiff(filenode_old, node)
147 155 d = differ.DiffProcessor(f_gitdiff,
148 156 format='gitdiff')
149 diff = d.as_html()
150 157 st = d.stat()
158 if (st[0] + st[1]) * 256 > self.cut_off_limit:
159 diff = wrap_to_table(_('Diff is to big '
160 'and was cut off, see '
161 'raw diff instead'))
162 else:
163 diff = d.as_html()
164
165
151 166 if diff:
152 167 c.sum_removed += len(diff)
153 168 else:
General Comments 0
You need to be logged in to leave comments. Login now