Show More
@@ -266,13 +266,7 b' def filterpatch(ui, chunks):' | |||||
266 | consumed.append(chunks.pop()) |
|
266 | consumed.append(chunks.pop()) | |
267 | return consumed |
|
267 | return consumed | |
268 |
|
268 | |||
269 | chunks = list(chunks) |
|
269 | def prompt(skipfile, skipall, query): | |
270 | chunks.reverse() |
|
|||
271 | seen = set() |
|
|||
272 | resp_all = [None] # this two are changed from inside prompt, |
|
|||
273 | resp_file = [None] # so can't be usual variables |
|
|||
274 | applied = {} # 'filename' -> [] of chunks |
|
|||
275 | def prompt(query): |
|
|||
276 | """prompt query, and process base inputs |
|
270 | """prompt query, and process base inputs | |
277 |
|
271 | |||
278 | - y/n for the rest of file |
|
272 | - y/n for the rest of file | |
@@ -280,13 +274,12 b' def filterpatch(ui, chunks):' | |||||
280 | - ? (help) |
|
274 | - ? (help) | |
281 | - q (quit) |
|
275 | - q (quit) | |
282 |
|
276 | |||
283 |
Return |
|
277 | Return True/False and possibly updated skipfile and skipall. | |
284 | appropriate. |
|
|||
285 | """ |
|
278 | """ | |
286 |
if |
|
279 | if skipall is not None: | |
287 |
return |
|
280 | return skipall, skipfile, skipall | |
288 |
if |
|
281 | if skipfile is not None: | |
289 |
return |
|
282 | return skipfile, skipfile, skipall | |
290 | while True: |
|
283 | while True: | |
291 | resps = _('[Ynsfdaq?]') |
|
284 | resps = _('[Ynsfdaq?]') | |
292 | choices = (_('&Yes, record this change'), |
|
285 | choices = (_('&Yes, record this change'), | |
@@ -311,33 +304,40 b' def filterpatch(ui, chunks):' | |||||
311 | elif r == 1: # no |
|
304 | elif r == 1: # no | |
312 | ret = False |
|
305 | ret = False | |
313 | elif r == 2: # Skip |
|
306 | elif r == 2: # Skip | |
314 |
ret = |
|
307 | ret = skipfile = False | |
315 | elif r == 3: # file (Record remaining) |
|
308 | elif r == 3: # file (Record remaining) | |
316 |
ret = |
|
309 | ret = skipfile = True | |
317 | elif r == 4: # done, skip remaining |
|
310 | elif r == 4: # done, skip remaining | |
318 |
ret = |
|
311 | ret = skipall = False | |
319 | elif r == 5: # all |
|
312 | elif r == 5: # all | |
320 |
ret = |
|
313 | ret = skipall = True | |
321 | elif r == 6: # quit |
|
314 | elif r == 6: # quit | |
322 | raise util.Abort(_('user quit')) |
|
315 | raise util.Abort(_('user quit')) | |
323 | return ret |
|
316 | return ret, skipfile, skipall | |
|
317 | ||||
|
318 | chunks = list(chunks) | |||
|
319 | chunks.reverse() | |||
|
320 | seen = set() | |||
|
321 | applied = {} # 'filename' -> [] of chunks | |||
|
322 | skipfile, skipall = None, None | |||
324 | pos, total = 0, len(chunks) - 1 |
|
323 | pos, total = 0, len(chunks) - 1 | |
325 | while chunks: |
|
324 | while chunks: | |
326 | pos = total - len(chunks) + 1 |
|
325 | pos = total - len(chunks) + 1 | |
327 | chunk = chunks.pop() |
|
326 | chunk = chunks.pop() | |
328 | if isinstance(chunk, header): |
|
327 | if isinstance(chunk, header): | |
329 | # new-file mark |
|
328 | # new-file mark | |
330 |
|
|
329 | skipfile = None | |
331 | fixoffset = 0 |
|
330 | fixoffset = 0 | |
332 | hdr = ''.join(chunk.header) |
|
331 | hdr = ''.join(chunk.header) | |
333 | if hdr in seen: |
|
332 | if hdr in seen: | |
334 | consumefile(chunks) |
|
333 | consumefile(chunks) | |
335 | continue |
|
334 | continue | |
336 | seen.add(hdr) |
|
335 | seen.add(hdr) | |
337 |
if |
|
336 | if skipall is None: | |
338 | chunk.pretty(ui) |
|
337 | chunk.pretty(ui) | |
339 |
|
|
338 | msg = (_('examine changes to %s?') % | |
340 |
|
|
339 | _(' and ').join(map(repr, chunk.files()))) | |
|
340 | r, skipfile, skipall = prompt(skipfile, skipall, msg) | |||
341 | if r: |
|
341 | if r: | |
342 | applied[chunk.filename()] = [chunk] |
|
342 | applied[chunk.filename()] = [chunk] | |
343 | if chunk.allhunks(): |
|
343 | if chunk.allhunks(): | |
@@ -346,12 +346,13 b' def filterpatch(ui, chunks):' | |||||
346 | consumefile(chunks) |
|
346 | consumefile(chunks) | |
347 | else: |
|
347 | else: | |
348 | # new hunk |
|
348 | # new hunk | |
349 |
if |
|
349 | if skipfile is None and skipall is None: | |
350 | chunk.pretty(ui) |
|
350 | chunk.pretty(ui) | |
351 |
|
|
351 | msg = (total == 1 | |
352 |
and |
|
352 | and (_('record this change to %r?') % chunk.filename()) | |
353 |
or |
|
353 | or (_('record change %d/%d to %r?') % | |
354 |
|
|
354 | (pos, total, chunk.filename()))) | |
|
355 | r, skipfile, skipall = prompt(skipfile, skipall, msg) | |||
355 | if r: |
|
356 | if r: | |
356 | if fixoffset: |
|
357 | if fixoffset: | |
357 | chunk = copy.copy(chunk) |
|
358 | chunk = copy.copy(chunk) |
General Comments 0
You need to be logged in to leave comments.
Login now