Overview
SHA1 Hash: | 81122988ba271d135ce26071eb584f0d8bbe1caf |
---|---|
Date: | 2009-03-21 19:18:22 |
User: | drh |
Comment: | More improvements to the 3-way merge. Additional test cases added. |
Timelines: | ancestors | descendants | both | trunk |
Other Links: | files | ZIP archive | manifest |
Tags And Properties
- branch=trunk inherited from [a28c83647d]
- sym-trunk inherited from [a28c83647d]
Changes
[hide diffs]Modified src/merge3.c from [bd94cf9eaa] to [137ba3bf55].
@@ -110,11 +110,11 @@ int i, /* Index in aC[] of current location in pSrc */ int sz /* Number of lines in unedited source to output */ ){ while( sz>0 ){ if( aC[i]==0 && aC[i+1]==0 && aC[i+2]==0 ) break; - if( aC[i]>sz ){ + if( aC[i]>=sz ){ blob_copy_lines(pOut, pSrc, sz); aC[i] -= sz; break; } blob_copy_lines(pOut, pSrc, aC[i]); @@ -192,21 +192,21 @@ blob_copy_lines(0, pV1, nCpy); blob_copy_lines(0, pV2, nCpy); aC1[i1] -= nCpy; aC2[i2] -= nCpy; }else - if( aC1[i1] >= aC2[i2+1] && aC2[i2+1]+aC2[i2+2]>0 ){ + if( aC1[i1] >= aC2[i2+1] && aC1[i1]>0 && aC2[i2+1]+aC2[i2+2]>0 ){ nDel = aC2[i2+1]; nIns = aC2[i2+2]; DEBUG( printf("EDIT -%d+%d left\n", nDel, nIns); ) blob_copy_lines(0, pPivot, nDel); blob_copy_lines(0, pV1, nDel); blob_copy_lines(pOut, pV2, nIns); aC1[i1] -= nDel; i2 += 3; }else - if( aC2[i2] >= aC1[i1+1] && aC1[i1+1]+aC1[i1+2]>0 ){ + if( aC2[i2] >= aC1[i1+1] && aC2[i2]>0 && aC1[i1+1]+aC1[i1+2]>0 ){ nDel = aC1[i1+1]; nIns = aC1[i1+2]; DEBUG( printf("EDIT -%d+%d right\n", nDel, nIns); ) blob_copy_lines(0, pPivot, nDel); blob_copy_lines(0, pV2, nDel);
Modified test/delta1.test from [08d7071c42] to [b0dba644d2].
@@ -32,10 +32,11 @@ # work properly. # set filelist [glob $testdir/*] foreach f $filelist { set base [file root [file tail $f]] +puts "base=$base f=$f" set f1 [read_file $f] write_file t1 $f1 for {set i 0} {$i<100} {incr i} { write_file t2 [random_changes $f1 1 1 0 0.1] fossil test-delta t1 t2
Modified test/merge1.test from [eed9903dc2] to [310813fc4c].
@@ -19,11 +19,11 @@ # drh@hwaci.com # http://www.hwaci.com/drh/ # ############################################################################ # -# Tests of the delta mechanism. +# Tests of the 3-way merge # write_file_indented t1 { 111 - This is line one of the demo program - 1111 222 - The second line program line in code - 2222 @@ -77,24 +77,26 @@ 333 - This is a test of the merging algohm - 3333 444 - If all goes well, we will be pleased - 4444 555 - we think it well and other stuff too - 5555 } write_file_indented t23 { - >>>>>>>> BEGIN MERGE CONFLICT <<<<<<<< + >>>>>>> BEGIN MERGE CONFLICT 111 - This is line ONE of the demo program - 1111 + ============================ 111 - This is line one OF the demo program - 1111 - >>>>>>>>> END MERGE CONFLICT <<<<<<<<< + <<<<<<< END MERGE CONFLICT 222 - The second line program line in code - 2222 333 - This is a test of the merging algohm - 3333 444 - If all goes well, we will be pleased - 4444 555 - we think it well and other stuff too - 5555 } write_file_indented t32 { - >>>>>>>> BEGIN MERGE CONFLICT <<<<<<<< + >>>>>>> BEGIN MERGE CONFLICT 111 - This is line one OF the demo program - 1111 + ============================ 111 - This is line ONE of the demo program - 1111 - >>>>>>>>> END MERGE CONFLICT <<<<<<<<< + <<<<<<< END MERGE CONFLICT 222 - The second line program line in code - 2222 333 - This is a test of the merging algohm - 3333 444 - If all goes well, we will be pleased - 4444 555 - we think it well and other stuff too - 5555 } @@ -156,18 +158,26 @@ 333 - This is a test of the merging algohm - 3333 444 - If all goes well, we will be pleased - 4444 555 - we think it well and other stuff too - 5555 } write_file_indented t32 { + >>>>>>> BEGIN MERGE CONFLICT + ============================ 000 - Zero lines added to the beginning of - 0000 + 111 - This is line one of the demo program - 1111 + <<<<<<< END MERGE CONFLICT 222 - The second line program line in code - 2222 333 - This is a test of the merging algohm - 3333 444 - If all goes well, we will be pleased - 4444 555 - we think it well and other stuff too - 5555 } write_file_indented t23 { + >>>>>>> BEGIN MERGE CONFLICT 000 - Zero lines added to the beginning of - 0000 + 111 - This is line one of the demo program - 1111 + ============================ + <<<<<<< END MERGE CONFLICT 222 - The second line program line in code - 2222 333 - This is a test of the merging algohm - 3333 444 - If all goes well, we will be pleased - 4444 555 - we think it well and other stuff too - 5555 } @@ -235,5 +245,136 @@ } fossil test-3 t1 t3 t2 a32 test merge1-6.1 {[same_file t32 a32]} fossil test-3 t1 t2 t3 a23 test merge1-6.2 {[same_file t32 a23]} + +write_file_indented t1 { + abcd + efgh + ijkl + mnop + qrst + uvwx + yzAB + CDEF + GHIJ + KLMN + OPQR + STUV + XYZ. +} +write_file_indented t2 { + abcd + efgh 2 + ijkl 2 + mnop 2 + qrst + uvwx + yzAB 2 + CDEF 2 + GHIJ 2 + KLMN + OPQR + STUV + XYZ. +} +write_file_indented t3 { + abcd + efgh + ijkl + mnop 3 + qrst 3 + uvwx 3 + yzAB 3 + CDEF + GHIJ + KLMN + OPQR + STUV + XYZ. +} +write_file_indented t23 { + abcd + >>>>>>> BEGIN MERGE CONFLICT + efgh 2 + ijkl 2 + mnop 2 + qrst + uvwx + yzAB 2 + CDEF 2 + GHIJ 2 + ============================ + efgh + ijkl + mnop 3 + qrst 3 + uvwx 3 + yzAB 3 + CDEF + GHIJ + <<<<<<< END MERGE CONFLICT + KLMN + OPQR + STUV + XYZ. +} +fossil test-3 t1 t2 t3 a23 +test merge1-7.1 {[same_file t23 a23]} + +write_file_indented t2 { + abcd + efgh 2 + ijkl 2 + mnop + qrst + uvwx + yzAB 2 + CDEF 2 + GHIJ 2 + KLMN + OPQR + STUV + XYZ. +} +write_file_indented t3 { + abcd + efgh + ijkl + mnop 3 + qrst 3 + uvwx 3 + yzAB 3 + CDEF + GHIJ + KLMN + OPQR + STUV + XYZ. +} +write_file_indented t23 { + abcd + efgh 2 + ijkl 2 + >>>>>>> BEGIN MERGE CONFLICT + mnop + qrst + uvwx + yzAB 2 + CDEF 2 + GHIJ 2 + ============================ + mnop 3 + qrst 3 + uvwx 3 + yzAB 3 + CDEF + GHIJ + <<<<<<< END MERGE CONFLICT + KLMN + OPQR + STUV + XYZ. +} +fossil test-3 t1 t2 t3 a23 +test merge1-7.2 {[same_file t23 a23]}