Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.0, 1.0.1, and 1.0.2

stable status: break max diff-size check into it's own function for reuse

Refs #897

Changeset e85f55e53828

Parent 328a4f3f0d23

by Steve Borho

Changes to one file · Browse files at e85f55e53828 Showing diff from parent 328a4f3f0d23 Diff from another changeset...

 
92
93
94
 
95
96
97
 
1153
1154
1155
1156
1157
1158
 
 
 
 
1159
1160
1161
1162
1163
1164
1165
1166
1167
 
1168
1169
1170
1171
 
 
 
 
 
 
 
 
 
 
1172
1173
1174
 
92
93
94
95
96
97
98
 
1154
1155
1156
 
 
 
1157
1158
1159
1160
1161
1162
 
1163
1164
1165
1166
1167
 
1168
1169
1170
 
 
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
@@ -92,6 +92,7 @@
  self.preview_tab_name_label = None   self.subrepos = []   self.colorstyle = self.repo.ui.config('tortoisehg', 'diffcolorstyle') + self.ignoremaxdiff = False     def auto_check(self):   # Only auto-check files once, and only if a pattern was given. @@ -1153,22 +1154,30 @@
  if len(self.diffmodel):   tree.scroll_to_cell(0, use_align=True, row_align=0.0)   - def read_file_chunks(self, wfile): - 'Get diffs of working file, parse into (c)hunks' - difftext = cStringIO.StringIO() + def check_max_diff(self, pfile): + lines = [] + if self.ignoremaxdiff: + return lines   ctx = self.repo[self._node1]   try: - pfile = util.pconvert(wfile)   fctx = ctx.filectx(pfile)   except error.LookupError:   fctx = None   if fctx and fctx.size() > hglib.getmaxdiffsize(self.repo.ui):   # Fake patch that displays size warning - lines = ['diff --git a/%s b/%s\n' % (wfile, wfile)] + lines = ['diff --git a/%s b/%s\n' % (pfile, pfile)]   lines.append(_('File is larger than the specified max size.\n'))   lines.append(_('Hunk selection is disabled for this file.\n')) - lines.append('--- a/%s\n' % wfile) - lines.append('+++ b/%s\n' % wfile) + lines.append('--- a/%s\n' % pfile) + lines.append('+++ b/%s\n' % pfile) + return lines + + def read_file_chunks(self, wfile): + 'Get diffs of working file, parse into (c)hunks' + difftext = cStringIO.StringIO() + pfile = util.pconvert(wfile) + lines = self.check_max_diff(pfile) + if lines:   difftext.writelines(lines)   difftext.seek(0)   else: