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

status: improve visualization of partially selected files

in the diff header, show the total count of hunks and changed lines
and the count of selected hunks and changed lines. When 0 hunks
are selected, change to 'rejected' font of soft grey.

Changeset 4a6f54cc0e8e

Parent 5527e6bd2fc7

by Steve Borho

Changes to 2 files · Browse files at 4a6f54cc0e8e Showing diff from parent 5527e6bd2fc7 Diff from another changeset...

Change 1 of 1 Show Entire File hggtk/​hgshelve.py Stacked
 
96
97
98
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
100
101
 
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
@@ -96,6 +96,32 @@
  if h.startswith('index '):   return True   + def selpretty(self, selected): + str = '' + for h in self.header: + if h.startswith('index '): + str += _('this modifies a binary file (all or nothing)\n') + break + if self.pretty_re.match(h): + str += h + if self.binary(): + str += _('this is a binary file\n') + break + if h.startswith('---'): + hunks = len(self.hunks) + shunks, lines, slines = 0, 0, 0 + for i, h in enumerate(self.hunks): + lines += h.added + h.removed + if selected(i): + shunks += 1 + slines += h.added + h.removed + str += _('total: %d hunks (%d changed lines); ' + 'selected: %d hunks (%d changed lines)') % (hunks, + lines, shunks, slines) + break + str += h + return str +   def pretty(self, fp):   for h in self.header:   if h.startswith('index '):
Change 1 of 5 Show Entire File hggtk/​status.py Stacked
 
617
618
619
 
 
 
 
620
621
622
623
624
 
625
626
 
627
628
629
 
631
632
633
 
 
 
 
 
 
 
 
 
 
 
634
635
636
 
842
843
844
845
 
846
847
848
849
850
 
851
852
853
 
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
 
873
874
875
 
919
920
921
922
923
924
925
926
927
 
 
928
929
930
 
931
932
933
934
 
 
 
 
935
936
937
 
617
618
619
620
621
622
623
624
 
 
 
 
625
626
 
627
628
629
630
 
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
 
854
855
856
 
857
858
859
860
861
 
862
863
864
865
 
868
869
870
 
871
872
873
 
 
 
 
 
 
 
 
 
 
874
875
876
877
 
921
922
923
 
 
 
 
 
 
924
925
926
927
 
928
929
930
931
932
933
934
935
936
937
938
939
@@ -617,13 +617,14 @@
  '''Update chunk toggle state to match file toggle state'''   wfile = util.pconvert(entry[FM_PATH])   if wfile not in self._filechunks: return + selected = entry[FM_CHECKED] + for n in self._filechunks[wfile][1:]: + self.diff_model[n][DM_REJECTED] = not selected + self._update_diff_hunk(self.diff_model[n])   entry[FM_PARTIAL_SELECTED] = False - self._update_partial(self.diff_model, wfile, False) - for n in self._filechunks[wfile][1:]: - self.diff_model[n][DM_REJECTED] = not entry[FM_CHECKED] - self._update_diff_model_row(self.diff_model[n]) + self._update_diff_header(self.diff_model, wfile, selected)   - def _update_diff_model_row(self, row): + def _update_diff_hunk(self, row):   if row[DM_REJECTED]:   row[DM_FONT] = self.rejfont   row[DM_DISPLAYED] = row[DM_TEXT] @@ -631,6 +632,17 @@
  row[DM_FONT] = self.difffont   row[DM_DISPLAYED] = row[DM_MARKUP]   + def _update_diff_header(self, dmodel, wfile, selected): + hc = self._filechunks[wfile][0] + row = dmodel[hc] + displayed = row[DM_DISPLAYED] + sel = lambda x: not dmodel[hc+x+1][DM_REJECTED] + newtext = self._shelve_chunks[row[DM_CHUNK_ID]].selpretty(sel) + row[DM_DISPLAYED] = newtext + if selected: + row[DM_FONT] = self.headerfont + else: + row[DM_FONT] = self.rejfont     def _show_toggle(self, check, toggletype):   self.opts[toggletype] = check.get_active() @@ -842,12 +854,12 @@
  if row[DM_IS_HEADER]:   for n in fchunks:   dmodel[n][DM_REJECTED] = fr[FM_CHECKED] - self._update_diff_model_row(dmodel[n]) + self._update_diff_hunk(dmodel[n])   newvalue = not fr[FM_CHECKED]   partial = False   else:   row[DM_REJECTED] = not row[DM_REJECTED] - self._update_diff_model_row(row) + self._update_diff_hunk(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 @@ -856,20 +868,10 @@
  # Update file's check status   if fr[FM_PARTIAL_SELECTED] != partial:   fr[FM_PARTIAL_SELECTED] = partial - self._update_partial(dmodel, wfile, partial)   if fr[FM_CHECKED] != newvalue:   fr[FM_CHECKED] = newvalue   self._update_check_count() - - def _update_partial(self, dmodel, wfile, partial): - hc = self._filechunks[wfile][0] - row = dmodel[hc] - displayed = row[DM_DISPLAYED] - tag = ' ** Partial **' - 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)] + self._update_diff_header(dmodel, wfile, newvalue)     def _show_diff_hunks(self, files):   ''' Update the diff text ''' @@ -919,19 +921,19 @@
  self._filechunks = {}   skip = False   for n, chunk in enumerate(self._shelve_chunks): - fp = cStringIO.StringIO() - chunk.pretty(fp) - markedup = markup(fp) - text = unmarkup(fp) - isheader = isinstance(chunk, hgshelve.header) - if isheader: + if isinstance(chunk, hgshelve.header): + text = chunk.selpretty(lambda x: True)   for f in chunk.files():   self._filechunks[f] = [len(self.diff_model)] - row = [False, markedup, text, markedup, + row = [False, text, text, text,   True, n, self.headerfont]   self.diff_model.append(row)   skip = chunk.special()   elif not skip: + fp = cStringIO.StringIO() + chunk.pretty(fp) + markedup = markup(fp) + text = unmarkup(fp)   f = chunk.filename()   self._filechunks[f].append(len(self.diff_model))   row = [False, markedup, text, markedup,