Changeset 4a6f54cc0e8e…
Parent 5527e6bd2fc7…
by
Changes to 2 files · Browse files at 4a6f54cc0e8e Showing diff from parent 5527e6bd2fc7 Diff from another changeset...
@@ -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 '):
|
@@ -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,
|
Loading...