From a8d145705634e1edf6c40e2efd920f2cd6f03366 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 23 Aug 2013 15:32:19 +1000 Subject: [PATCH] Browser: refine 'c' and 'x' commands. 'x' will try to make text go away. 'c' will try to make text stay. 'X' will undo all such changes on the current line. Signed-off-by: NeilBrown --- vpatch.c | 43 +++++++------------------------------------ wiggle.1 | 39 ++++++++++++++++----------------------- 2 files changed, 23 insertions(+), 59 deletions(-) diff --git a/vpatch.c b/vpatch.c index 001bdf2..fb31947 100644 --- a/vpatch.c +++ b/vpatch.c @@ -1238,8 +1238,7 @@ static char *merge_window_help[] = { " x toggle ignoring of current Changed,", " Conflict, or Unmatched item", " c toggle accepting of result of conflict", - " X toggle ignored of all Change, Conflict", - " and Unmatched items in current line", + " X Revert 'c' and 'x' changes on this line", " v Save the current merge and run the", " default editor on the file.", NULL @@ -1344,7 +1343,6 @@ static int merge_window(struct plist *p, FILE *f, int reverse, int replace, int lineno; int changes = 0; /* If any edits have been made to the merge */ int answer; /* answer to 'save changes?' question */ - int do_mark; char *tempname; struct elmnt e; char search[80]; /* string we are searching for */ @@ -2260,9 +2258,10 @@ static int merge_window(struct plist *p, FILE *f, int reverse, int replace, break; case 'c': /* Toggle accepting of conflict. - * A 'Conflict' becomes 'Changed' + * A 'Conflict' or 'Extraneous' becomes 'Changed' */ - if (ci.merger[curs.pos.m].oldtype != Conflict) + if (ci.merger[curs.pos.m].oldtype != Conflict && + ci.merger[curs.pos.m].oldtype != Extraneous) break; if (ci.merger[curs.pos.m].type == Changed) @@ -2276,39 +2275,11 @@ static int merge_window(struct plist *p, FILE *f, int reverse, int replace, changes = 1; break; - case 'X': /* toggle where all Conflicts and Changeds - * in the current line are marked Unchanged. - * If any are not mark, mark them all, else - * un-mark them all. - */ - tpos = pos; - do_mark = 0; - do { - if ((ci.merger[tpos.p.m].oldtype == Conflict || - ci.merger[tpos.p.m].oldtype == Changed || - ci.merger[tpos.p.m].oldtype == Unmatched) - && (ci.merger[tpos.p.m].type == - ci.merger[tpos.p.m].oldtype)) - do_mark = 1; - e = prev_melmnt(&tpos.p, fm, fb, fa, ci.merger); - if (tpos.p.m < 0) - break; - } while (!ends_line(e) || - visible(mode & (RESULT|AFTER), ci.merger, &tpos) < 0); + case 'X': /* Reset all changes on the current line */ tpos = pos; do { - if (ci.merger[tpos.p.m].oldtype == Conflict || - ci.merger[tpos.p.m].oldtype == Changed || - ci.merger[tpos.p.m].oldtype == Unmatched) { - next = Unchanged; - if (ci.merger[tpos.p.m].oldtype == Unmatched) - next = Changed; - if (do_mark) - ci.merger[tpos.p.m].type = next; - else - ci.merger[tpos.p.m].type = - ci.merger[tpos.p.m].oldtype; - } + ci.merger[tpos.p.m].type = + ci.merger[tpos.p.m].oldtype; e = prev_melmnt(&tpos.p, fm, fb, fa, ci.merger); if (tpos.p.m < 0) break; diff --git a/wiggle.1 b/wiggle.1 index 2a382a7..ac700ba 100644 --- a/wiggle.1 +++ b/wiggle.1 @@ -534,30 +534,18 @@ experimentations should help. .P A limited amount of editing is permitted while in .B browse -mode. Currently any Conflict or Changed section can be converted to -Unchanged by using the -.B x -key (lower case), or all the Conflict and Changes sections in a line -can be converted to Unchanged. +mode. Currently text that is unwanted can be discarded with +.BR x . +This will convert a Conflict or Change to Unchanged, and an Unmatched +to Changed (which effectively changes it to the empty string). +Similarly a text can be marked as wanted with +.BR c . +This will convert a Conflict or Extraneous to Changed. Using the same +key again will revert the change. +.P +Finally, the uppercase .B X -(upper case). The effect can be toggled by pressing -.B x -or -.B X -again. -.P -A Conflict section can also be converted to Change (so the result is -accepted even though there wasn't a proper match) with the (lower -case) -.B c -key. Pressing -.B c -effects a toggle. -.P -If you make any changes, then wiggle will ask you if you want -to save the changes, even if -.B \-\-replace -was not given. +will revert all changes on the current line. .P To make more sweeping changes you can use .B v @@ -566,6 +554,11 @@ which runs an editor, preferring or .B $EDITOR if they are set in the environment. +.P +If you make any changes, then wiggle will ask you if you want +to save the changes, even if +.B \-\-replace +was not given. .SH WARNING Caution should always be exercised when applying a rejected patch with .IR wiggle . -- 2.39.5