##// 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 c.sum_removed = 0
88 c.sum_removed = 0
89 c.lines_added = 0
89 c.lines_added = 0
90 c.lines_deleted = 0
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 for changeset in c.cs_ranges:
94 for changeset in c.cs_ranges:
94 c.changes[changeset.raw_id] = []
95 c.changes[changeset.raw_id] = []
95 try:
96 try:
@@ -101,17 +102,23 b' class ChangesetController(BaseRepoContro'
101 # ADDED FILES
102 # ADDED FILES
102 #==================================================================
103 #==================================================================
103 for node in changeset.added:
104 for node in changeset.added:
105
104 filenode_old = FileNode(node.path, '', EmptyChangeset())
106 filenode_old = FileNode(node.path, '', EmptyChangeset())
105 if filenode_old.is_binary or node.is_binary:
107 if filenode_old.is_binary or node.is_binary:
106 diff = wrap_to_table(_('binary file'))
108 diff = wrap_to_table(_('binary file'))
107 st = (0, 0)
109 st = (0, 0)
108 else:
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 c.sum_added += node.size
114 c.sum_added += node.size
110 if c.sum_added < self.cut_off_limit:
115 if c.sum_added < self.cut_off_limit:
111 f_gitdiff = differ.get_gitdiff(filenode_old, node)
116 f_gitdiff = differ.get_gitdiff(filenode_old, node)
112 d = differ.DiffProcessor(f_gitdiff, format='gitdiff')
117 d = differ.DiffProcessor(f_gitdiff, format='gitdiff')
118
119 st = d.stat()
113 diff = d.as_html()
120 diff = d.as_html()
114 st = d.stat()
121
115 else:
122 else:
116 diff = wrap_to_table(_('Changeset is to big and '
123 diff = wrap_to_table(_('Changeset is to big and '
117 'was cut off, see raw '
124 'was cut off, see raw '
@@ -134,6 +141,7 b' class ChangesetController(BaseRepoContro'
134 try:
141 try:
135 filenode_old = changeset_parent.get_node(node.path)
142 filenode_old = changeset_parent.get_node(node.path)
136 except ChangesetError:
143 except ChangesetError:
144 log.warning('Unable to fetch parent node for diff')
137 filenode_old = FileNode(node.path, '',
145 filenode_old = FileNode(node.path, '',
138 EmptyChangeset())
146 EmptyChangeset())
139
147
@@ -146,8 +154,15 b' class ChangesetController(BaseRepoContro'
146 f_gitdiff = differ.get_gitdiff(filenode_old, node)
154 f_gitdiff = differ.get_gitdiff(filenode_old, node)
147 d = differ.DiffProcessor(f_gitdiff,
155 d = differ.DiffProcessor(f_gitdiff,
148 format='gitdiff')
156 format='gitdiff')
149 diff = d.as_html()
150 st = d.stat()
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 if diff:
166 if diff:
152 c.sum_removed += len(diff)
167 c.sum_removed += len(diff)
153 else:
168 else:
General Comments 0
You need to be logged in to leave comments. Login now