Skip to content

Commit

Permalink
Get merge2 to pass all the tests...
Browse files Browse the repository at this point in the history
Some of this done by changing tests...

Signed-off-by: Neil Brown <[email protected]>
  • Loading branch information
neilbrown committed May 25, 2006
1 parent ae8ac6e commit 693fe6a
Show file tree
Hide file tree
Showing 12 changed files with 167 additions and 75 deletions.
112 changes: 85 additions & 27 deletions merge2.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ inline int isolate_conflicts(struct file af, struct file bf, struct file cf,
* Also, unless 'words', we need to include any partial lines
* in the Unchanged text that forms the border of a conflict.
*
* A Changed text may also border a conflict, but it can
* only border one conflict (where as an Unchanged can border
* a preceeding and a following conflict).
* The 'new' section of a Changed text appears in the
* conflict as does any part of the original before
* a newline.
*
*/
int i,j,k;
int cnt = 0;
Expand All @@ -115,7 +122,14 @@ inline int isolate_conflicts(struct file af, struct file bf, struct file cf,
if (!m[j].in_conflict) {
m[j].in_conflict = 1;
m[j].lo = 0;
} else if (m[j].type == Changed) {
/* This can no longer form a border */
m[j].lo = 0; m[j].hi = -1;
/* We merge these conflicts and stop searching */
cnt--;
break;
}

if (m[j].type == Unchanged || m[j].type == Changed) {
if (words) {
m[j].hi = m[j].al;
Expand All @@ -125,23 +139,40 @@ inline int isolate_conflicts(struct file af, struct file bf, struct file cf,
* might be after the last newline, if there
* is one, or might be at the start
*/
for (k=m[j].al; k>0; k--)
for (k=m[j].al; k>0; k--)
if (ends_line(af.list[m[j].a+k-1]))
break;
if (k>0) {
if (k > 0)
m[j].hi = k;
break;
}
if ((m[j].a == 0 || ends_line(af.list[m[j].a-1])) &&
(m[j].b == 0 || ends_line(bf.list[m[j].b-1])) &&
(m[j].c == 0 || ends_line(cf.list[m[j].c-1]))){
else if ((m[j].a == 0 || ends_line(af.list[m[j].a-1])) &&
(m[j].b == 0 || ends_line(bf.list[m[j].b-1])) &&
(m[j].c == 0 || ends_line(cf.list[m[j].c-1])))
m[j].hi = 0;
break;
else
/* no start-of-line found... */
m[j].hi = -1;
if (m[j].hi > 0 && m[j].type == Changed) {
/* this can only work if start is also a linke break */
if ((m[j].a == 0 || ends_line(af.list[m[j].a-1])) &&
(m[j].b == 0 || ends_line(bf.list[m[j].b-1])) &&
(m[j].c == 0 || ends_line(cf.list[m[j].c-1])))
/* ok */;
else
m[j].hi = -1;
}
/* no start-of-line found... */
m[j].hi = -1;
if (m[j].hi >= 0)
break;
}
}
#if 0
if (j>=0 && m[j].in_conflict && m[j].type == Unchanged &&
m[j].hi == m[j].lo) {
/* nothing to separate conflicts, merge them */
m[j].lo = 0;
m[j].hi = -1;
cnt--;
}
#endif
/* now the forward search */
for (j=i+1; m[j].type != End; j++) {
m[j].in_conflict = 1;
Expand All @@ -157,19 +188,29 @@ inline int isolate_conflicts(struct file af, struct file bf, struct file cf,
*/
if ((m[j].a == 0 || ends_line(af.list[m[j].a-1])) &&
(m[j].b == 0 || ends_line(bf.list[m[j].b-1])) &&
(m[j].c == 0 || ends_line(cf.list[m[j].c-1]))){
(m[j].c == 0 || ends_line(cf.list[m[j].c-1])))
m[j].lo = 0;
break;
else {
for (k = 0 ; k < m[j].al ; k++)
if (ends_line(af.list[m[j].a+k]))
break;
if (k<m[j].al)
m[j].lo = k+1;
else
/* no start-of-line found */
m[j].lo = m[j].al+1;
}
for (k=0; k<m[j].al; k++)
if (ends_line(af.list[m[j].a+k]))
break;
if (k<m[j].al) {
m[j].lo = k+1;
break;
if (m[j].lo <= m[j].al+1 && m[j].type == Changed) {
/* this can only work if the end is a line break */
if (ends_line(af.list[m[j].a+m[j].al-1]) &&
ends_line(bf.list[m[j].b+m[j].bl-1]) &&
ends_line(cf.list[m[j].c+m[j].cl-1]))
/* ok */;
else
m[j].lo = m[j].al+1;
}
/* no start-of-line found */
m[j].lo = m[j].al+1;
if (m[j].lo < m[j].al+1)
break;
}
}
i = j;
Expand Down Expand Up @@ -346,11 +387,11 @@ struct ci print_merge2(FILE *out, struct file *a, struct file *b, struct file *c
* Unchanged which is < it's hi
*/
int st = m->hi;
if (m->hi <= m->lo)
st = 0;

if (m->type == Unchanged)
printrange(out, a, m->a+m->lo, m->hi - m->lo);
else
printrange(out, c, m->c, m->cl);

#if 1
if (v)
Expand All @@ -366,7 +407,7 @@ struct ci print_merge2(FILE *out, struct file *a, struct file *b, struct file *c
cm->b, cm->b+cm->bl-1,
cm->c, cm->c+cm->cl-1, cm->in_conflict?" in_conflict":"",
cm->lo, cm->hi);
if (cm->type == Unchanged && cm != m && cm->lo < cm->hi)
if ((cm->type == Unchanged ||cm->type == Changed) && cm != m && cm->lo < cm->hi)
break;
}
#endif
Expand All @@ -393,17 +434,19 @@ struct ci print_merge2(FILE *out, struct file *a, struct file *b, struct file *c
fputs(words?"===":"=======\n", out);
st = m->hi;
for (cm=m; cm->in_conflict; cm++) {
if ((cm->type == Unchanged || cm->type == Changed) && cm != m && cm->lo < cm->hi) {
if (cm->type == Unchanged)
printrange(out, c, cm->c, cm->lo);
if (cm->type == Unchanged && cm != m && cm->lo < cm->hi) {
printrange(out, c, cm->c, cm->lo);
break;
}
if (cm->type == Changed)
st = 0; /* All of result of change must be printed */
printrange(out, c, cm->c+st, cm->cl-st);
st = 0;
}
fputs(words?"--->>>":">>>>>>>\n", out);
m = cm;
if (m->type == Unchanged && m->in_conflict && m->hi >= m->al) {
if (m->in_conflict && m->hi >= m->al) {
assert(m->type == Unchanged);
printrange(out, a, m->a+m->lo, m->hi-m->lo);
m++;
}
Expand All @@ -414,6 +457,21 @@ struct ci print_merge2(FILE *out, struct file *a, struct file *b, struct file *c
*/
if (m->type == End)
break;
#if 1
if (v) {
printf("<<%s: %d-%d,%d-%d,%d-%d%s(%d,%d)>>\n",
m->type==Unmatched?"Unmatched":
m->type==Unchanged?"Unchanged":
m->type==Extraneous?"Extraneous":
m->type==Changed?"Changed":
m->type==AlreadyApplied?"AlreadyApplied":
m->type==Conflict?"Conflict":"unknown",
m->a, m->a+m->al-1,
m->b, m->b+m->bl-1,
m->c, m->c+m->cl-1, m->in_conflict?" in_conflict":"",
m->lo, m->hi);
}
#endif
switch(m->type) {
case Unchanged:
case AlreadyApplied:
Expand Down
18 changes: 18 additions & 0 deletions tests/linux/idmap.h/merge
Original file line number Diff line number Diff line change
@@ -1,2 +1,20 @@
<<<<<<<
|||||||
*** 55,6 **** 1
#define IDMAP_STATUS_LOOKUPFAIL IDMAP_STATUS_FAIL


/* XXX get (include) from bits/utmp.h */
#define IDMAP_NAMESZ 128

=======
*** 55,8 **** 1
#define IDMAP_STATUS_LOOKUPFAIL IDMAP_STATUS_FAIL


#define IDMAP_MAXMSGSZ 256

/* XXX get (include) from bits/utmp.h */
#define IDMAP_NAMESZ 128

>>>>>>>
57 changes: 26 additions & 31 deletions tests/linux/md-resync/merge
Original file line number Diff line number Diff line change
Expand Up @@ -1148,7 +1148,11 @@ abort:
mempool_destroy(conf->r1buf_pool);
conf->r1buf_pool = NULL;
}

print_conf(conf);
=======

print_conf(conf);
>>>>>>>
return err;
}
Expand Down Expand Up @@ -1314,6 +1318,10 @@ static int init_resync (conf_t *conf)
return -ENOMEM;

<<<<<<<
close_sync(conf);

}

/*
* perform a "sync" on one "block"
*
Expand Down Expand Up @@ -1472,6 +1480,10 @@ static int raid1_sync_request (mddev_t *mddev, unsigned long sector_nr)

return (bsize >> 9);
|||||||
close_sync(conf);

}

static int init_resync(conf_t *conf)
{
*** 1170,9 **** 8
Expand All @@ -1485,6 +1497,19 @@ 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)
{
Expand Down Expand Up @@ -1513,37 +1538,7 @@ static void end_sync_write(struct buffer_head *bh, int uptodate)
int size = bh->b_size;
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.
*** 1209,10 **** 9
r1_bio->sector = sector_nr;
r1_bio->cmd = SPECIAL;

max_sector = mddev->sb->size << 1;
if (sector_nr >= max_sector)
BUG();

=======
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.
*** 1190,6 **** 9
r1_bio->sector = sector_nr;
r1_bio->cmd = SPECIAL;

>>>>>>>
}
md_done_sync(mddev,size>>9, uptodate }
}

#define INVALID_LEVEL KERN_WARNING \
Expand Down
6 changes: 0 additions & 6 deletions tests/linux/md/lmerge
Original file line number Diff line number Diff line change
Expand Up @@ -1436,12 +1436,6 @@ abort:
return 1;
}

<<<<<<<
|||||||
#undef OLD_LEVEL

=======
>>>>>>>
static struct gendisk *md_probe(dev_t dev, int *part, void *data)
{
static DECLARE_MUTEX(disks_sem);
Expand Down
6 changes: 0 additions & 6 deletions tests/linux/md/merge
Original file line number Diff line number Diff line change
Expand Up @@ -1436,12 +1436,6 @@ abort:
return 1;
}

<<<<<<<
|||||||
#undef OLD_LEVEL

=======
>>>>>>>
static struct gendisk *md_probe(dev_t dev, int *part, void *data)
{
static DECLARE_MUTEX(disks_sem);
Expand Down
4 changes: 1 addition & 3 deletions tests/linux/md/wmerge
Original file line number Diff line number Diff line change
Expand Up @@ -1436,9 +1436,7 @@ abort:
return 1;
}

<<<---|||#undef OLD_LEVEL

===--->>>static struct gendisk *md_probe(dev_t dev, int *part, void *data)
static struct gendisk *md_probe(dev_t dev, int *part, void *data)
{
static DECLARE_MUTEX(disks_sem);
int unit = MINOR(dev);
Expand Down
4 changes: 4 additions & 0 deletions tests/linux/raid5build/merge
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@ static void raid5_build_block (struct stripe_head *sh, int i)
dev->flags = 0;
if (i != sh->pd_idx)
<<<<<<<
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);
>>>>>>>
Expand Down
2 changes: 2 additions & 0 deletions tests/linux/raid5line/lmerge
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<<<<<<<
clear_bit(BH_Uptodate, &sh->bh_cache[i]->b_state);
|||||||
*** 1,1 **** 1
clear_buffer_uptodate(sh->bh_cache[i]);
=======
*** 1,1 **** 1
dev->flags = 0;
>>>>>>>
2 changes: 2 additions & 0 deletions tests/linux/raid5line/merge
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<<<<<<<
clear_bit(BH_Uptodate, &sh->bh_cache[i]->b_state);
|||||||
*** 1,1 **** 1
clear_buffer_uptodate(sh->bh_cache[i]);
=======
*** 1,1 **** 1
dev->flags = 0;
>>>>>>>
4 changes: 3 additions & 1 deletion tests/linux/raid5line/wmerge
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
<<<--- clear_bit(BH_Uptodate, &|||clear_buffer_uptodate(===dev--->>>-><<<---->b_state|||===flags = 0--->>>;
<<<--- clear_bit(BH_Uptodate, &|||*** 1,1 **** 1
clear_buffer_uptodate(===*** 1,1 **** 1
dev--->>>-><<<---->b_state|||===flags = 0--->>>;
2 changes: 2 additions & 0 deletions tests/linux/rpc_tcp_nonagle/merge
Original file line number Diff line number Diff line change
Expand Up @@ -1036,9 +1036,11 @@ svc_tcp_init(struct svc_sock *svsk)
<<<<<<<
/* initialise setting must have enough space to
|||||||
/* initialise setting must have enough space to
=======
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
Expand Down
Loading

0 comments on commit 693fe6a

Please sign in to comment.