]> git.neil.brown.name Git - wiggle.git/commitdiff
Encourage more context into conflict reports.
authorNeil Brown <neilb@suse.de>
Tue, 8 May 2012 08:54:11 +0000 (18:54 +1000)
committerNeil Brown <neilb@suse.de>
Tue, 8 May 2012 08:54:11 +0000 (18:54 +1000)
Conflict reports currently don't contain much surrounding
'Extraneous' text.  When the patch didn't really apply at all,
this context is very useful.
So encourage at least 3 lines of context from Extraneous or
Unchanged texts.
If it mostly comes from Unchanged text it isn't quite so useful,
so reduce the requirement.

Update self-tests to match.  In most cases these are an improvement.
In a couple of case we maybe get a bit more context than really
necessary, but that is better than not enough.

Signed-off-by: NeilBrown <neilb@suse.de>
13 files changed:
merge2.c
tests/linux/inode-justrej/lmerge
tests/linux/md-loop/merge
tests/linux/md-resync/merge
tests/linux/raid5build/merge
tests/linux/rpc_tcp_nonagle/merge
tests/simple/all-different/merge
tests/simple/conflict/merge
tests/simple/conflictmixed/lmerge
tests/simple/conflictmixed/merge
tests/simple/multiple-add/lmerge
tests/simple/multiple-add/merge
tests/simple/show-wiggle-1/Wmerge

