Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.8, 0.8.1, and 0.8.2

changeset: use maxdiff size to prevent extraordinary diffs

Rather than doing a binary check, we can look at the file size for free before
trying to read the file's data from the revlog.

Better fix for issue #39.

Changeset 17b4f566bffd

Parent 7d809817314c

by Steve Borho

Changes to one file · Browse files at 17b4f566bffd Showing diff from parent 7d809817314c Diff from another changeset...

 
184
185
186
187
188
189
190
191
 
 
 
 
 
 
 
 
 
 
 
 
192
193
194
 
184
185
186
 
 
 
 
 
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
@@ -184,11 +184,18 @@
  buf, rev = self._buffer, self.currev   n1, n2 = self.curnodes   - lines = [] - matcher = cmdutil.match(self.repo, [file]) - diffopts = mdiff.diffopts(git=True, nodates=True, nobinary=True) - for s in patch.diff(self.repo, n1, n2, match=matcher, opts=diffopts): - lines.extend(s.splitlines()) + fctx = self.repo[rev].filectx(file) + if not fctx: + return + if fctx.size() > getmaxdiffsize(self.ui): + lines = ['diff', + _(' %s is larger than the specified max diff size') % file] + else: + lines = [] + matcher = cmdutil.match(self.repo, [file]) + opts = mdiff.diffopts(git=True, nodates=True) + for s in patch.diff(self.repo, n1, n2, match=matcher, opts=opts): + lines.extend(s.splitlines())     eob = buf.get_end_iter()   offset = eob.get_offset()