Show More
@@ -255,10 +255,7 def parsepatch(fp): | |||||
255 |
|
255 | |||
256 | def filterpatch(ui, chunks): |
|
256 | def filterpatch(ui, chunks): | |
257 | """Interactively filter patch chunks into applied-only chunks""" |
|
257 | """Interactively filter patch chunks into applied-only chunks""" | |
258 | chunks = list(chunks) |
|
258 | def consumefile(chunks): | |
259 | chunks.reverse() |
|
|||
260 | seen = set() |
|
|||
261 | def consumefile(): |
|
|||
262 | """fetch next portion from chunks until a 'header' is seen |
|
259 | """fetch next portion from chunks until a 'header' is seen | |
263 | NB: header == new-file mark |
|
260 | NB: header == new-file mark | |
264 | """ |
|
261 | """ | |
@@ -266,10 +263,12 def filterpatch(ui, chunks): | |||||
266 | while chunks: |
|
263 | while chunks: | |
267 | if isinstance(chunks[-1], header): |
|
264 | if isinstance(chunks[-1], header): | |
268 | break |
|
265 | break | |
269 | else: |
|
266 | consumed.append(chunks.pop()) | |
270 | consumed.append(chunks.pop()) |
|
|||
271 | return consumed |
|
267 | return consumed | |
272 |
|
268 | |||
|
269 | chunks = list(chunks) | |||
|
270 | chunks.reverse() | |||
|
271 | seen = set() | |||
273 | resp_all = [None] # this two are changed from inside prompt, |
|
272 | resp_all = [None] # this two are changed from inside prompt, | |
274 | resp_file = [None] # so can't be usual variables |
|
273 | resp_file = [None] # so can't be usual variables | |
275 | applied = {} # 'filename' -> [] of chunks |
|
274 | applied = {} # 'filename' -> [] of chunks | |
@@ -332,7 +331,7 def filterpatch(ui, chunks): | |||||
332 | fixoffset = 0 |
|
331 | fixoffset = 0 | |
333 | hdr = ''.join(chunk.header) |
|
332 | hdr = ''.join(chunk.header) | |
334 | if hdr in seen: |
|
333 | if hdr in seen: | |
335 | consumefile() |
|
334 | consumefile(chunks) | |
336 | continue |
|
335 | continue | |
337 | seen.add(hdr) |
|
336 | seen.add(hdr) | |
338 | if resp_all[0] is None: |
|
337 | if resp_all[0] is None: | |
@@ -342,9 +341,9 def filterpatch(ui, chunks): | |||||
342 | if r: |
|
341 | if r: | |
343 | applied[chunk.filename()] = [chunk] |
|
342 | applied[chunk.filename()] = [chunk] | |
344 | if chunk.allhunks(): |
|
343 | if chunk.allhunks(): | |
345 | applied[chunk.filename()] += consumefile() |
|
344 | applied[chunk.filename()] += consumefile(chunks) | |
346 | else: |
|
345 | else: | |
347 | consumefile() |
|
346 | consumefile(chunks) | |
348 | else: |
|
347 | else: | |
349 | # new hunk |
|
348 | # new hunk | |
350 | if resp_file[0] is None and resp_all[0] is None: |
|
349 | if resp_file[0] is None and resp_all[0] is None: |
General Comments 0
You need to be logged in to leave comments.
Login now