Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.0.2, 1.0.3, and 1.0.4

stable status: catch LookupError and friends from patch.diff()

Try not to barf when file revisions are missing.

Closes #1102

Changeset 56b42d08d603

Parent 7c54c5bace2c

by Steve Borho

Changes to one file · Browse files at 56b42d08d603 Showing diff from parent 7c54c5bace2c Diff from another changeset...

 
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
 
 
 
 
 
 
 
 
 
 
 
1058
1059
1060
 
1118
1119
1120
 
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
 
 
 
 
 
 
 
 
 
 
 
 
1134
1135
1136
1137
 
 
 
 
 
 
1138
1139
1140
 
1174
1175
1176
1177
1178
1179
 
 
 
 
 
 
1180
1181
1182
 
1047
1048
1049
 
 
 
 
 
 
 
 
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
 
1121
1122
1123
1124
1125
1126
1127
 
 
 
 
 
 
 
 
 
 
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
 
 
 
1141
1142
1143
1144
1145
1146
1147
1148
1149
 
1183
1184
1185
 
 
 
1186
1187
1188
1189
1190
1191
1192
1193
1194
@@ -1047,14 +1047,17 @@
  opts.git = True   wctx = self.repo[None]   pctx1, pctx2 = wctx.parents() - difftext = [_('===== Diff to first parent %d:%s =====\n') % ( - pctx1.rev(), str(pctx1))] - for s in patch.diff(self.repo, pctx1.node(), None, opts=opts): - difftext.extend(s.splitlines(True)) - difftext.append(_('\n===== Diff to second parent %d:%s =====\n') % ( - pctx2.rev(), str(pctx2))) - for s in patch.diff(self.repo, pctx2.node(), None, opts=opts): - difftext.extend(s.splitlines(True)) + header = _('===== Diff to %s parent %d:%s =====\n') + difftext = [header % (_('first'), pctx1.rev(), str(pctx1))] + try: + for s in patch.diff(self.repo, pctx1.node(), None, opts=opts): + difftext.extend(s.splitlines(True)) + difftext.append('\n') + difftext.append(header % (_('second'), pctx2.rev(), str(pctx2))) + for s in patch.diff(self.repo, pctx2.node(), None, opts=opts): + difftext.extend(s.splitlines(True)) + except (IOError, error.RepoError, error.LookupError, util.Abort), e: + self.stbar.set_text(str(e))   else:   buf = cStringIO.StringIO()   for row in self.filemodel: @@ -1118,23 +1121,29 @@
  opts = patch.diffopts(self.ui, self.opts)   opts.git = True   difftext = [] + header = _('===== Diff to %s parent %d:%s =====\n')   if self.is_merge():   wctx = self.repo[None]   pctx1, pctx2 = wctx.parents() - difftext = [_('===== Diff to first parent %d:%s =====\n') % ( - pctx1.rev(), str(pctx1))] - for s in patch.diff(self.repo, pctx1.node(), None, - match=matcher, opts=opts): - difftext.extend(s.splitlines(True)) - difftext.append(_('\n===== Diff to second parent %d:%s =====\n') % ( - pctx2.rev(), str(pctx2))) - for s in patch.diff(self.repo, pctx2.node(), None, - match=matcher, opts=opts): - difftext.extend(s.splitlines(True)) + difftext = [header % (_('first'), pctx1.rev(), str(pctx1))] + try: + for s in patch.diff(self.repo, pctx1.node(), None, + match=matcher, opts=opts): + difftext.extend(s.splitlines(True)) + difftext.append('\n') + difftext.append(header % (_('second'), pctx2.rev(), str(pctx2))) + for s in patch.diff(self.repo, pctx2.node(), None, + match=matcher, opts=opts): + difftext.extend(s.splitlines(True)) + except (IOError, error.RepoError, error.LookupError, util.Abort), e: + self.stbar.set_text(str(e))   else: - for s in patch.diff(self.repo, self._node1, self._node2, - match=matcher, opts=opts): - difftext.extend(s.splitlines(True)) + try: + for s in patch.diff(self.repo, self._node1, self._node2, + match=matcher, opts=opts): + difftext.extend(s.splitlines(True)) + except (IOError, error.RepoError, error.LookupError, util.Abort), e: + self.stbar.set_text(str(e))   return self.diff_highlight_buffer(difftext)     @@ -1174,9 +1183,12 @@
  else:   matcher = cmdutil.matchfiles(self.repo, [pfile])   diffopts = mdiff.diffopts(git=True, nodates=True) - for s in patch.diff(self.repo, self._node1, self._node2, - match=matcher, opts=diffopts): - difftext.writelines(s.splitlines(True)) + try: + for s in patch.diff(self.repo, self._node1, self._node2, + match=matcher, opts=diffopts): + difftext.writelines(s.splitlines(True)) + except (IOError, error.RepoError, error.LookupError, util.Abort), e: + self.stbar.set_text(str(e))   difftext.seek(0)   return hgshelve.parsepatch(difftext)