Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.7, 0.7.1, and 0.7.2

status: use color and italics to show rejected hunks

Changeset 2ac69f2c669f

Parent 974cfcd26549

by Steve Borho

Changes to one file · Browse files at 2ac69f2c669f Showing diff from parent 974cfcd26549 Diff from another changeset...

Change 1 of 10 Show Entire File hggtk/​status.py Stacked
 
34
35
36
37
38
39
 
 
 
 
 
 
40
41
42
 
267
268
269
270
 
 
 
271
272
273
274
275
276
277
 
310
311
312
313
314
315
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
316
317
318
319
 
 
320
321
322
 
323
324
325
 
332
333
334
335
 
336
337
338
339
 
340
341
342
343
 
 
 
 
 
 
344
345
346
347
348
349
 
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
 
614
615
616
 
 
 
 
 
 
 
 
 
 
617
618
619
 
822
823
824
825
 
826
827
 
828
829
830
831
 
832
833
834
 
845
846
847
848
 
849
850
851
852
853
 
 
 
 
854
855
856
 
871
872
873
 
874
 
 
 
 
 
 
 
875
876
877
 
895
896
897
 
898
899
900
901
902
 
 
 
903
904
905
906
907
 
 
 
908
909
910
 
34
35
36
 
 
 
37
38
39
40
41
42
43
44
45
 
270
271
272
 
273
274
275
276
277
278
 
279
280
281
 
314
315
316
 
 
 
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
 
335
336
337
338
 
339
340
341
342
 
349
350
351
 
352
353
354
355
 
356
357
 
 
 
358
359
360
361
362
363
364
 
 
365
366
367
 
377
378
379
 
 
 
 
 
 
 
 
 
 
 
 
380
381
382
 
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
 
838
839
840
 
841
842
843
844
845
846
847
848
849
850
851
852
 
863
864
865
 
866
867
 
 
 
 
868
869
870
871
872
873
874
 
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
 
921
922
923
924
925
926
927
928
 
929
930
931
932
933
934
935
 
