]> git.neil.brown.name Git - wiggle.git/commitdiff
vpatch: allow conflict to be ignored with 'x'
authorNeilBrown <neilb@suse.de>
Tue, 13 Nov 2012 05:56:04 +0000 (16:56 +1100)
committerNeilBrown <neilb@suse.de>
Tue, 13 Nov 2012 05:56:04 +0000 (16:56 +1100)
Patch still under development

merge2.c
vpatch.c
wiggle.h

index 145ae24dee8720f4e8e72acdfc717b6db0a8d5fa..14e35856d30cfaaa1d023cc6fb7ac80fca10de33 100644 (file)
--- 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);
index 272f36305dbbad2cc4a61b811d49a1e354aba3d8..99efb1983b9c767015c2e29472187087c4288fb7 100644 (file)
--- 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;
index 91b4110d3835ca1f0a80ab241e798cc8c014e502..b08887ba69115197edd400d763ff6579f6068e1b 100644 (file)
--- 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);