26ab4f7012 2009-03-21 drh: # 26ab4f7012 2009-03-21 drh: # Copyright (c) 2009 D. Richard Hipp 26ab4f7012 2009-03-21 drh: # 26ab4f7012 2009-03-21 drh: # This program is free software; you can redistribute it and/or 26ab4f7012 2009-03-21 drh: # modify it under the terms of the GNU General Public 26ab4f7012 2009-03-21 drh: # License version 2 as published by the Free Software Foundation. 26ab4f7012 2009-03-21 drh: # 26ab4f7012 2009-03-21 drh: # This program is distributed in the hope that it will be useful, 26ab4f7012 2009-03-21 drh: # but WITHOUT ANY WARRANTY; without even the implied warranty of 26ab4f7012 2009-03-21 drh: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26ab4f7012 2009-03-21 drh: # General Public License for more details. 26ab4f7012 2009-03-21 drh: # 26ab4f7012 2009-03-21 drh: # You should have received a copy of the GNU General Public 26ab4f7012 2009-03-21 drh: # License along with this library; if not, write to the 26ab4f7012 2009-03-21 drh: # Free Software Foundation, Inc., 59 Temple Place - Suite 330, 26ab4f7012 2009-03-21 drh: # Boston, MA 02111-1307, USA. 26ab4f7012 2009-03-21 drh: # 26ab4f7012 2009-03-21 drh: # Author contact information: 26ab4f7012 2009-03-21 drh: # drh@hwaci.com 26ab4f7012 2009-03-21 drh: # http://www.hwaci.com/drh/ 26ab4f7012 2009-03-21 drh: # 26ab4f7012 2009-03-21 drh: ############################################################################ 26ab4f7012 2009-03-21 drh: # 26ab4f7012 2009-03-21 drh: # Tests of the 3-way merge 26ab4f7012 2009-03-21 drh: # 26ab4f7012 2009-03-21 drh: 26ab4f7012 2009-03-21 drh: proc merge-test {testid basis v1 v2 result} { 26ab4f7012 2009-03-21 drh: write_file t1 [join [string trim $basis] \n]\n 26ab4f7012 2009-03-21 drh: write_file t2 [join [string trim $v1] \n]\n 26ab4f7012 2009-03-21 drh: write_file t3 [join [string trim $v2] \n]\n 26ab4f7012 2009-03-21 drh: fossil test-3-way-merge t1 t2 t3 t4 26ab4f7012 2009-03-21 drh: set x [read_file t4] 26ab4f7012 2009-03-21 drh: regsub -all {>>>>>>> BEGIN MERGE CONFLICT} $x {>} x 26ab4f7012 2009-03-21 drh: regsub -all {============================} $x {=} x 26ab4f7012 2009-03-21 drh: regsub -all {<<<<<<< END MERGE CONFLICT} $x {<} x 26ab4f7012 2009-03-21 drh: set x [split [string trim $x] \n] 26ab4f7012 2009-03-21 drh: set result [string trim $result] 26ab4f7012 2009-03-21 drh: if {$x!=$result} { 26ab4f7012 2009-03-21 drh: puts " Expected \[$result\]" 26ab4f7012 2009-03-21 drh: puts " Got \[$x\]" 26ab4f7012 2009-03-21 drh: test merge3-$testid 0 26ab4f7012 2009-03-21 drh: } else { 26ab4f7012 2009-03-21 drh: test merge3-$testid 1 26ab4f7012 2009-03-21 drh: } 26ab4f7012 2009-03-21 drh: } 26ab4f7012 2009-03-21 drh: 26ab4f7012 2009-03-21 drh: merge-test 1 { 26ab4f7012 2009-03-21 drh: 1 2 3 4 5 6 7 8 9 26ab4f7012 2009-03-21 drh: } { 26ab4f7012 2009-03-21 drh: 1 2 3b 4 5 6 7 8 9 26ab4f7012 2009-03-21 drh: } { 26ab4f7012 2009-03-21 drh: 1 2 3 4 5c 6 7 8 9 26ab4f7012 2009-03-21 drh: } { 26ab4f7012 2009-03-21 drh: 1 2 3b 4 5c 6 7 8 9 26ab4f7012 2009-03-21 drh: } 26ab4f7012 2009-03-21 drh: 26ab4f7012 2009-03-21 drh: merge-test 2 { 26ab4f7012 2009-03-21 drh: 1 2 3 4 5 6 7 8 9 26ab4f7012 2009-03-21 drh: } { 26ab4f7012 2009-03-21 drh: 1 2 3b 4b 5 6 7 8 9 26ab4f7012 2009-03-21 drh: } { 26ab4f7012 2009-03-21 drh: 1 2 3 4 5c 6 7 8 9 26ab4f7012 2009-03-21 drh: } { 26ab4f7012 2009-03-21 drh: 1 2 3b 4b 5c 6 7 8 9 26ab4f7012 2009-03-21 drh: } 26ab4f7012 2009-03-21 drh: merge-test 3 { 26ab4f7012 2009-03-21 drh: 1 2 3 4 5 6 7 8 9 26ab4f7012 2009-03-21 drh: } { 26ab4f7012 2009-03-21 drh: 1 2 3b 4b 5b 6 7 8 9 26ab4f7012 2009-03-21 drh: } { 26ab4f7012 2009-03-21 drh: 1 2 3 4 5c 6 7 8 9 26ab4f7012 2009-03-21 drh: } { 26ab4f7012 2009-03-21 drh: 1 2 > 3b 4b 5b = 3 4 5c < 6 7 8 9 26ab4f7012 2009-03-21 drh: } 26ab4f7012 2009-03-21 drh: merge-test 4 { 26ab4f7012 2009-03-21 drh: 1 2 3 4 5 6 7 8 9 26ab4f7012 2009-03-21 drh: } { 26ab4f7012 2009-03-21 drh: 1 2 3b 4b 5b 6b 7 8 9 26ab4f7012 2009-03-21 drh: } { 26ab4f7012 2009-03-21 drh: 1 2 3 4 5c 6 7 8 9 26ab4f7012 2009-03-21 drh: } { 26ab4f7012 2009-03-21 drh: 1 2 > 3b 4b 5b 6b = 3 4 5c 6 < 7 8 9 26ab4f7012 2009-03-21 drh: } 26ab4f7012 2009-03-21 drh: merge-test 5 { 26ab4f7012 2009-03-21 drh: 1 2 3 4 5 6 7 8 9 26ab4f7012 2009-03-21 drh: } { 26ab4f7012 2009-03-21 drh: 1 2 3b 4b 5b 6b 7 8 9 26ab4f7012 2009-03-21 drh: } { 26ab4f7012 2009-03-21 drh: 1 2 3 4 5c 6c 7c 8 9 26ab4f7012 2009-03-21 drh: } { 26ab4f7012 2009-03-21 drh: 1 2 > 3b 4b 5b 6b 7 = 3 4 5c 6c 7c < 8 9 26ab4f7012 2009-03-21 drh: } 26ab4f7012 2009-03-21 drh: merge-test 6 { 26ab4f7012 2009-03-21 drh: 1 2 3 4 5 6 7 8 9 26ab4f7012 2009-03-21 drh: } { 26ab4f7012 2009-03-21 drh: 1 2 3b 4b 5b 6b 7 8b 9 26ab4f7012 2009-03-21 drh: } { 26ab4f7012 2009-03-21 drh: 1 2 3 4 5c 6c 7c 8 9 26ab4f7012 2009-03-21 drh: } { 26ab4f7012 2009-03-21 drh: 1 2 > 3b 4b 5b 6b 7 = 3 4 5c 6c 7c < 8b 9 26ab4f7012 2009-03-21 drh: } 26ab4f7012 2009-03-21 drh: merge-test 7 { 26ab4f7012 2009-03-21 drh: 1 2 3 4 5 6 7 8 9 26ab4f7012 2009-03-21 drh: } { 26ab4f7012 2009-03-21 drh: 1 2 3b 4b 5b 6b 7 8b 9 26ab4f7012 2009-03-21 drh: } { 26ab4f7012 2009-03-21 drh: 1 2 3 4 5c 6c 7c 8c 9 26ab4f7012 2009-03-21 drh: } { 26ab4f7012 2009-03-21 drh: 1 2 > 3b 4b 5b 6b 7 8b = 3 4 5c 6c 7c 8c < 9 26ab4f7012 2009-03-21 drh: } 26ab4f7012 2009-03-21 drh: merge-test 8 { 26ab4f7012 2009-03-21 drh: 1 2 3 4 5 6 7 8 9 26ab4f7012 2009-03-21 drh: } { 26ab4f7012 2009-03-21 drh: 1 2 3b 4b 5b 6b 7 8b 9b 26ab4f7012 2009-03-21 drh: } { 26ab4f7012 2009-03-21 drh: 1 2 3 4 5c 6c 7c 8c 9 26ab4f7012 2009-03-21 drh: } { 26ab4f7012 2009-03-21 drh: 1 2 > 3b 4b 5b 6b 7 8b 9b = 3 4 5c 6c 7c 8c 9 < 26ab4f7012 2009-03-21 drh: } 26ab4f7012 2009-03-21 drh: merge-test 9 { 26ab4f7012 2009-03-21 drh: 1 2 3 4 5 6 7 8 9 26ab4f7012 2009-03-21 drh: } { 26ab4f7012 2009-03-21 drh: 1 2 3b 4b 5 6 7 8b 9b 26ab4f7012 2009-03-21 drh: } { 26ab4f7012 2009-03-21 drh: 1 2 3 4 5c 6c 7c 8 9 26ab4f7012 2009-03-21 drh: } { 26ab4f7012 2009-03-21 drh: 1 2 3b 4b 5c 6c 7c 8b 9b 26ab4f7012 2009-03-21 drh: } 26ab4f7012 2009-03-21 drh: 26ab4f7012 2009-03-21 drh: merge-test 10 { 26ab4f7012 2009-03-21 drh: 1 2 3 4 5 6 7 8 9 26ab4f7012 2009-03-21 drh: } { 26ab4f7012 2009-03-21 drh: 1 2 3b 4b 5 6 7 8b 9b 26ab4f7012 2009-03-21 drh: } { 26ab4f7012 2009-03-21 drh: 1 2 3b 4b 5 6c 7c 8 9 26ab4f7012 2009-03-21 drh: } { 26ab4f7012 2009-03-21 drh: 1 2 3b 4b 5 6c 7c 8b 9b 26ab4f7012 2009-03-21 drh: } 26ab4f7012 2009-03-21 drh: merge-test 11 { 26ab4f7012 2009-03-21 drh: 1 2 3 4 5 6 7 8 9 26ab4f7012 2009-03-21 drh: } { 26ab4f7012 2009-03-21 drh: 1 2 3b 4b 5 6 7 8b 9b 26ab4f7012 2009-03-21 drh: } { 26ab4f7012 2009-03-21 drh: 1 2 3b 4c 5 6c 7c 8 9 26ab4f7012 2009-03-21 drh: } { 26ab4f7012 2009-03-21 drh: 1 2 > 3b 4b = 3b 4c < 5 6c 7c 8b 9b 26ab4f7012 2009-03-21 drh: } 26ab4f7012 2009-03-21 drh: merge-test 12 { 26ab4f7012 2009-03-21 drh: 1 2 3 4 5 6 7 8 9 26ab4f7012 2009-03-21 drh: } { 26ab4f7012 2009-03-21 drh: 1 2 3b4b 5 6 7 8b 9b 26ab4f7012 2009-03-21 drh: } { 26ab4f7012 2009-03-21 drh: 1 2 3b4b 5 6c 7c 8 9 26ab4f7012 2009-03-21 drh: } { 26ab4f7012 2009-03-21 drh: 1 2 3b4b 5 6c 7c 8b 9b 26ab4f7012 2009-03-21 drh: }