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

changeset: show +/- counts in file header line

pruned away a lot of dead code

Changeset 81a248104b70

Parent c6a225d4ccba

by Steve Borho

Changes to one file · Browse files at 81a248104b70 Showing diff from parent c6a225d4ccba Diff from another changeset...

 
200
201
202
203
 
204
205
206
 
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
 
 
 
 
 
 
 
 
 
 
 
 
 
 
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
 
255
256
257
258
259
260
261
262
263
264
 
269
270
271
272
273
 
274
275
276
 
200
201
202
 
203
204
205
206
 
211
212
213
 
 
 
 
 
214
215
216
217
218
219
 
 
 
 
 
220
221
222
223
224
 
 
 
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
240
241
242
243
 
244
245
 
246
247
248
 
253
254
255
 
 
256
257
258
259
@@ -200,7 +200,7 @@
  eob = buf.get_end_iter()   offset = eob.get_offset()   pos = buf.get_iter_at_offset(offset) - fileoffs, tags, lines, statmax = self.prepare_diff(lines, offset, file) + tags, lines = self.prepare_diff(lines, offset, file)   for l in lines:   buf.insert(eob, l)   @@ -211,54 +211,38 @@
  txt = buf.get_text(i0, i1)   buf.apply_tag_by_name(name, i0, i1)   - # inserts the marks - for mark, offset, stats in fileoffs: - pos = buf.get_iter_at_offset(offset) - mark = 'mark_%d' % offset - buf.create_mark(mark, pos)   sob, eob = buf.get_bounds()   buf.apply_tag_by_name("mono", pos, eob)   return True     def prepare_diff(self, difflines, offset, fname):   '''Borrowed from hgview; parses changeset diffs''' - DIFFHDR = "=== %s ===\n" - idx = 0 - outlines = [] - tags = [] - filespos = []   def addtag( name, offset, length ):   if tags and tags[-1][0] == name and tags[-1][2]==offset:   tags[-1][2] += length   else:   tags.append( [name, offset, offset+length] ) - stats = [0,0] - statmax = 0 - for i,l1 in enumerate(difflines): + + add, rem = 0, 0 + for l in difflines[3:]: + if l.startswith('+'): + add += 1 + elif l.startswith('-'): + rem += 1 + outlines = [] + tags = [] + txt = toutf("=== (+%d,-%d) %s ===\n" % (add, rem, fname)) + addtag( "greybg", offset, len(txt) ) + outlines.append(txt) + offset += len(txt.decode('utf-8')) + for l1 in difflines[3:]:   l = toutf(l1) - if l.startswith("diff"): - txt = toutf(DIFFHDR % fname) - addtag( "greybg", offset, len(txt) ) - outlines.append(txt) - markname = "file%d" % idx - idx += 1 - statmax = max( statmax, stats[0]+stats[1] ) - stats = [0,0] - filespos.append(( markname, offset, stats )) - offset += len(txt.decode('utf-8')) - continue - elif l.startswith("+++"): - continue - elif l.startswith("---"): - continue - elif l.startswith("@@"): + if l.startswith("@@"):   tag = "blue"   elif l.startswith("+"):   tag = "green" - stats[0] += 1   l = diffexpand(l)   elif l.startswith("-"): - stats[1] += 1   tag = "red"   l = diffexpand(l)   else: @@ -269,8 +253,7 @@
  addtag( tag, offset, length )   outlines.append( l )   offset += length - statmax = max( statmax, stats[0]+stats[1] ) - return filespos, tags, outlines, statmax + return tags, outlines     def link_event(self, tag, widget, event, liter):   if event.type != gtk.gdk.BUTTON_RELEASE: