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

status: Add check box to toggle display of rejected chunks

Changeset e3fdbb14ca5b

Parent e2ca749154c3

by Steve Borho

Changes to one file · Browse files at e3fdbb14ca5b Showing diff from parent e2ca749154c3 Diff from another changeset...

Change 1 of 8 Show Entire File hggtk/​status.py Stacked
 
26
27
28
29
30
 
 
31
32
33
 
301
302
303
304
305
 
306
307
308
 
309
310
311
 
314
315
316
 
317
318
319
320
321
322
323
324
 
325
326
327
328
329
330
 
 
 
 
 
 
 
 
331
332
333
 
339
340
341
 
342
343
344
 
353
354
355
 
 
 
 
 
 
 
 
 
 
 
 
 
356
357
358
 
549
550
551
 
552
553
554
 
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
 
 
 
 
 
 
 
 
 
770
771
772
773
 
 
774
775
776
777
778
779
780
781
782
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
783
784
785
 
828
829
830
831
 
832
833
834
835
 
836
837
838
 
26
27
28
 
 
29
30
31
32
33
 
301
302
303
 
 
304
305
306
 
307
308
309
310
 
313
314
315
316
317
318
319
 
 
 
 
 
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
 
343
344
345
346
347
348
349
 
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
 
567
568
569
570
571
572
573
 
768
769
770
 
771
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
772
773
774
775
776
777
778
779
780
781
782
 
 
783
784
785
 
 
 
 
 
 
 
 
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
 
850
851
852
 
853
854
855
856
 
