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

patchctx: record.parsepatch() API changed with ad1b46e4a575

Rather than returning <header> <hunk> ... <header> <hunk> ..
It now returns a list of header objects, each with a hunks list member

Changeset 9152f172c504

Parent d81235b13f08

by Steve Borho

Changes to 3 files · Browse files at 9152f172c504 Showing diff from parent d81235b13f08 Diff from another changeset...

 
325
326
327
328
 
 
329
330
331
 
566
567
568
569
 
 
570
571
572
 
325
326
327
 
328
329
330
331
332
 
567
568
569
 
570
571
572
573
574
@@ -325,7 +325,8 @@
  opts=diffopts):   buf.write(p)   buf.seek(0) - return record.parsepatch(buf) + header = record.parsepatch(buf)[0] + return [header] + header.hunks     @pyqtSlot(object, object, object)   def displayFile(self, file, rev, status): @@ -566,7 +567,8 @@
  elif type(self._ctx.rev()) is str:   chunks = self._ctx._files[filename]   else: - chunks = record.parsepatch(cStringIO.StringIO(fd.diff)) + header = record.parsepatch(cStringIO.StringIO(fd.diff))[0] + chunks = [header] + header.hunks     utext = []   for chunk in chunks[1:]:
 
103
104
105
106
 
 
107
108
109
 
103
104
105
 
106
107
108
109
110
@@ -103,7 +103,8 @@
  except IOError, e:   pass   try: - self.chunks = record.parsepatch(buf)[1:] + header = record.parsepatch(buf)[0] + self.chunks = header.hunks   except patch.PatchError, e:   self.chunks = []  
 
39
40
41
 
42
43
44
 
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
181
182
183
 
39
40
41
42
43
44
45
 
165
166
167
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
@@ -39,6 +39,7 @@
  self._branch = ''   self._node = node.nullid   self._mtime = None + self._parseerror = None     try:   ph = mq.patchheader(self._path) @@ -164,20 +165,22 @@
  for i in range(self._ph.diffstartline):   pf.readline()   for chunk in record.parsepatch(pf): - if isinstance(chunk, record.header): - top = patch.parsefilename(chunk.header[-2]) - bot = patch.parsefilename(chunk.header[-1]) - type, path = get_path(top, bot) - if path not in chunk.files(): - type, path = 0, chunk.files()[-1] - if path not in files: - self._status[type].append(path) - files[path] = [chunk] - self._fileorder.append(path) - else: - files[path].append(chunk) - except patch.PatchError: - pass + if not isinstance(chunk, record.header): + continue + top = patch.parsefilename(chunk.header[-2]) + bot = patch.parsefilename(chunk.header[-1]) + type, path = get_path(top, bot) + if path not in chunk.files(): + type, path = 0, chunk.files()[-1] + if path not in files: + self._status[type].append(path) + files[path] = [chunk] + self._fileorder.append(path) + files[path].extend(chunk.hunks) + except patch.PatchError, e: + self._parseerror = e + if 'THGDEBUG' in os.environ: + print e   finally:   pf.close()   return files