Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 2.0, 2.0.1, and 2.0.2

stable patchctx: display patch parsing errors prominently

We now show a special '*ParseError*' (with R status so it gets a nice red X
icon) and its diff contents show the ParseError exception raised by record.

Changeset da2821a84944

Parent dd0d41322283

by Steve Borho

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

 
19
20
21
 
22
23
24
 
92
93
94
 
 
95
96
97
 
137
138
139
 
140
141
142
143
144
145
146
 
 
 
147
148
149
150
151
152
 
153
154
155
 
186
187
188
 
 
189
190
191
 
19
20
21
22
23
24
25
 
93
94
95
96
97
98
99
100
 
140
141
142
143
144
145
146
147
148
149
 
150
151
152
153
154
155
156
157
 
158
159
160
161
 
192
193
194
195
196
197
198
199
@@ -19,6 +19,7 @@
 from tortoisehg.util import hglib    class patchctx(object): + _parseErrorFileName = '*ParseError*'     def __init__(self, patchpath, repo, pf=None, rev=None):   """ Read patch context from file @@ -92,6 +93,8 @@
  def p2(self): return None     def flags(self, wfile): + if wfile == self._parseErrorFileName: + return ''   if wfile in self._files:   for gp in patch.readgitpatch(self._files[wfile][0].header):   if gp.mode: @@ -137,19 +140,22 @@
  return summary     def changesToParent(self, whichparent): + 'called by filelistmodel to get list of files'   if whichparent == 0 and self._files:   return self._status   else:   return [], [], []     def thgmqpatchdata(self, wfile): - # return file diffs as string list without line ends + 'called by fileview to get diff data' + if wfile == self._parseErrorFileName: + return '\n\n\nErrors while parsing patch:\n'+str(self._parseerror)   if wfile in self._files:   buf = cStringIO.StringIO()   for chunk in self._files[wfile]:   chunk.write(buf)   return buf.getvalue() - return [] + return ''     @propertycache   def _files(self): @@ -186,6 +192,8 @@
  self._fileorder.append(path)   files[path].extend(chunk.hunks)   except patch.PatchError, e: + self._status[2].append(self._parseErrorFileName) + files[self._parseErrorFileName] = []   self._parseerror = e   if 'THGDEBUG' in os.environ:   print e