857
858
859
860
@@ -26,8 +26,8 @@
   # diff_model row enumerations  DM_REJECTED = 0 -DM_CHUNK_TEXT = 1 -DM_NOT_HEADER_CHUNK = 2 +DM_NOT_REJECTED = 1 +DM_CHUNK_TEXT = 2  DM_HEADER_CHUNK = 3  DM_CHUNK_ID = 4   @@ -301,11 +301,10 @@
  diff_frame.set_shadow_type(gtk.SHADOW_ETCHED_IN)   scroller = gtk.ScrolledWindow()   scroller.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) - diff_frame.add(scroller) - +   if self.count_revs() == 2 or len(self.repo.changectx(None).parents()) == 1:   # use treeview to diff hunks - self.diff_model = gtk.ListStore(bool, str, bool, bool, int) + self.diff_model = gtk.ListStore(bool, bool, str, bool, int)   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)) @@ -314,20 +313,25 @@
  self.diff_tree.connect('row-activated',   self._diff_tree_row_act)   self.diff_tree.set_enable_search(False) + self.diff_tree.set_headers_visible(False)     diff_hunk_cell = gtk.CellRendererText()   diff_hunk_cell.set_property('cell-background', '#EEEEEE') - diffcol = gtk.TreeViewColumn('diff', diff_hunk_cell, - strikethrough=DM_REJECTED, - markup=DM_CHUNK_TEXT, - strikethrough_set=DM_NOT_HEADER_CHUNK, - cell_background_set=DM_HEADER_CHUNK) + diffcol = gtk.TreeViewColumn('diff', diff_hunk_cell)   diffcol.set_resizable(True)   self.diff_tree.append_column(diffcol)   self.tree.get_selection().set_mode(gtk.SELECTION_MULTIPLE)   self.tree.get_selection().connect('changed',   self._tree_selection_changed, False)   scroller.add(self.diff_tree) + + vbox = gtk.VBox() + visiblerejects = gtk.CheckButton("Show Rejected Chunks") + visiblerejects.connect('toggled', self._toggle_rejects, diffcol, diff_hunk_cell) + vbox.pack_start(visiblerejects, False, False, 2) + vbox.pack_start(scroller, True, True, 2) + self._toggle_rejects(visiblerejects, diffcol, diff_hunk_cell) + diff_frame.add(vbox)   else:   # display merge diffs in simple text view   self.merge_diff_text = gtk.TextView() @@ -339,6 +343,7 @@
  self._merge_tree_selection_changed, False)   self._activate_shelve_buttons(False)   scroller.add(self.merge_diff_text) + diff_frame.add(scroller)     if self.diffbottom:   self._diffpane = gtk.VPaned() @@ -353,6 +358,19 @@
  return self._diffpane     + def _toggle_rejects(self, widget, diffcol, cell): + diffcol.clear_attributes(cell) + if widget.get_active(): + diffcol.set_attributes(cell, + strikethrough=DM_REJECTED, + markup=DM_CHUNK_TEXT, + cell_background_set=DM_HEADER_CHUNK) + else: + diffcol.set_attributes(cell, + visible=DM_NOT_REJECTED, + markup=DM_CHUNK_TEXT, + cell_background_set=DM_HEADER_CHUNK) +   def get_extras(self):   table = gtk.Table(rows=2, columns=3)   table.set_col_spacings(8) @@ -549,6 +567,7 @@
  file = entry[2]   if file not in self._filechunks: return   for n in self._filechunks[file][1:]: + self.diff_model[n][DM_NOT_REJECTED] = entry[0]   self.diff_model[n][DM_REJECTED] = not entry[0]     def _show_toggle(self, check, type): @@ -749,37 +768,40 @@
  selection.select_path((row,))   return False   -   def _diff_tree_row_act(self, tree, path, column): - row = self.diff_model[path] - chunk = self._shelve_chunks[row[DM_CHUNK_ID]] - file = chunk.filename() - if file not in self._filechunks: return - if row[DM_HEADER_CHUNK]: - for n in self._filechunks[file][1:]: - self.diff_model[n][DM_REJECTED] = not self.diff_model[n][DM_REJECTED] - newvalue = False - for n in self._filechunks[file][1:]: - if not self.diff_model[n][DM_REJECTED]: - newvalue = True - break - else: - row[DM_REJECTED] = not row[DM_REJECTED] - if row[DM_REJECTED]: - # File has at least one inactive chunk, check others + try: + row = self.diff_model[path] + chunk = self._shelve_chunks[row[DM_CHUNK_ID]] + file = chunk.filename() + if file not in self._filechunks: return + if row[DM_HEADER_CHUNK]: + for n in self._filechunks[file][1:]: + self.diff_model[n][DM_REJECTED] = not self.diff_model[n][DM_REJECTED] + newvalue = False   for n in self._filechunks[file][1:]:   if not self.diff_model[n][DM_REJECTED]: - return - newvalue = False + newvalue = True + break   else: - newvalue = True - # Update file's check status - for fr in self.model: - if fr[2] == file: - if fr[0] != newvalue: - fr[0] = newvalue - self._update_check_count() - return + row[DM_REJECTED] = not row[DM_REJECTED] + if row[DM_REJECTED]: + # File has at least one inactive chunk, check others + for n in self._filechunks[file][1:]: + if not self.diff_model[n][DM_REJECTED]: + return + newvalue = False + else: + newvalue = True + # Update file's check status + for fr in self.model: + if fr[2] == file: + if fr[0] != newvalue: + fr[0] = newvalue + self._update_check_count() + return + finally: + for row in self.diff_model: + row[DM_NOT_REJECTED] = not row[DM_REJECTED]       def _show_diff_hunks(self, files): @@ -828,11 +850,11 @@
  isheader = isinstance(chunk, hgshelve.header)   if isheader:   self._filechunks[chunk.filename()] = [len(self.diff_model)] - self.diff_model.append([False, markedup, False, True, n]) + self.diff_model.append([False, True, markedup, True, n])   skip = chunk.special()   elif skip != True:   self._filechunks[chunk.filename()].append(len(self.diff_model)) - self.diff_model.append([False, markedup, True, False, n]) + self.diff_model.append([False, True, markedup, False, n])   finally:   difftext.close()