Hex Artifact Content
Not logged in

Artifact 60194e41fa120b44f2a561b890f55ddba18aebe6:


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 53 69 6d 70  erms of the Simp
0090: 6c 69 66 69 65 64 20 42 53 44 20 4c 69 63 65 6e  lified BSD Licen
00a0: 73 65 20 28 61 6c 73 6f 0a 23 20 6b 6e 6f 77 6e  se (also.# known
00b0: 20 61 73 20 74 68 65 20 22 32 2d 43 6c 61 75 73   as the "2-Claus
00c0: 65 20 4c 69 63 65 6e 73 65 22 20 6f 72 20 22 46  e License" or "F
00d0: 72 65 65 42 53 44 20 4c 69 63 65 6e 73 65 22 2e  reeBSD License".
00e0: 29 0a 23 0a 23 20 54 68 69 73 20 70 72 6f 67 72  ).#.# This progr
00f0: 61 6d 20 69 73 20 64 69 73 74 72 69 62 75 74 65  am is distribute
0100: 64 20 69 6e 20 74 68 65 20 68 6f 70 65 20 74 68  d in the hope th
0110: 61 74 20 69 74 20 77 69 6c 6c 20 62 65 20 75 73  at it will be us
0120: 65 66 75 6c 2c 0a 23 20 62 75 74 20 77 69 74 68  eful,.# but with
0130: 6f 75 74 20 61 6e 79 20 77 61 72 72 61 6e 74 79  out any warranty
0140: 3b 20 77 69 74 68 6f 75 74 20 65 76 65 6e 20 74  ; without even t
0150: 68 65 20 69 6d 70 6c 69 65 64 20 77 61 72 72 61  he implied warra
0160: 6e 74 79 20 6f 66 0a 23 20 6d 65 72 63 68 61 6e  nty of.# merchan
0170: 74 61 62 69 6c 69 74 79 20 6f 72 20 66 69 74 6e  tability or fitn
0180: 65 73 73 20 66 6f 72 20 61 20 70 61 72 74 69 63  ess for a partic
0190: 75 6c 61 72 20 70 75 72 70 6f 73 65 2e 0a 23 0a  ular purpose..#.
01a0: 23 20 41 75 74 68 6f 72 20 63 6f 6e 74 61 63 74  # Author contact
01b0: 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 3a 0a 23 20   information:.# 
01c0: 20 20 64 72 68 40 68 77 61 63 69 2e 63 6f 6d 0a    drh@hwaci.com.
01d0: 23 20 20 20 68 74 74 70 3a 2f 2f 77 77 77 2e 68  #   http://www.h
01e0: 77 61 63 69 2e 63 6f 6d 2f 64 72 68 2f 0a 23 0a  waci.com/drh/.#.
01f0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
0200: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
0210: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
0220: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
0230: 23 23 23 23 23 23 23 23 23 23 23 23 0a 23 0a 23  ############.#.#
0240: 20 54 65 73 74 73 20 6f 66 20 74 68 65 20 64 65   Tests of the de
0250: 6c 74 61 20 6d 65 63 68 61 6e 69 73 6d 2e 0a 23  lta mechanism..#
0260: 0a 0a 73 65 74 20 66 69 6c 65 6c 69 73 74 20 5b  ..set filelist [
0270: 67 6c 6f 62 20 24 74 65 73 74 64 69 72 2f 2a 5d  glob $testdir/*]
0280: 0a 66 6f 72 65 61 63 68 20 66 20 24 66 69 6c 65  .foreach f $file
0290: 6c 69 73 74 20 7b 0a 20 20 69 66 20 7b 5b 66 69  list {.  if {[fi
02a0: 6c 65 20 69 73 64 69 72 20 24 66 5d 7d 20 63 6f  le isdir $f]} co
02b0: 6e 74 69 6e 75 65 0a 20 20 73 65 74 20 62 61 73  ntinue.  set bas
02c0: 65 20 5b 66 69 6c 65 20 72 6f 6f 74 20 5b 66 69  e [file root [fi
02d0: 6c 65 20 74 61 69 6c 20 24 66 5d 5d 0a 20 20 73  le tail $f]].  s
02e0: 65 74 20 66 31 20 5b 72 65 61 64 5f 66 69 6c 65  et f1 [read_file
02f0: 20 24 66 5d 0a 20 20 77 72 69 74 65 5f 66 69 6c   $f].  write_fil
0300: 65 20 74 31 20 24 66 31 0a 20 20 66 6f 72 20 7b  e t1 $f1.  for {
0310: 73 65 74 20 69 20 30 7d 20 7b 24 69 3c 31 30 30  set i 0} {$i<100
0320: 7d 20 7b 69 6e 63 72 20 69 7d 20 7b 0a 20 20 20  } {incr i} {.   
0330: 20 65 78 70 72 20 7b 73 72 61 6e 64 28 24 69 2a   expr {srand($i*
0340: 32 29 7d 0a 20 20 20 20 77 72 69 74 65 5f 66 69  2)}.    write_fi
0350: 6c 65 20 74 32 20 5b 73 65 74 20 66 32 20 5b 72  le t2 [set f2 [r
0360: 61 6e 64 6f 6d 5f 63 68 61 6e 67 65 73 20 24 66  andom_changes $f
0370: 31 20 32 20 34 20 30 20 30 2e 31 5d 5d 0a 20 20  1 2 4 0 0.1]].  
0380: 20 20 65 78 70 72 20 7b 73 72 61 6e 64 28 24 69    expr {srand($i
0390: 2a 32 2b 31 29 7d 0a 20 20 20 20 77 72 69 74 65  *2+1)}.    write
03a0: 5f 66 69 6c 65 20 74 33 20 5b 73 65 74 20 66 33  _file t3 [set f3
03b0: 20 5b 72 61 6e 64 6f 6d 5f 63 68 61 6e 67 65 73   [random_changes
03c0: 20 24 66 31 20 32 20 34 20 32 20 30 2e 31 5d 5d   $f1 2 4 2 0.1]]
03d0: 0a 20 20 20 20 65 78 70 72 20 7b 73 72 61 6e 64  .    expr {srand
03e0: 28 24 69 2a 32 2b 31 29 7d 0a 20 20 20 20 77 72  ($i*2+1)}.    wr
03f0: 69 74 65 5f 66 69 6c 65 20 74 32 33 20 5b 72 61  ite_file t23 [ra
0400: 6e 64 6f 6d 5f 63 68 61 6e 67 65 73 20 24 66 32  ndom_changes $f2
0410: 20 32 20 34 20 32 20 30 2e 31 5d 0a 20 20 20 20   2 4 2 0.1].    
0420: 65 78 70 72 20 7b 73 72 61 6e 64 28 24 69 2a 32  expr {srand($i*2
0430: 29 7d 0a 20 20 20 20 77 72 69 74 65 5f 66 69 6c  )}.    write_fil
0440: 65 20 74 33 32 20 5b 72 61 6e 64 6f 6d 5f 63 68  e t32 [random_ch
0450: 61 6e 67 65 73 20 24 66 33 20 32 20 34 20 30 20  anges $f3 2 4 0 
0460: 30 2e 31 5d 0a 20 20 20 20 66 6f 73 73 69 6c 20  0.1].    fossil 
0470: 74 65 73 74 2d 33 2d 77 61 79 2d 6d 65 72 67 65  test-3-way-merge
0480: 20 74 31 20 74 32 20 74 33 20 61 32 33 0a 20 20   t1 t2 t3 a23.  
0490: 20 20 74 65 73 74 20 6d 65 72 67 65 2d 24 62 61    test merge-$ba
04a0: 73 65 2d 24 69 2d 32 33 20 7b 5b 73 61 6d 65 5f  se-$i-23 {[same_
04b0: 66 69 6c 65 20 61 32 33 20 74 32 33 5d 7d 0a 20  file a23 t23]}. 
04c0: 20 20 20 66 6f 73 73 69 6c 20 74 65 73 74 2d 33     fossil test-3
04d0: 2d 77 61 79 2d 6d 65 72 67 65 20 74 31 20 74 33  -way-merge t1 t3
04e0: 20 74 32 20 61 33 32 0a 20 20 20 20 74 65 73 74   t2 a32.    test
04f0: 20 6d 65 72 67 65 2d 24 62 61 73 65 2d 24 69 2d   merge-$base-$i-
0500: 33 32 20 7b 5b 73 61 6d 65 5f 66 69 6c 65 20 61  32 {[same_file a
0510: 33 32 20 74 33 32 5d 7d 0a 20 20 7d 0a 7d 0a     32 t32]}.  }.}.