936
937
938
939
940
941
@@ -34,9 +34,12 @@
   # diff_model row enumerations  DM_REJECTED = 0 -DM_CHUNK_TEXT = 1 -DM_HEADER_CHUNK = 2 -DM_CHUNK_ID = 3 +DM_MARKUP = 1 +DM_TEXT = 2 +DM_DISPLAYED = 3 +DM_IS_HEADER = 4 +DM_CHUNK_ID = 5 +DM_FONT = 6    class GStatus(GDialog):   """GTK+ based dialog for displaying repository status @@ -267,11 +270,12 @@
  stat_cell = gtk.CellRendererText()     self.selcb = None - if self.count_revs() < 2 and len(self.repo.changectx(None).parents()) == 1: + ismerge = len(self.repo.changectx(None).parents()) == 2 + if self.count_revs() < 2 and not ismerge: + # show file selection checkboxes only when applicable   col0 = gtk.TreeViewColumn('', toggle_cell)   col0.add_attribute(toggle_cell, 'active', FM_CHECKED)   col0.add_attribute(toggle_cell, 'inconsistent', FM_PARTIAL_SELECTED) - #col0.set_sort_column_id(0)   col0.set_resizable(False)   self.filetree.append_column(col0)   self.selcb = self._add_header_checkbox(col0, self._sel_clicked) @@ -310,16 +314,29 @@
  scroller = gtk.ScrolledWindow()   scroller.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)   - if self.count_revs() == 2 or len(self.repo.changectx(None).parents()) == 1: - # use treeview to diff hunks - + self.difffont = pango.FontDescription(self.fontlist) + if len(self.repo.changectx(None).parents()) == 2: + # display merge diffs in simple text view + self.clipboard = None + self.merge_diff_text = gtk.TextView() + self.merge_diff_text.set_wrap_mode(gtk.WRAP_NONE) + self.merge_diff_text.set_editable(False) + self.merge_diff_text.modify_font(self.difffont) + self.filetree.get_selection().set_mode(gtk.SELECTION_SINGLE) + self.filetree.get_selection().connect('changed', + self._merge_tree_selection_changed, False) + scroller.add(self.merge_diff_text) + diff_frame.add(scroller) + else: + # use treeview to show selectable diff hunks   sel = (os.name == 'nt') and 'CLIPBOARD' or 'PRIMARY'   self.clipboard = gtk.Clipboard(selection=sel)   - self.diff_model = gtk.ListStore(bool, str, bool, int) + self.diff_model = gtk.ListStore(bool, str, str, str, bool, int, + pango.FontDescription)   self.diff_tree = gtk.TreeView(self.diff_model)   self.diff_tree.get_selection().set_mode(gtk.SELECTION_MULTIPLE) - self.diff_tree.modify_font(pango.FontDescription(self.fontlist)) + #self.diff_tree.modify_font(self.difffont)   self.diff_tree.set_headers_visible(False)   self.diff_tree.set_property('enable-grid-lines', True)   self.diff_tree.connect('row-activated', @@ -332,18 +349,19 @@
  cell = gtk.CellRendererText()   diffcol = gtk.TreeViewColumn('diff', cell)   diffcol.set_resizable(True) - diffcol.add_attribute(cell, 'markup', DM_CHUNK_TEXT) + diffcol.add_attribute(cell, 'markup', DM_DISPLAYED)     # differentiate header chunks   cell.set_property('cell-background', '#EEEEEE') - diffcol.add_attribute(cell, 'cell_background_set', DM_HEADER_CHUNK) + diffcol.add_attribute(cell, 'cell_background_set', DM_IS_HEADER)   - # Rejected hunks are given darker background, smaller font - cell.set_property('background', '#CCCCCC') - cell.set_property('scale', pango.SCALE_X_SMALL) + # differentiate rejected hunks + self.rejfont = self.difffont.copy() + self.rejfont.set_style(pango.STYLE_ITALIC) + self.rejfont.set_weight(pango.WEIGHT_LIGHT) + diffcol.add_attribute(cell, 'font-desc', DM_FONT) + cell.set_property('background', '#EEEEEE')   diffcol.add_attribute(cell, 'background-set', DM_REJECTED) - diffcol.add_attribute(cell, 'scale-set', DM_REJECTED) - #diffcol.add_attribute(cell, 'strikethrough', DM_REJECTED)     self.diff_tree.append_column(diffcol)   self.filetree.get_selection().set_mode(gtk.SELECTION_MULTIPLE) @@ -359,18 +377,6 @@
  vbox.pack_start(scroller, True, True, 2)     diff_frame.add(vbox) - else: - # display merge diffs in simple text view - self.clipboard = None - self.merge_diff_text = gtk.TextView() - self.merge_diff_text.set_wrap_mode(gtk.WRAP_NONE) - self.merge_diff_text.set_editable(False) - self.merge_diff_text.modify_font(pango.FontDescription(self.fontdiff)) - self.filetree.get_selection().set_mode(gtk.SELECTION_SINGLE) - self.filetree.get_selection().connect('changed', - self._merge_tree_selection_changed, False) - scroller.add(self.merge_diff_text) - diff_frame.add(scroller)     if self.diffbottom:   self._diffpane = gtk.VPaned() @@ -614,6 +620,16 @@
  self._update_partial(self.diff_model, file, False)   for n in self._filechunks[file][1:]:   self.diff_model[n][DM_REJECTED] = not entry[FM_CHECKED] + self._update_diff_model_row(self.diff_model[n]) + + def _update_diff_model_row(self, row): + if row[DM_REJECTED]: + row[DM_FONT] = self.rejfont + row[DM_DISPLAYED] = row[DM_TEXT] + else: + row[DM_FONT] = self.difffont + row[DM_DISPLAYED] = row[DM_MARKUP] +     def _show_toggle(self, check, type):   self.opts[type] = check.get_active() @@ -822,13 +838,15 @@
  if util.pconvert(fr[FM_PATH]) == file:   break   fchunks = self._filechunks[file][1:] - if row[DM_HEADER_CHUNK]: + if row[DM_IS_HEADER]:   for n in fchunks:   dmodel[n][DM_REJECTED] = fr[FM_CHECKED] + self._update_diff_model_row(dmodel[n])   newvalue = not fr[FM_CHECKED]   partial = False   else:   row[DM_REJECTED] = not row[DM_REJECTED] + self._update_diff_model_row(row)   rej = [ n for n in fchunks if dmodel[n][DM_REJECTED] ]   nonrej = [ n for n in fchunks if not dmodel[n][DM_REJECTED] ]   newvalue = nonrej and True or False @@ -845,12 +863,12 @@
  def _update_partial(self, dmodel, file, partial):   hc = self._filechunks[file][0]   row = dmodel[hc] - markup = row[DM_CHUNK_TEXT] + displayed = row[DM_DISPLAYED]   tag = ' ** Partial **' - if partial and not markup.endswith(tag): - row[DM_CHUNK_TEXT] = markup + tag - elif not partial and markup.endswith(tag): - row[DM_CHUNK_TEXT] = markup[0:-len(tag)] + if partial and not displayed.endswith(tag): + row[DM_DISPLAYED] = displayed + tag + elif not partial and displayed.endswith(tag): + row[DM_DISPLAYED] = displayed[0:-len(tag)]     def _show_diff_hunks(self, files):   ''' Update the diff text ''' @@ -871,7 +889,15 @@
  hunk = '<span foreground="#FF8000">%s</span>' % line   else:   hunk += line + return hunk   + def unmarkup(fp): + hunk = "" + fp.seek(0) + lines = fp.readlines() + lines[-1] = lines[-1].strip('\n\r') + for line in lines: + hunk += gobject.markup_escape_text(toutf(line))   return hunk     def dohgdiff(): @@ -895,16 +921,21 @@
  fp = cStringIO.StringIO()   chunk.pretty(fp)   markedup = markup(fp) + text = unmarkup(fp)   isheader = isinstance(chunk, hgshelve.header)   if isheader:   for f in chunk.files():   self._filechunks[f] = [len(self.diff_model)] - self.diff_model.append([False, markedup, True, n]) + row = [False, markedup, text, markedup, + True, n, self.difffont] + self.diff_model.append(row)   skip = chunk.special()   elif skip != True:   f = chunk.filename()   self._filechunks[f].append(len(self.diff_model)) - self.diff_model.append([False, markedup, False, n]) + row = [False, markedup, text, markedup, + False, n, self.difffont] + self.diff_model.append(row)   finally:   difftext.close()