From: NeilBrown Date: Tue, 13 Nov 2012 05:56:04 +0000 (+1100) Subject: vpatch: allow conflict to be ignored with 'x' X-Git-Tag: v1.0~96 X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=2cd5975410cb704411bcad9588f0d8606ec12c2f;p=wiggle.git vpatch: allow conflict to be ignored with 'x' Patch still under development --- diff --git a/merge2.c b/merge2.c index 145ae24..14e3585 100644 --- a/merge2.c +++ b/merge2.c @@ -89,7 +89,7 @@ static int is_cutpoint(struct merge m, (m.c == 0 || ends_line(cf.list[m.c-1]))); } -static int isolate_conflicts(struct file af, struct file bf, struct file cf, +int isolate_conflicts(struct file af, struct file bf, struct file cf, struct csl *csl1, struct csl *csl2, int words, struct merge *m, int show_wiggles) { @@ -128,12 +128,15 @@ static int isolate_conflicts(struct file af, struct file bf, struct file cf, int changed = 0; int unmatched = 0; + for (i = 0; m[i].type != End; i++) + m[i].in_conflict = 0; + for (i = 0; m[i].type != End; i++) { if (m[i].type == Changed) changed = 1; if (m[i].type == Unmatched) unmatched = 1; - if (m[i].type == Conflict || + if ((m[i].type == Conflict && m[i].conflict_ignored == 0) || (show_wiggles && ((changed && unmatched) || m[i].type == Extraneous))) { /* We have a conflict (or wiggle) here. @@ -334,6 +337,7 @@ struct ci make_merger(struct file af, struct file bf, struct file cf, rv.merger[i].c1 = c1; rv.merger[i].c2 = c2; rv.merger[i].in_conflict = 0; + rv.merger[i].conflict_ignored = 0; if (!match1 && match2) { /* This is either Unmatched or Extraneous - probably both. @@ -460,6 +464,7 @@ struct ci make_merger(struct file af, struct file bf, struct file cf, rv.merger[i].c1 = c1; rv.merger[i].c2 = c2; rv.merger[i].in_conflict = 0; + rv.merger[i].conflict_ignored = 0; assert(i < l); rv.conflicts = isolate_conflicts(af, bf, cf, csl1, csl2, words, rv.merger, show_wiggles); diff --git a/vpatch.c b/vpatch.c index 272f363..99efb19 100644 --- a/vpatch.c +++ b/vpatch.c @@ -528,6 +528,8 @@ static int visible(int mode, struct merge *m, struct mpos *pos) return a_extra | A_UNDERLINE; break; case 2: + if ((mode & RESULT) && m[pos->p.m].conflict_ignored) + break; if (mode & (AFTER|RESULT)) return a_added | A_UNDERLINE; break; @@ -570,9 +572,13 @@ static int check_line(struct mpos pos, struct file fm, struct file fb, do { if (m[pos.p.m].type == Changed) rv |= CHANGES; - else if (m[pos.p.m].type == Conflict) - rv |= CONFLICTED | CHANGES; - else if (m[pos.p.m].type == AlreadyApplied) { + else if (m[pos.p.m].type == Conflict) { + if (m[pos.p.m].conflict_ignored && + (mode & RESULT)) + ; + else + rv |= CONFLICTED | CHANGES; + } else if (m[pos.p.m].type == AlreadyApplied) { rv |= CONFLICTED; if (mode & (BEFORE|AFTER)) rv |= CHANGES; @@ -1877,6 +1883,15 @@ static void merge_window(struct plist *p, FILE *f, int reverse) vpos = tvpos; break; + case 'x': /* Toggle rejecting of conflict */ + if (ci.merger[curs.pos.m].type == Conflict) { + ci.merger[curs.pos.m].conflict_ignored = + ! ci.merger[curs.pos.m].conflict_ignored; + isolate_conflicts(fm, fb, fa, csl1, csl2, 0, ci.merger, 0); + refresh = 1; + } + break; + case '?': help_window(modehelp, merge_window_help); refresh = 2; diff --git a/wiggle.h b/wiggle.h index 91b4110..b08887b 100644 --- a/wiggle.h +++ b/wiggle.h @@ -117,6 +117,7 @@ struct merge { int al, bl, cl; /* length of ranges */ int c1, c2; /* this or next common-sequence */ int in_conflict; + int conflict_ignored; int lo, hi; /* region of a Changed or Unchanged that is not involved * in a conflict. * These are distances from start of the "before" section, @@ -171,6 +172,9 @@ extern struct ci print_merge2(FILE *out, int words, int ignore_already, int show_wiggles); extern void printword(FILE *f, struct elmnt e); +extern int isolate_conflicts(struct file af, struct file bf, struct file cf, + struct csl *csl1, struct csl *csl2, int words, + struct merge *m, int show_wiggles); extern struct ci make_merger(struct file a, struct file b, struct file c, struct csl *c1, struct csl *c2, int words, int ignore_already, int show_wiggles);