index 2bbb709d1275fef3f959e6e1e1526aff69aeff25..20b0305547c37cf0b8ffcc68c3f0ac7dfe3f2ede 100644 (file)
--- a/merge2.c
+++ b/merge2.c
@@ -121,6 +121,13 @@ static int isolate_conflicts(struct file af, struct file bf, struct file cf,
         *
         * A hunk header is never considered part of a conflict.  It
         * thereby can serve as a separator between conflicts.
+        *
+        * We need to ensure there is adequate context for the conflict.
+        * So ensure there are at least 3 newlines in Extraneous or
+        * Unchanged on both sides of a Conflict - but don't go so far
+        * as including a hunk header.
+        * If there are 3, and they are all in 'Unchanged' sections, then
+        * that much context is not really needed - reduce it a bit.
         */
        int i, j, k;
        int cnt = 0;
@@ -143,6 +150,7 @@ static int isolate_conflicts(struct file af, struct file bf, struct file cf,
                         *
                         * Then search forward doing the same thing.
                         */
+                       int newlines = 0;
                        cnt++;
                        m[i].in_conflict = 1;
                        j = i;
@@ -161,8 +169,19 @@ static int isolate_conflicts(struct file af, struct file bf, struct file cf,
                                        cnt--;
                                        break;
                                }
+                               if (m[j].type == Extraneous) {
+                                       for (k = m[j].bl; k > 0; k--)
+                                               if (ends_line(bf.list[m[j].b+k-1]))
+                                                       newlines++;
+                               }
 
                                if (m[j].type == Unchanged || m[j].type == Changed) {
+                                       /* If we find enough newlines in this section,
+                                        * then we only really need 1, but would rather
+                                        * it wasn't the first one.  'firstk' allows us
+                                        * to track which newline we actually use
+                                        */
+                                       int firstk = m[j].al;
                                        if (words) {
                                                m[j].hi = m[j].al;
                                                break;
@@ -172,8 +191,15 @@ static int isolate_conflicts(struct file af, struct file bf, struct file cf,
                                         * is one, or might be at the start
                                         */
                                        for (k = m[j].al; k > 0; k--)
-                                               if (ends_line(af.list[m[j].a+k-1]))
-                                                       break;
+                                               if (ends_line(af.list[m[j].a+k-1])) {
+                                                       if (firstk == m[j].al)
+                                                               firstk = k;
+                                                       newlines++;
+                                                       if (newlines >= 3) {
+                                                               k = firstk;
+                                                               break;
+                                                       }
+                                               }
                                        if (k > 0)
                                                m[j].hi = k;
                                        else if (is_cutpoint(m[j], af,bf,cf))
@@ -195,12 +221,18 @@ static int isolate_conflicts(struct file af, struct file bf, struct file cf,
                        }
 
                        /* now the forward search */
+                       newlines = 0;
                        for (j = i+1; m[j].type != End; j++) {
                                if (m[j].type == Extraneous &&
                                    bf.list[m[j].b].start[0] == '\0')
                                        /* hunk header - not conflict any more */
                                        break;
                                m[j].in_conflict = 1;
+                               if (m[j].type == Extraneous) {
+                                       for (k = 0; k < m[j].bl; k++)
+                                               if (ends_line(bf.list[m[j].b+k]))
+                                                       newlines++;
+                               }
                                if (m[j].type == Unchanged || m[j].type == Changed) {
                                        m[j].hi = m[j].al;
                                        if (words) {
@@ -214,9 +246,22 @@ static int isolate_conflicts(struct file af, struct file bf, struct file cf,
                                        if (is_cutpoint(m[j], af,bf,cf))
                                                m[j].lo = 0;
                                        else {
+                                               /* If we find enough newlines in this section,
+                                                * then we only really need 1, but would rather
+                                                * it wasn't the first one.  'firstk' allows us
+                                                * to track which newline we actually use
+                                                */
+                                               int firstk = 0;
                                                for (k = 0 ; k < m[j].al ; k++)
-                                                       if (ends_line(af.list[m[j].a+k]))
-                                                               break;
+                                                       if (ends_line(af.list[m[j].a+k])) {
+                                                               if (firstk == 0)
+                                                                       firstk = k;
+                                                               newlines++;
+                                                               if (newlines >= 3) {
+                                                                       k = firstk;
+                                                                       break;
+                                                               }
+                                                       }
                                                if (k < m[j].al)
                                                        m[j].lo = k+1;
                                                else
index 685b14ece340be550cac53c1a266abe395e60b61..08b0a9b0c87d259aa6e4844b5717348affd24f51 100644 (file)
@@ -952,12 +952,14 @@ void remove_inode_hash(struct inode *inode)
 void generic_delete_inode(struct inode *inode)
 {
        struct super_operations *op = inode->i_sb->s_op;
-
 <<<<<<<
+
        hlist_del_init(&inode->i_hash);
 |||||||
+
        list_del_init(&inode->i_hash);
 =======
+
 >>>>>>>
        list_del_init(&inode->i_list);
        inode->i_state|=I_FREEING;
index 682ed2046846d114468171be185c0c41d239e36b..ebb59eafaaf0bfecdf9c070c44af56456dc2df00 100644 (file)
@@ -3950,11 +3950,13 @@ MD_EXPORT_SYMBOL(md_update_sb);
 MD_EXPORT_SYMBOL(md_wakeup_thread);
 MD_EXPORT_SYMBOL(md_print_devices);
 MD_EXPORT_SYMBOL(find_rdev_nr);
-MD_EXPORT_SYMBOL(md_interrupt_thread);
 <<<<<<<
+MD_EXPORT_SYMBOL(md_interrupt_thread);
 MD_EXPORT_SYMBOL(mddev_map);
 |||||||
+MD_EXPORT_SYMBOL(md_interrupt_thread);
 EXPORT_SYMBOL(mddev_map);
 =======
+MD_EXPORT_SYMBOL(md_interrupt_thread);
 >>>>>>>
 MODULE_LICENSE("GPL");
index 7960304fd9b8d79cbdbd4dbb667f8a2ea2aa91b4..09928a2e21b30b07f7effdccf841d5bb9701d712 100644 (file)
@@ -980,13 +980,13 @@ static int raid1_diskop(mddev_t *mddev, mdp_disk_t **d, int state)
 <<<<<<<
                if (conf->start_future > 0) {
                        MD_BUG();
+                       err = -EBUSY;
+                       break;
+               }
 |||||||
                close_sync(conf);
 =======
 >>>>>>>
-                       err = -EBUSY;
-                       break;
-               }
                sdisk = conf->mirrors + spare_disk;
                sdisk->operational = 0;
                sdisk->write_only = 0;
@@ -1002,13 +1002,13 @@ static int raid1_diskop(mddev_t *mddev, mdp_disk_t **d, int state)
 <<<<<<<
                if (conf->start_future > 0) {
                        MD_BUG();
+                       err = -EBUSY;
+                       break;
+               }
 |||||||
                close_sync(conf);
 =======
 >>>>>>>
-                       err = -EBUSY;
-                       break;
-               }
                sdisk = conf->mirrors + spare_disk;
                fdisk = conf->mirrors + failed_disk;
 
@@ -1306,12 +1306,14 @@ static int init_resync (conf_t *conf)
 *** 1144,16 **** 8
 <<<<<<<
        raid1_conf_t *conf = data;
+       mddev_t *mddev = conf->mddev;
 |||||||
        conf_t *conf = data;
+       mddev_t *mddev = conf->mddev;
 =======
        sector_t max_sector, nr_sectors;
->>>>>>>
        int disk, partial;
+>>>>>>>
 
        if (sector_nr == 0)
                if (init_resync(conf))
@@ -1497,19 +1499,6 @@ nomem:
        raid1_shrink_buffers(conf);
        return -ENOMEM;
 }
-|||||||
-       if (!sector_nr)
-               if (init_resync(conf))
-                       return -ENOMEM;
-       /*
-=======
-       if (sector_nr >= max_sector) {
-               close_sync(conf);
-               return 0;
-       }
-
-       /*
->>>>>>>
 
 static void end_sync_read(struct buffer_head *bh, int uptodate)
 {
@@ -1539,6 +1528,23 @@ static void end_sync_write(struct buffer_head *bh, int uptodate)
                raid1_free_buf(r1_bh);
                sync_request_done(sect, mddev_to_conf(mddev));
                md_done_sync(mddev,size>>9, uptodate);
+|||||||
+       if (!sector_nr)
+               if (init_resync(conf))
+                       return -ENOMEM;
+       /*
+        * If there is non-resync activity waiting for us then
+        * put in a delay to throttle resync.
+=======
+       if (sector_nr >= max_sector) {
+               close_sync(conf);
+               return 0;
+       }
+
+       /*
+        * If there is non-resync activity waiting for us then
+        * put in a delay to throttle resync.
+>>>>>>>
        }
 }
 
@@ -1761,11 +1767,13 @@ static int raid1_run (mddev_t *mddev)
        }
 
 <<<<<<<
+       if (!start_recovery && !(sb->state & (1 << MD_SB_CLEAN)) &&
            (conf->working_disks > 1)) {
                const char * name = "raid1syncd";
 
                conf->resync_thread = md_register_thread(raid1syncd, conf,name);
 |||||||
+       if (!start_recovery && !(sb->state & (1 << MD_SB_CLEAN)) &&
                                                (conf->working_disks > 1)) {
                const char * name = "raid1syncd";
 
index 77cfac86e0d8399da6705e230fd02ef6c56575af..0fe41cd7ab63fcb08f94950a9a50cf1b6db7bdf2 100644 (file)
@@ -10,11 +10,13 @@ static void raid5_build_block (struct stripe_head *sh, int i)
        dev->vec.bv_len = STRIPE_SIZE;
        dev->vec.bv_offset = 0;
 
-       dev->req.bi_bdev = conf->disks[i].bdev;
 <<<<<<<
+       bh->b_dev       = conf->disks[i].dev;
 |||||||
+       bh->b_dev       = conf->disks[i].dev;
        /* FIXME - later we will need bdev here */
 =======
+       dev->req.bi_bdev = conf->disks[i].bdev;
        dev->req.bi_sector = sh->sector;
 >>>>>>>
        dev->req.bi_private = sh;
@@ -25,10 +27,12 @@ static void raid5_build_block (struct stripe_head *sh, int i)
        bh->b_size      = sh->size;
        bh->b_list      = BUF_LOCKED;
        return bh;
+}
 |||||||
        bh->b_size      = sh->size;
        return bh;
+}
 =======
                dev->sector = compute_blocknr(sh, i);
->>>>>>>
 }
+>>>>>>>
index c66c37a681a3ad0cfb27cb5e90b0e5b0d9ca2ef6..2f9aa46bf0ffe814985c1e921fbd068e3b56e087 100644 (file)
@@ -1031,19 +1031,27 @@ svc_tcp_init(struct svc_sock *svsk)
                sk->write_space = svc_write_space;
 
                svsk->sk_reclen = 0;
+<<<<<<<
                svsk->sk_tcplen = 0;
 
-<<<<<<<
                /* initialise setting must have enough space to
+                * receive and respond to one request.  
+                * svc_tcp_recvfrom will re-adjust if necessary
 |||||||
+                svsk->sk_tcplen = 0;
+
                 /* initialise setting must have enough space to
+                 * receive and respond to one request.
+                 * svc_tcp_recvfrom will re-adjust if necessary
 =======
+                svsk->sk_tcplen = 0;
+
                tp->nonagle = 1;        /* disable Nagle's algorithm */
 
                 /* initialise setting must have enough space to
+                 * receive and respond to one request.
+                 * svc_tcp_recvfrom will re-adjust if necessary
 >>>>>>>
-                * receive and respond to one request.  
-                * svc_tcp_recvfrom will re-adjust if necessary
                 */
                svc_sock_setbufsize(svsk->sk_sock,
                                    3 * svsk->sk_server->sv_bufsz,
index ab83c87a4f9fd447b15f3b4e00b1a02d403b28e8..28ee4541ce25b39543f4a45ef6bad07de7926a0a 100644 (file)
@@ -9,6 +9,7 @@
 8
 9
 0
+yes
 |||||||
 a
 b
@@ -20,6 +21,7 @@ g
 h
 i
 j
+yes
 =======
 A
 B
@@ -31,5 +33,5 @@ G
 H
 I
 J
->>>>>>>
 yes
+>>>>>>>
index 4afaeff67cd1e19aa6c72d3e127128fd533baf5e..8bbd48730a40cb628035516b68a2023d1edf8724 100644 (file)
@@ -1,10 +1,16 @@
+<<<<<<<
 this is a file
 with the word
-<<<<<<<
 two which is
+misspelt
 |||||||
+this is a file
+with the word
 to which is
+misspelt
 =======
+this is a file
+with the word
 too which is
->>>>>>>
 misspelt
+>>>>>>>
index bb4d03c3f97508a6c868e5dd16fa833460faf831..6d7071ee5a44bbfbefd311586dba20f4d43e80b3 100644 (file)
@@ -1,10 +1,14 @@
+<<<<<<<
 this is a file
 with the word
-<<<<<<<
 two which is
 |||||||
+this is a file
+with the word
 to which is
 =======
+this is a file
+with the word
 too which was
 >>>>>>>
 misspelt
index bb4d03c3f97508a6c868e5dd16fa833460faf831..bb38d8a741514fc17ad8e7477a97a2f4aa5c6147 100644 (file)
@@ -1,10 +1,16 @@
+<<<<<<<
 this is a file
 with the word
-<<<<<<<
 two which is
+misspelt
 |||||||
+this is a file
+with the word
 to which is
+misspelt
 =======
+this is a file
+with the word
 too which was
->>>>>>>
 misspelt
+>>>>>>>
index f2a4151609b7bf486f936a84e93c7d22ea9de316..5827de2718b731779ec0ba20756fdd7c1aec55a5 100644 (file)
@@ -4,12 +4,14 @@ the
 current
 version
 of
-the
 <<<<<<<
+the
 file.
 |||||||
+the
 file
 =======
+the
 file that has changed
 >>>>>>>
 
index f2a4151609b7bf486f936a84e93c7d22ea9de316..312609f4dd4548afc9cb6ae2af9e02eeaffee3bf 100644 (file)
@@ -7,9 +7,11 @@ of
 the
 <<<<<<<
 file.
+
 |||||||
 file
+
 =======
 file that has changed
->>>>>>>
 
+>>>>>>>
index 2bb7d411a359a93788b1489f303c8ec07573482a..d5cba671af0de64a4bb4016bb0b11b76e489ab09 100644 (file)
@@ -1,14 +1,20 @@
-
 <<<<<<<
+
 This is one line of the file
+
 |||||||
+
 This is 1 line of the file
+
 =======
+
 This is 1 line of the document
+
 &&&&&&&
+
 This is one line of the document
->>>>>>>
 
+>>>>>>>
 I think this is another line
 
 So is this