Show More
@@ -433,7 +433,7 b' class uihunk(patchnode):' | |||||
433 | def __repr__(self): |
|
433 | def __repr__(self): | |
434 | return '<hunk %r@%d>' % (self.filename(), self.fromline) |
|
434 | return '<hunk %r@%d>' % (self.filename(), self.fromline) | |
435 |
|
435 | |||
436 | def filterpatch(ui, chunks, chunkselector): |
|
436 | def filterpatch(ui, chunks, chunkselector, operation=None): | |
437 | """interactively filter patch chunks into applied-only chunks""" |
|
437 | """interactively filter patch chunks into applied-only chunks""" | |
438 | chunks = list(chunks) |
|
438 | chunks = list(chunks) | |
439 | # convert chunks list into structure suitable for displaying/modifying |
|
439 | # convert chunks list into structure suitable for displaying/modifying | |
@@ -446,7 +446,7 b' def filterpatch(ui, chunks, chunkselecto' | |||||
446 | uiheaders = [uiheader(h) for h in headers] |
|
446 | uiheaders = [uiheader(h) for h in headers] | |
447 | # let user choose headers/hunks/lines, and mark their applied flags |
|
447 | # let user choose headers/hunks/lines, and mark their applied flags | |
448 | # accordingly |
|
448 | # accordingly | |
449 | ret = chunkselector(ui, uiheaders) |
|
449 | ret = chunkselector(ui, uiheaders, operation=operation) | |
450 | appliedhunklist = [] |
|
450 | appliedhunklist = [] | |
451 | for hdr in uiheaders: |
|
451 | for hdr in uiheaders: | |
452 | if (hdr.applied and |
|
452 | if (hdr.applied and | |
@@ -466,13 +466,13 b' def filterpatch(ui, chunks, chunkselecto' | |||||
466 |
|
466 | |||
467 | return (appliedhunklist, ret) |
|
467 | return (appliedhunklist, ret) | |
468 |
|
468 | |||
469 | def chunkselector(ui, headerlist): |
|
469 | def chunkselector(ui, headerlist, operation=None): | |
470 | """ |
|
470 | """ | |
471 | curses interface to get selection of chunks, and mark the applied flags |
|
471 | curses interface to get selection of chunks, and mark the applied flags | |
472 | of the chosen chunks. |
|
472 | of the chosen chunks. | |
473 | """ |
|
473 | """ | |
474 | ui.write(_('starting interactive selection\n')) |
|
474 | ui.write(_('starting interactive selection\n')) | |
475 | chunkselector = curseschunkselector(headerlist, ui) |
|
475 | chunkselector = curseschunkselector(headerlist, ui, operation) | |
476 | f = signal.getsignal(signal.SIGTSTP) |
|
476 | f = signal.getsignal(signal.SIGTSTP) | |
477 | curses.wrapper(chunkselector.main) |
|
477 | curses.wrapper(chunkselector.main) | |
478 | if chunkselector.initerr is not None: |
|
478 | if chunkselector.initerr is not None: | |
@@ -486,12 +486,12 b' def testdecorator(testfn, f):' | |||||
486 | return f(testfn, *args, **kwargs) |
|
486 | return f(testfn, *args, **kwargs) | |
487 | return u |
|
487 | return u | |
488 |
|
488 | |||
489 | def testchunkselector(testfn, ui, headerlist): |
|
489 | def testchunkselector(testfn, ui, headerlist, operation=None): | |
490 | """ |
|
490 | """ | |
491 | test interface to get selection of chunks, and mark the applied flags |
|
491 | test interface to get selection of chunks, and mark the applied flags | |
492 | of the chosen chunks. |
|
492 | of the chosen chunks. | |
493 | """ |
|
493 | """ | |
494 | chunkselector = curseschunkselector(headerlist, ui) |
|
494 | chunkselector = curseschunkselector(headerlist, ui, operation) | |
495 | if testfn and os.path.exists(testfn): |
|
495 | if testfn and os.path.exists(testfn): | |
496 | testf = open(testfn) |
|
496 | testf = open(testfn) | |
497 | testcommands = map(lambda x: x.rstrip('\n'), testf.readlines()) |
|
497 | testcommands = map(lambda x: x.rstrip('\n'), testf.readlines()) | |
@@ -502,7 +502,7 b' def testchunkselector(testfn, ui, header' | |||||
502 | return chunkselector.opts |
|
502 | return chunkselector.opts | |
503 |
|
503 | |||
504 | class curseschunkselector(object): |
|
504 | class curseschunkselector(object): | |
505 | def __init__(self, headerlist, ui): |
|
505 | def __init__(self, headerlist, ui, operation=None): | |
506 | # put the headers into a patch object |
|
506 | # put the headers into a patch object | |
507 | self.headerlist = patch(headerlist) |
|
507 | self.headerlist = patch(headerlist) | |
508 |
|
508 | |||
@@ -556,6 +556,9 b' class curseschunkselector(object):' | |||||
556 | # if the last 'toggle all' command caused all changes to be applied |
|
556 | # if the last 'toggle all' command caused all changes to be applied | |
557 | self.waslasttoggleallapplied = True |
|
557 | self.waslasttoggleallapplied = True | |
558 |
|
558 | |||
|
559 | # affects some ui text | |||
|
560 | self.operation = operation | |||
|
561 | ||||
559 | def uparrowevent(self): |
|
562 | def uparrowevent(self): | |
560 | """ |
|
563 | """ | |
561 | try to select the previous item to the current item that has the |
|
564 | try to select the previous item to the current item that has the |
General Comments 0
You need to be logged in to leave comments.
Login now