Artifact 9b6f797f40414450c29bca52e89a328a586fef40:
File
test/merge2.test
part of check-in
[dbda8d6ce9]
- Initial check-in of m1 sources.
by
drh on
2007-07-21 14:10:57.
0000: 23 0a 23 20 43 6f 70 79 72 69 67 68 74 20 28 63 #.# Copyright (c
0010: 29 20 32 30 30 36 20 44 2e 20 52 69 63 68 61 72 ) 2006 D. Richar
0020: 64 20 48 69 70 70 0a 23 0a 23 20 54 68 69 73 20 d Hipp.#.# This
0030: 70 72 6f 67 72 61 6d 20 69 73 20 66 72 65 65 20 program is free
0040: 73 6f 66 74 77 61 72 65 3b 20 79 6f 75 20 63 61 software; you ca
0050: 6e 20 72 65 64 69 73 74 72 69 62 75 74 65 20 69 n redistribute i
0060: 74 20 61 6e 64 2f 6f 72 0a 23 20 6d 6f 64 69 66 t and/or.# modif
0070: 79 20 69 74 20 75 6e 64 65 72 20 74 68 65 20 74 y it under the t
0080: 65 72 6d 73 20 6f 66 20 74 68 65 20 47 4e 55 20 erms of the GNU
0090: 47 65 6e 65 72 61 6c 20 50 75 62 6c 69 63 0a 23 General Public.#
00a0: 20 4c 69 63 65 6e 73 65 20 76 65 72 73 69 6f 6e License version
00b0: 20 32 20 61 73 20 70 75 62 6c 69 73 68 65 64 20 2 as published
00c0: 62 79 20 74 68 65 20 46 72 65 65 20 53 6f 66 74 by the Free Soft
00d0: 77 61 72 65 20 46 6f 75 6e 64 61 74 69 6f 6e 2e ware Foundation.
00e0: 0a 23 0a 23 20 54 68 69 73 20 70 72 6f 67 72 61 .#.# This progra
00f0: 6d 20 69 73 20 64 69 73 74 72 69 62 75 74 65 64 m is distributed
0100: 20 69 6e 20 74 68 65 20 68 6f 70 65 20 74 68 61 in the hope tha
0110: 74 20 69 74 20 77 69 6c 6c 20 62 65 20 75 73 65 t it will be use
0120: 66 75 6c 2c 0a 23 20 62 75 74 20 57 49 54 48 4f ful,.# but WITHO
0130: 55 54 20 41 4e 59 20 57 41 52 52 41 4e 54 59 3b UT ANY WARRANTY;
0140: 20 77 69 74 68 6f 75 74 20 65 76 65 6e 20 74 68 without even th
0150: 65 20 69 6d 70 6c 69 65 64 20 77 61 72 72 61 6e e implied warran
0160: 74 79 20 6f 66 0a 23 20 4d 45 52 43 48 41 4e 54 ty of.# MERCHANT
0170: 41 42 49 4c 49 54 59 20 6f 72 20 46 49 54 4e 45 ABILITY or FITNE
0180: 53 53 20 46 4f 52 20 41 20 50 41 52 54 49 43 55 SS FOR A PARTICU
0190: 4c 41 52 20 50 55 52 50 4f 53 45 2e 20 20 53 65 LAR PURPOSE. Se
01a0: 65 20 74 68 65 20 47 4e 55 0a 23 20 47 65 6e 65 e the GNU.# Gene
01b0: 72 61 6c 20 50 75 62 6c 69 63 20 4c 69 63 65 6e ral Public Licen
01c0: 73 65 20 66 6f 72 20 6d 6f 72 65 20 64 65 74 61 se for more deta
01d0: 69 6c 73 2e 0a 23 20 0a 23 20 59 6f 75 20 73 68 ils..# .# You sh
01e0: 6f 75 6c 64 20 68 61 76 65 20 72 65 63 65 69 76 ould have receiv
01f0: 65 64 20 61 20 63 6f 70 79 20 6f 66 20 74 68 65 ed a copy of the
0200: 20 47 4e 55 20 47 65 6e 65 72 61 6c 20 50 75 62 GNU General Pub
0210: 6c 69 63 0a 23 20 4c 69 63 65 6e 73 65 20 61 6c lic.# License al
0220: 6f 6e 67 20 77 69 74 68 20 74 68 69 73 20 6c 69 ong with this li
0230: 62 72 61 72 79 3b 20 69 66 20 6e 6f 74 2c 20 77 brary; if not, w
0240: 72 69 74 65 20 74 6f 20 74 68 65 0a 23 20 46 72 rite to the.# Fr
0250: 65 65 20 53 6f 66 74 77 61 72 65 20 46 6f 75 6e ee Software Foun
0260: 64 61 74 69 6f 6e 2c 20 49 6e 63 2e 2c 20 35 39 dation, Inc., 59
0270: 20 54 65 6d 70 6c 65 20 50 6c 61 63 65 20 2d 20 Temple Place -
0280: 53 75 69 74 65 20 33 33 30 2c 0a 23 20 42 6f 73 Suite 330,.# Bos
0290: 74 6f 6e 2c 20 4d 41 20 20 30 32 31 31 31 2d 31 ton, MA 02111-1
02a0: 33 30 37 2c 20 55 53 41 2e 0a 23 0a 23 20 41 75 307, USA..#.# Au
02b0: 74 68 6f 72 20 63 6f 6e 74 61 63 74 20 69 6e 66 thor contact inf
02c0: 6f 72 6d 61 74 69 6f 6e 3a 0a 23 20 20 20 64 72 ormation:.# dr
02d0: 68 40 68 77 61 63 69 2e 63 6f 6d 0a 23 20 20 20 h@hwaci.com.#
02e0: 68 74 74 70 3a 2f 2f 77 77 77 2e 68 77 61 63 69 http://www.hwaci
02f0: 2e 63 6f 6d 2f 64 72 68 2f 0a 23 0a 23 23 23 23 .com/drh/.#.####
0300: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
0310: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
0320: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
0330: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
0340: 23 23 23 23 23 23 23 23 0a 23 0a 23 20 54 65 73 ########.#.# Tes
0350: 74 73 20 6f 66 20 74 68 65 20 64 65 6c 74 61 20 ts of the delta
0360: 6d 65 63 68 61 6e 69 73 6d 2e 0a 23 0a 0a 73 65 mechanism..#..se
0370: 74 20 66 69 6c 65 6c 69 73 74 20 5b 67 6c 6f 62 t filelist [glob
0380: 20 24 74 65 73 74 64 69 72 2f 2a 5d 0a 66 6f 72 $testdir/*].for
0390: 65 61 63 68 20 66 20 24 66 69 6c 65 6c 69 73 74 each f $filelist
03a0: 20 7b 0a 20 20 73 65 74 20 62 61 73 65 20 5b 66 {. set base [f
03b0: 69 6c 65 20 72 6f 6f 74 20 5b 66 69 6c 65 20 74 ile root [file t
03c0: 61 69 6c 20 24 66 5d 5d 0a 20 20 73 65 74 20 66 ail $f]]. set f
03d0: 31 20 5b 72 65 61 64 5f 66 69 6c 65 20 24 66 5d 1 [read_file $f]
03e0: 0a 20 20 77 72 69 74 65 5f 66 69 6c 65 20 74 31 . write_file t1
03f0: 20 24 66 31 0a 20 20 66 6f 72 20 7b 73 65 74 20 $f1. for {set
0400: 69 20 30 7d 20 7b 24 69 3c 31 30 30 7d 20 7b 69 i 0} {$i<100} {i
0410: 6e 63 72 20 69 7d 20 7b 0a 20 20 20 20 65 78 70 ncr i} {. exp
0420: 72 20 7b 73 72 61 6e 64 28 24 69 2a 32 29 7d 0a r {srand($i*2)}.
0430: 20 20 20 20 77 72 69 74 65 5f 66 69 6c 65 20 74 write_file t
0440: 32 20 5b 73 65 74 20 66 32 20 5b 72 61 6e 64 6f 2 [set f2 [rando
0450: 6d 5f 63 68 61 6e 67 65 73 20 24 66 31 20 32 20 m_changes $f1 2
0460: 34 20 30 20 30 2e 31 5d 5d 0a 20 20 20 20 65 78 4 0 0.1]]. ex
0470: 70 72 20 7b 73 72 61 6e 64 28 24 69 2a 32 2b 31 pr {srand($i*2+1
0480: 29 7d 0a 20 20 20 20 77 72 69 74 65 5f 66 69 6c )}. write_fil
0490: 65 20 74 33 20 5b 73 65 74 20 66 33 20 5b 72 61 e t3 [set f3 [ra
04a0: 6e 64 6f 6d 5f 63 68 61 6e 67 65 73 20 24 66 31 ndom_changes $f1
04b0: 20 32 20 34 20 32 20 30 2e 31 5d 5d 0a 20 20 20 2 4 2 0.1]].
04c0: 20 65 78 70 72 20 7b 73 72 61 6e 64 28 24 69 2a expr {srand($i*
04d0: 32 2b 31 29 7d 0a 20 20 20 20 77 72 69 74 65 5f 2+1)}. write_
04e0: 66 69 6c 65 20 74 32 33 20 5b 72 61 6e 64 6f 6d file t23 [random
04f0: 5f 63 68 61 6e 67 65 73 20 24 66 32 20 32 20 34 _changes $f2 2 4
0500: 20 32 20 30 2e 31 5d 0a 20 20 20 20 65 78 70 72 2 0.1]. expr
0510: 20 7b 73 72 61 6e 64 28 24 69 2a 32 29 7d 0a 20 {srand($i*2)}.
0520: 20 20 20 77 72 69 74 65 5f 66 69 6c 65 20 74 33 write_file t3
0530: 32 20 5b 72 61 6e 64 6f 6d 5f 63 68 61 6e 67 65 2 [random_change
0540: 73 20 24 66 33 20 32 20 34 20 30 20 30 2e 31 5d s $f3 2 4 0 0.1]
0550: 0a 20 20 20 20 66 6f 73 73 69 6c 20 74 65 73 74 . fossil test
0560: 2d 33 2d 77 61 79 2d 6d 65 72 67 65 20 74 31 20 -3-way-merge t1
0570: 74 32 20 74 33 20 61 32 33 0a 20 20 20 20 74 65 t2 t3 a23. te
0580: 73 74 20 6d 65 72 67 65 2d 24 62 61 73 65 2d 24 st merge-$base-$
0590: 69 2d 32 33 20 7b 5b 73 61 6d 65 5f 66 69 6c 65 i-23 {[same_file
05a0: 20 61 32 33 20 74 32 33 5d 7d 0a 20 20 20 20 66 a23 t23]}. f
05b0: 6f 73 73 69 6c 20 74 65 73 74 2d 33 2d 77 61 79 ossil test-3-way
05c0: 2d 6d 65 72 67 65 20 74 31 20 74 33 20 74 32 20 -merge t1 t3 t2
05d0: 61 33 32 0a 20 20 20 20 74 65 73 74 20 6d 65 72 a32. test mer
05e0: 67 65 2d 24 62 61 73 65 2d 24 69 2d 33 32 20 7b ge-$base-$i-32 {
05f0: 5b 73 61 6d 65 5f 66 69 6c 65 20 61 33 32 20 74 [same_file a32 t
0600: 33 32 5d 7d 0a 20 20 7d 0a 7d 0a 32]}. }.}.