Hex Artifact Content
Not logged in

Artifact 69c9aea1a1f3c2e33de6aa970d174b53594ab62f:

File src/update.c part of check-in [49b59bc559] - Issue a warning after a commit if the commit causes a fork. by drh on 2008-02-09 00:11:04.

0000: 2f 2a 0a 2a 2a 20 43 6f 70 79 72 69 67 68 74 20  /*.** Copyright 
0010: 28 63 29 20 32 30 30 37 20 44 2e 20 52 69 63 68  (c) 2007 D. Rich
0020: 61 72 64 20 48 69 70 70 0a 2a 2a 0a 2a 2a 20 54  ard Hipp.**.** T
0030: 68 69 73 20 70 72 6f 67 72 61 6d 20 69 73 20 66  his program is f
0040: 72 65 65 20 73 6f 66 74 77 61 72 65 3b 20 79 6f  ree software; yo
0050: 75 20 63 61 6e 20 72 65 64 69 73 74 72 69 62 75  u can redistribu
0060: 74 65 20 69 74 20 61 6e 64 2f 6f 72 0a 2a 2a 20  te it and/or.** 
0070: 6d 6f 64 69 66 79 20 69 74 20 75 6e 64 65 72 20  modify it under 
0080: 74 68 65 20 74 65 72 6d 73 20 6f 66 20 74 68 65  the terms of the
0090: 20 47 4e 55 20 47 65 6e 65 72 61 6c 20 50 75 62   GNU General Pub
00a0: 6c 69 63 0a 2a 2a 20 4c 69 63 65 6e 73 65 20 76  lic.** License v
00b0: 65 72 73 69 6f 6e 20 32 20 61 73 20 70 75 62 6c  ersion 2 as publ
00c0: 69 73 68 65 64 20 62 79 20 74 68 65 20 46 72 65  ished by the Fre
00d0: 65 20 53 6f 66 74 77 61 72 65 20 46 6f 75 6e 64  e Software Found
00e0: 61 74 69 6f 6e 2e 0a 2a 2a 0a 2a 2a 20 54 68 69  ation..**.** Thi
00f0: 73 20 70 72 6f 67 72 61 6d 20 69 73 20 64 69 73  s program is dis
0100: 74 72 69 62 75 74 65 64 20 69 6e 20 74 68 65 20  tributed in the 
0110: 68 6f 70 65 20 74 68 61 74 20 69 74 20 77 69 6c  hope that it wil
0120: 6c 20 62 65 20 75 73 65 66 75 6c 2c 0a 2a 2a 20  l be useful,.** 
0130: 62 75 74 20 57 49 54 48 4f 55 54 20 41 4e 59 20  but WITHOUT ANY 
0140: 57 41 52 52 41 4e 54 59 3b 20 77 69 74 68 6f 75  WARRANTY; withou
0150: 74 20 65 76 65 6e 20 74 68 65 20 69 6d 70 6c 69  t even the impli
0160: 65 64 20 77 61 72 72 61 6e 74 79 20 6f 66 0a 2a  ed warranty of.*
0170: 2a 20 4d 45 52 43 48 41 4e 54 41 42 49 4c 49 54  * MERCHANTABILIT
0180: 59 20 6f 72 20 46 49 54 4e 45 53 53 20 46 4f 52  Y or FITNESS FOR
0190: 20 41 20 50 41 52 54 49 43 55 4c 41 52 20 50 55   A PARTICULAR PU
01a0: 52 50 4f 53 45 2e 20 20 53 65 65 20 74 68 65 20  RPOSE.  See the 
01b0: 47 4e 55 0a 2a 2a 20 47 65 6e 65 72 61 6c 20 50  GNU.** General P
01c0: 75 62 6c 69 63 20 4c 69 63 65 6e 73 65 20 66 6f  ublic License fo
01d0: 72 20 6d 6f 72 65 20 64 65 74 61 69 6c 73 2e 0a  r more details..
01e0: 2a 2a 20 0a 2a 2a 20 59 6f 75 20 73 68 6f 75 6c  ** .** You shoul
01f0: 64 20 68 61 76 65 20 72 65 63 65 69 76 65 64 20  d have received 
0200: 61 20 63 6f 70 79 20 6f 66 20 74 68 65 20 47 4e  a copy of the GN
0210: 55 20 47 65 6e 65 72 61 6c 20 50 75 62 6c 69 63  U General Public
0220: 0a 2a 2a 20 4c 69 63 65 6e 73 65 20 61 6c 6f 6e  .** License alon
0230: 67 20 77 69 74 68 20 74 68 69 73 20 6c 69 62 72  g with this libr
0240: 61 72 79 3b 20 69 66 20 6e 6f 74 2c 20 77 72 69  ary; if not, wri
0250: 74 65 20 74 6f 20 74 68 65 0a 2a 2a 20 46 72 65  te to the.** Fre
0260: 65 20 53 6f 66 74 77 61 72 65 20 46 6f 75 6e 64  e Software Found
0270: 61 74 69 6f 6e 2c 20 49 6e 63 2e 2c 20 35 39 20  ation, Inc., 59 
0280: 54 65 6d 70 6c 65 20 50 6c 61 63 65 20 2d 20 53  Temple Place - S
0290: 75 69 74 65 20 33 33 30 2c 0a 2a 2a 20 42 6f 73  uite 330,.** Bos
02a0: 74 6f 6e 2c 20 4d 41 20 20 30 32 31 31 31 2d 31  ton, MA  02111-1
02b0: 33 30 37 2c 20 55 53 41 2e 0a 2a 2a 0a 2a 2a 20  307, USA..**.** 
02c0: 41 75 74 68 6f 72 20 63 6f 6e 74 61 63 74 20 69  Author contact i
02d0: 6e 66 6f 72 6d 61 74 69 6f 6e 3a 0a 2a 2a 20 20  nformation:.**  
02e0: 20 64 72 68 40 68 77 61 63 69 2e 63 6f 6d 0a 2a   drh@hwaci.com.*
02f0: 2a 20 20 20 68 74 74 70 3a 2f 2f 77 77 77 2e 68  *   http://www.h
0300: 77 61 63 69 2e 63 6f 6d 2f 64 72 68 2f 0a 2a 2a  waci.com/drh/.**
0310: 0a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  .***************
0320: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
0330: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
0340: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
0350: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
0360: 0a 2a 2a 0a 2a 2a 20 54 68 69 73 20 66 69 6c 65  .**.** This file
0370: 20 63 6f 6e 74 61 69 6e 73 20 63 6f 64 65 20 75   contains code u
0380: 73 65 64 20 74 6f 20 6d 65 72 67 65 20 74 68 65  sed to merge the
0390: 20 63 68 61 6e 67 65 73 20 69 6e 20 74 68 65 20   changes in the 
03a0: 63 75 72 72 65 6e 74 0a 2a 2a 20 63 68 65 63 6b  current.** check
03b0: 6f 75 74 20 69 6e 74 6f 20 61 20 64 69 66 66 65  out into a diffe
03c0: 72 65 6e 74 20 76 65 72 73 69 6f 6e 20 61 6e 64  rent version and
03d0: 20 73 77 69 74 63 68 20 74 6f 20 74 68 61 74 20   switch to that 
03e0: 76 65 72 73 69 6f 6e 2e 0a 2a 2f 0a 23 69 6e 63  version..*/.#inc
03f0: 6c 75 64 65 20 22 63 6f 6e 66 69 67 2e 68 22 0a  lude "config.h".
0400: 23 69 6e 63 6c 75 64 65 20 22 75 70 64 61 74 65  #include "update
0410: 2e 68 22 0a 23 69 6e 63 6c 75 64 65 20 3c 61 73  .h".#include <as
0420: 73 65 72 74 2e 68 3e 0a 0a 2f 2a 0a 2a 2a 20 52  sert.h>../*.** R
0430: 65 74 75 72 6e 20 74 72 75 65 20 69 66 20 61 72  eturn true if ar
0440: 74 69 66 61 63 74 20 72 69 64 20 69 73 20 61 20  tifact rid is a 
0450: 76 65 72 73 69 6f 6e 0a 2a 2f 0a 69 6e 74 20 69  version.*/.int i
0460: 73 5f 61 5f 76 65 72 73 69 6f 6e 28 69 6e 74 20  s_a_version(int 
0470: 72 69 64 29 7b 0a 20 20 72 65 74 75 72 6e 20 64  rid){.  return d
0480: 62 5f 65 78 69 73 74 73 28 22 53 45 4c 45 43 54  b_exists("SELECT
0490: 20 31 20 46 52 4f 4d 20 70 6c 69 6e 6b 20 57 48   1 FROM plink WH
04a0: 45 52 45 20 63 69 64 3d 25 64 22 2c 20 72 69 64  ERE cid=%d", rid
04b0: 29 3b 0a 7d 0a 0a 2f 2a 0a 2a 2a 20 43 4f 4d 4d  );.}../*.** COMM
04c0: 41 4e 44 3a 20 75 70 64 61 74 65 0a 2a 2a 0a 2a  AND: update.**.*
04d0: 2a 20 55 73 61 67 65 3a 20 25 66 6f 73 73 69 6c  * Usage: %fossil
04e0: 20 75 70 64 61 74 65 20 3f 56 45 52 53 49 4f 4e   update ?VERSION
04f0: 3f 20 3f 2d 2d 6c 61 74 65 73 74 3f 0a 2a 2a 0a  ? ?--latest?.**.
0500: 2a 2a 20 54 68 65 20 6f 70 74 69 6f 6e 61 6c 20  ** The optional 
0510: 61 72 67 75 6d 65 6e 74 20 69 73 20 61 20 76 65  argument is a ve
0520: 72 73 69 6f 6e 20 74 68 61 74 20 73 68 6f 75 6c  rsion that shoul
0530: 64 20 62 65 63 6f 6d 65 20 74 68 65 20 63 75 72  d become the cur
0540: 72 65 6e 74 0a 2a 2a 20 76 65 72 73 69 6f 6e 2e  rent.** version.
0550: 20 20 49 66 20 74 68 65 20 61 72 67 75 6d 65 6e    If the argumen
0560: 74 20 69 73 20 6f 6d 69 74 74 65 64 2c 20 74 68  t is omitted, th
0570: 65 6e 20 75 73 65 20 74 68 65 20 6c 65 61 66 20  en use the leaf 
0580: 6f 66 20 74 68 65 0a 2a 2a 20 74 72 65 65 20 74  of the.** tree t
0590: 68 61 74 20 62 65 67 69 6e 73 20 77 69 74 68 20  hat begins with 
05a0: 74 68 65 20 63 75 72 72 65 6e 74 20 76 65 72 73  the current vers
05b0: 69 6f 6e 2c 20 69 66 20 74 68 65 72 65 20 69 73  ion, if there is
05c0: 20 6f 6e 6c 79 20 61 20 0a 2a 2a 20 73 69 6e 67   only a .** sing
05d0: 6c 65 20 6c 65 61 66 2e 20 20 49 66 20 74 68 65  le leaf.  If the
05e0: 72 65 20 61 72 65 20 61 20 6d 75 6c 74 69 70 6c  re are a multipl
05f0: 65 20 6c 65 61 76 65 73 2c 20 74 68 65 20 6c 61  e leaves, the la
0600: 74 65 73 74 20 69 73 20 75 73 65 64 0a 2a 2a 20  test is used.** 
0610: 69 66 20 74 68 65 20 2d 2d 6c 61 74 65 73 74 20  if the --latest 
0620: 66 6c 61 67 20 69 73 20 70 72 65 73 65 6e 74 2e  flag is present.
0630: 0a 2a 2a 0a 2a 2a 20 54 68 69 73 20 63 6f 6d 6d  .**.** This comm
0640: 61 6e 64 20 69 73 20 64 69 66 66 65 72 65 6e 74  and is different
0650: 20 66 72 6f 6d 20 74 68 65 20 22 63 68 65 63 6b   from the "check
0660: 6f 75 74 22 20 69 6e 20 74 68 61 74 20 65 64 69  out" in that edi
0670: 74 73 20 61 72 65 0a 2a 2a 20 6e 6f 74 20 6f 76  ts are.** not ov
0680: 65 72 77 72 69 74 74 65 6e 2e 20 20 45 64 69 74  erwritten.  Edit
0690: 73 20 61 72 65 20 6d 65 72 67 65 64 20 69 6e 74  s are merged int
06a0: 6f 20 74 68 65 20 6e 65 77 20 76 65 72 73 69 6f  o the new versio
06b0: 6e 2e 0a 2a 2f 0a 76 6f 69 64 20 75 70 64 61 74  n..*/.void updat
06c0: 65 5f 63 6d 64 28 76 6f 69 64 29 7b 0a 20 20 69  e_cmd(void){.  i
06d0: 6e 74 20 76 69 64 3b 20 20 20 20 20 20 20 20 20  nt vid;         
06e0: 20 20 20 20 20 2f 2a 20 43 75 72 72 65 6e 74 20       /* Current 
06f0: 76 65 72 73 69 6f 6e 20 2a 2f 0a 20 20 69 6e 74  version */.  int
0700: 20 74 69 64 3d 30 3b 20 20 20 20 20 20 20 20 20   tid=0;         
0710: 20 20 20 2f 2a 20 54 61 72 67 65 74 20 76 65 72     /* Target ver
0720: 73 69 6f 6e 20 2d 20 76 65 72 73 69 6f 6e 20 77  sion - version w
0730: 65 20 61 72 65 20 63 68 61 6e 67 69 6e 67 20 74  e are changing t
0740: 6f 20 2a 2f 0a 20 20 53 74 6d 74 20 71 3b 0a 20  o */.  Stmt q;. 
0750: 20 69 6e 74 20 6c 61 74 65 73 74 46 6c 61 67 3b   int latestFlag;
0760: 20 20 20 20 20 20 20 2f 2a 20 50 69 63 6b 20 74         /* Pick t
0770: 68 65 20 6c 61 74 65 73 74 20 76 65 72 73 69 6f  he latest versio
0780: 6e 20 69 66 20 74 72 75 65 20 2a 2f 0a 20 20 69  n if true */.  i
0790: 6e 74 20 66 6f 72 63 65 46 6c 61 67 3b 20 20 20  nt forceFlag;   
07a0: 20 20 20 20 20 2f 2a 20 54 72 75 65 20 66 6f 72       /* True for
07b0: 63 65 20 74 68 65 20 75 70 64 61 74 65 20 2a 2f  ce the update */
07c0: 0a 0a 20 20 6c 61 74 65 73 74 46 6c 61 67 20 3d  ..  latestFlag =
07d0: 20 66 69 6e 64 5f 6f 70 74 69 6f 6e 28 22 6c 61   find_option("la
07e0: 74 65 73 74 22 2c 30 2c 20 30 29 21 3d 30 3b 0a  test",0, 0)!=0;.
07f0: 20 20 66 6f 72 63 65 46 6c 61 67 20 3d 20 66 69    forceFlag = fi
0800: 6e 64 5f 6f 70 74 69 6f 6e 28 22 66 6f 72 63 65  nd_option("force
0810: 22 2c 22 66 22 2c 30 29 21 3d 30 3b 0a 20 20 69  ","f",0)!=0;.  i
0820: 66 28 20 67 2e 61 72 67 63 21 3d 33 20 26 26 20  f( g.argc!=3 && 
0830: 67 2e 61 72 67 63 21 3d 32 20 29 7b 0a 20 20 20  g.argc!=2 ){.   
0840: 20 75 73 61 67 65 28 22 3f 56 45 52 53 49 4f 4e   usage("?VERSION
0850: 3f 22 29 3b 0a 20 20 7d 0a 20 20 64 62 5f 6d 75  ?");.  }.  db_mu
0860: 73 74 5f 62 65 5f 77 69 74 68 69 6e 5f 74 72 65  st_be_within_tre
0870: 65 28 29 3b 0a 20 20 76 69 64 20 3d 20 64 62 5f  e();.  vid = db_
0880: 6c 67 65 74 5f 69 6e 74 28 22 63 68 65 63 6b 6f  lget_int("checko
0890: 75 74 22 2c 20 30 29 3b 0a 20 20 69 66 28 20 76  ut", 0);.  if( v
08a0: 69 64 3d 3d 30 20 29 7b 0a 20 20 20 20 66 6f 73  id==0 ){.    fos
08b0: 73 69 6c 5f 66 61 74 61 6c 28 22 63 61 6e 6e 6f  sil_fatal("canno
08c0: 74 20 66 69 6e 64 20 63 75 72 72 65 6e 74 20 76  t find current v
08d0: 65 72 73 69 6f 6e 22 29 3b 0a 20 20 7d 0a 20 20  ersion");.  }.  
08e0: 69 66 28 20 64 62 5f 65 78 69 73 74 73 28 22 53  if( db_exists("S
08f0: 45 4c 45 43 54 20 31 20 46 52 4f 4d 20 76 6d 65  ELECT 1 FROM vme
0900: 72 67 65 22 29 20 29 7b 0a 20 20 20 20 66 6f 73  rge") ){.    fos
0910: 73 69 6c 5f 66 61 74 61 6c 28 22 63 61 6e 6e 6f  sil_fatal("canno
0920: 74 20 75 70 64 61 74 65 20 61 6e 20 75 6e 63 6f  t update an unco
0930: 6d 6d 69 74 74 65 64 20 6d 65 72 67 65 22 29 3b  mmitted merge");
0940: 0a 20 20 7d 0a 23 69 66 20 30 0a 20 20 2f 2a 20  .  }.#if 0.  /* 
0950: 41 6c 77 61 79 73 20 64 6f 20 74 68 65 20 75 70  Always do the up
0960: 64 61 74 65 2e 20 20 49 66 20 69 74 20 64 6f 65  date.  If it doe
0970: 73 20 6e 6f 74 20 77 6f 72 6b 20 6f 75 74 2c 20  s not work out, 
0980: 74 68 65 20 75 73 65 72 20 63 61 6e 20 62 61 63  the user can bac
0990: 6b 20 6f 75 74 0a 20 20 2a 2a 20 74 68 65 20 63  k out.  ** the c
09a0: 68 61 6e 67 65 73 20 75 73 69 6e 67 20 22 75 6e  hanges using "un
09b0: 64 6f 22 20 2a 2f 0a 20 20 69 66 28 20 21 66 6f  do" */.  if( !fo
09c0: 72 63 65 46 6c 61 67 20 26 26 20 75 6e 73 61 76  rceFlag && unsav
09d0: 65 64 5f 63 68 61 6e 67 65 73 28 29 20 29 7b 0a  ed_changes() ){.
09e0: 20 20 20 20 66 6f 73 73 69 6c 5f 66 61 74 61 6c      fossil_fatal
09f0: 28 22 75 6e 63 6f 6d 6d 69 74 74 65 64 20 63 68  ("uncommitted ch
0a00: 61 6e 67 65 73 3b 20 75 73 65 20 2d 66 20 6f 72  anges; use -f or
0a10: 20 2d 2d 66 6f 72 63 65 20 74 6f 20 6f 76 65 72   --force to over
0a20: 72 69 64 65 22 29 3b 0a 20 20 7d 0a 23 65 6e 64  ride");.  }.#end
0a30: 69 66 0a 0a 20 20 69 66 28 20 67 2e 61 72 67 63  if..  if( g.argc
0a40: 3d 3d 33 20 29 7b 0a 20 20 20 20 74 69 64 20 3d  ==3 ){.    tid =
0a50: 20 6e 61 6d 65 5f 74 6f 5f 72 69 64 28 67 2e 61   name_to_rid(g.a
0a60: 72 67 76 5b 32 5d 29 3b 0a 20 20 20 20 69 66 28  rgv[2]);.    if(
0a70: 20 74 69 64 3d 3d 30 20 29 7b 0a 20 20 20 20 20   tid==0 ){.     
0a80: 20 66 6f 73 73 69 6c 5f 66 61 74 61 6c 28 22 6e   fossil_fatal("n
0a90: 6f 74 20 61 20 76 65 72 73 69 6f 6e 3a 20 25 73  ot a version: %s
0aa0: 22 2c 20 67 2e 61 72 67 76 5b 32 5d 29 3b 0a 20  ", g.argv[2]);. 
0ab0: 20 20 20 7d 0a 20 20 20 20 69 66 28 20 21 69 73     }.    if( !is
0ac0: 5f 61 5f 76 65 72 73 69 6f 6e 28 74 69 64 29 20  _a_version(tid) 
0ad0: 29 7b 0a 20 20 20 20 20 20 66 6f 73 73 69 6c 5f  ){.      fossil_
0ae0: 66 61 74 61 6c 28 22 6e 6f 74 20 61 20 76 65 72  fatal("not a ver
0af0: 73 69 6f 6e 3a 20 25 73 22 2c 20 67 2e 61 72 67  sion: %s", g.arg
0b00: 76 5b 32 5d 29 3b 0a 20 20 20 20 7d 0a 20 20 7d  v[2]);.    }.  }
0b10: 0a 0a 20 20 69 66 28 20 74 69 64 3d 3d 30 20 29  ..  if( tid==0 )
0b20: 7b 0a 20 20 20 20 2f 2a 20 0a 20 20 20 20 2a 2a  {.    /* .    **
0b30: 20 44 6f 20 61 6e 20 61 75 74 6f 73 79 6e 63 20   Do an autosync 
0b40: 70 75 6c 6c 20 70 72 69 6f 72 20 74 6f 20 74 68  pull prior to th
0b50: 65 20 75 70 64 61 74 65 2c 20 69 66 20 61 75 74  e update, if aut
0b60: 6f 73 79 6e 63 20 69 73 20 6f 6e 20 61 6e 64 20  osync is on and 
0b70: 74 68 65 79 0a 20 20 20 20 2a 2a 20 64 69 64 20  they.    ** did 
0b80: 6e 6f 74 20 77 61 6e 74 20 61 20 73 70 65 63 69  not want a speci
0b90: 66 69 63 20 76 65 72 73 69 6f 6e 20 28 69 2e 65  fic version (i.e
0ba0: 2e 20 61 6e 6f 74 68 65 72 20 62 72 61 6e 63 68  . another branch
0bb0: 2c 20 61 20 70 61 73 74 20 72 65 76 69 73 69 6f  , a past revisio
0bc0: 6e 29 2e 0a 20 20 20 20 2a 2a 20 42 79 20 6e 6f  n)..    ** By no
0bd0: 74 20 67 69 76 69 6e 67 20 61 20 73 70 65 63 69  t giving a speci
0be0: 66 69 63 20 76 65 72 73 69 6f 6e 2c 20 74 68 65  fic version, the
0bf0: 79 20 61 72 65 20 61 73 6b 69 6e 67 20 66 6f 72  y are asking for
0c00: 20 74 68 65 20 6c 61 74 65 73 74 2c 20 74 68 75   the latest, thu
0c10: 73 0a 20 20 20 20 2a 2a 20 70 75 6c 6c 20 74 6f  s.    ** pull to
0c20: 20 67 65 74 20 74 68 65 20 6c 61 74 65 73 74 2c   get the latest,
0c30: 20 74 68 65 6e 20 75 70 64 61 74 65 2e 0a 20 20   then update..  
0c40: 20 20 2a 2f 0a 20 20 20 20 61 75 74 6f 73 79 6e    */.    autosyn
0c50: 63 28 41 55 54 4f 53 59 4e 43 5f 50 55 4c 4c 29  c(AUTOSYNC_PULL)
0c60: 3b 0a 20 20 7d 0a 20 20 0a 20 20 69 66 28 20 74  ;.  }.  .  if( t
0c70: 69 64 3d 3d 30 20 29 7b 0a 20 20 20 20 63 6f 6d  id==0 ){.    com
0c80: 70 75 74 65 5f 6c 65 61 76 65 73 28 76 69 64 29  pute_leaves(vid)
0c90: 3b 0a 20 20 20 20 69 66 28 20 21 6c 61 74 65 73  ;.    if( !lates
0ca0: 74 46 6c 61 67 20 26 26 20 64 62 5f 69 6e 74 28  tFlag && db_int(
0cb0: 30 2c 20 22 53 45 4c 45 43 54 20 63 6f 75 6e 74  0, "SELECT count
0cc0: 28 2a 29 20 46 52 4f 4d 20 6c 65 61 76 65 73 22  (*) FROM leaves"
0cd0: 29 3e 31 20 29 7b 0a 20 20 20 20 20 20 64 62 5f  )>1 ){.      db_
0ce0: 70 72 65 70 61 72 65 28 26 71 2c 20 0a 20 20 20  prepare(&q, .   
0cf0: 20 20 20 20 20 22 25 73 20 22 0a 20 20 20 20 20       "%s ".     
0d00: 20 20 20 22 20 20 20 41 4e 44 20 65 76 65 6e 74     "   AND event
0d10: 2e 6f 62 6a 69 64 20 49 4e 20 6c 65 61 76 65 73  .objid IN leaves
0d20: 22 0a 20 20 20 20 20 20 20 20 22 20 4f 52 44 45  ".        " ORDE
0d30: 52 20 42 59 20 65 76 65 6e 74 2e 6d 74 69 6d 65  R BY event.mtime
0d40: 20 44 45 53 43 22 2c 0a 20 20 20 20 20 20 20 20   DESC",.        
0d50: 74 69 6d 65 6c 69 6e 65 5f 71 75 65 72 79 5f 66  timeline_query_f
0d60: 6f 72 5f 74 74 79 28 29 0a 20 20 20 20 20 20 29  or_tty().      )
0d70: 3b 0a 20 20 20 20 20 20 70 72 69 6e 74 5f 74 69  ;.      print_ti
0d80: 6d 65 6c 69 6e 65 28 26 71 2c 20 31 30 30 29 3b  meline(&q, 100);
0d90: 0a 20 20 20 20 20 20 64 62 5f 66 69 6e 61 6c 69  .      db_finali
0da0: 7a 65 28 26 71 29 3b 0a 20 20 20 20 20 20 66 6f  ze(&q);.      fo
0db0: 73 73 69 6c 5f 66 61 74 61 6c 28 22 4d 75 6c 74  ssil_fatal("Mult
0dc0: 69 70 6c 65 20 64 65 73 63 65 6e 64 65 6e 74 73  iple descendents
0dd0: 22 29 3b 0a 20 20 20 20 7d 0a 20 20 20 20 74 69  ");.    }.    ti
0de0: 64 20 3d 20 64 62 5f 69 6e 74 28 30 2c 20 22 53  d = db_int(0, "S
0df0: 45 4c 45 43 54 20 72 69 64 20 46 52 4f 4d 20 6c  ELECT rid FROM l
0e00: 65 61 76 65 73 2c 20 65 76 65 6e 74 22 0a 20 20  eaves, event".  
0e10: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0e20: 20 20 22 20 57 48 45 52 45 20 65 76 65 6e 74 2e    " WHERE event.
0e30: 6f 62 6a 69 64 3d 6c 65 61 76 65 73 2e 72 69 64  objid=leaves.rid
0e40: 22 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20  ".              
0e50: 20 20 20 20 20 20 22 20 4f 52 44 45 52 20 42 59        " ORDER BY
0e60: 20 65 76 65 6e 74 2e 6d 74 69 6d 65 20 44 45 53   event.mtime DES
0e70: 43 22 29 3b 20 0a 20 20 7d 0a 0a 20 20 64 62 5f  C"); .  }..  db_
0e80: 62 65 67 69 6e 5f 74 72 61 6e 73 61 63 74 69 6f  begin_transactio
0e90: 6e 28 29 3b 0a 20 20 76 66 69 6c 65 5f 63 68 65  n();.  vfile_che
0ea0: 63 6b 5f 73 69 67 6e 61 74 75 72 65 28 76 69 64  ck_signature(vid
0eb0: 29 3b 0a 20 20 75 6e 64 6f 5f 62 65 67 69 6e 28  );.  undo_begin(
0ec0: 29 3b 0a 20 20 6c 6f 61 64 5f 76 66 69 6c 65 5f  );.  load_vfile_
0ed0: 66 72 6f 6d 5f 72 69 64 28 74 69 64 29 3b 0a 0a  from_rid(tid);..
0ee0: 20 20 2f 2a 0a 20 20 2a 2a 20 54 68 65 20 72 65    /*.  ** The re
0ef0: 63 6f 72 64 2e 66 6e 20 66 69 65 6c 64 20 69 73  cord.fn field is
0f00: 20 75 73 65 64 20 74 6f 20 6d 61 74 63 68 20 66   used to match f
0f10: 69 6c 65 73 20 61 67 61 69 6e 73 74 20 65 61 63  iles against eac
0f20: 68 20 6f 74 68 65 72 2e 20 20 54 68 65 0a 20 20  h other.  The.  
0f30: 2a 2a 20 46 56 20 74 61 62 6c 65 20 63 6f 6e 74  ** FV table cont
0f40: 61 69 6e 73 20 6f 6e 65 20 72 6f 77 20 66 6f 72  ains one row for
0f50: 20 65 61 63 68 20 65 61 63 68 20 75 6e 69 71 75   each each uniqu
0f60: 65 20 66 69 6c 65 6e 61 6d 65 20 69 6e 0a 20 20  e filename in.  
0f70: 2a 2a 20 69 6e 20 74 68 65 20 63 75 72 72 65 6e  ** in the curren
0f80: 74 20 63 68 65 63 6b 6f 75 74 2c 20 74 68 65 20  t checkout, the 
0f90: 70 69 76 6f 74 2c 20 61 6e 64 20 74 68 65 20 76  pivot, and the v
0fa0: 65 72 73 69 6f 6e 20 62 65 69 6e 67 20 6d 65 72  ersion being mer
0fb0: 67 65 64 2e 0a 20 20 2a 2f 0a 20 20 64 62 5f 6d  ged..  */.  db_m
0fc0: 75 6c 74 69 5f 65 78 65 63 28 0a 20 20 20 20 22  ulti_exec(.    "
0fd0: 44 52 4f 50 20 54 41 42 4c 45 20 49 46 20 45 58  DROP TABLE IF EX
0fe0: 49 53 54 53 20 66 76 3b 22 0a 20 20 20 20 22 43  ISTS fv;".    "C
0ff0: 52 45 41 54 45 20 54 45 4d 50 20 54 41 42 4c 45  REATE TEMP TABLE
1000: 20 66 76 28 22 0a 20 20 20 20 22 20 20 66 6e 20   fv(".    "  fn 
1010: 54 45 58 54 20 50 52 49 4d 41 52 59 20 4b 45 59  TEXT PRIMARY KEY
1020: 2c 22 20 20 20 20 20 20 2f 2a 20 54 68 65 20 66  ,"      /* The f
1030: 69 6c 65 6e 61 6d 65 20 2a 2f 0a 20 20 20 20 22  ilename */.    "
1040: 20 20 69 64 76 20 49 4e 54 45 47 45 52 2c 22 20    idv INTEGER," 
1050: 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20               /* 
1060: 56 46 49 4c 45 20 65 6e 74 72 79 20 66 6f 72 20  VFILE entry for 
1070: 63 75 72 72 65 6e 74 20 76 65 72 73 69 6f 6e 20  current version 
1080: 2a 2f 0a 20 20 20 20 22 20 20 69 64 74 20 49 4e  */.    "  idt IN
1090: 54 45 47 45 52 2c 22 20 20 20 20 20 20 20 20 20  TEGER,"         
10a0: 20 20 20 20 20 2f 2a 20 56 46 49 4c 45 20 65 6e       /* VFILE en
10b0: 74 72 79 20 66 6f 72 20 74 61 72 67 65 74 20 76  try for target v
10c0: 65 72 73 69 6f 6e 20 2a 2f 0a 20 20 20 20 22 20  ersion */.    " 
10d0: 20 63 68 6e 67 65 64 20 42 4f 4f 4c 45 41 4e 2c   chnged BOOLEAN,
10e0: 22 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 54  "           /* T
10f0: 72 75 65 20 69 66 20 63 75 72 72 65 6e 74 20 76  rue if current v
1100: 65 72 73 69 6f 6e 20 68 61 73 20 62 65 65 6e 20  ersion has been 
1110: 65 64 69 74 65 64 20 2a 2f 0a 20 20 20 20 22 20  edited */.    " 
1120: 20 72 69 64 76 20 49 4e 54 45 47 45 52 2c 22 20   ridv INTEGER," 
1130: 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 52              /* R
1140: 65 63 6f 72 64 20 49 44 20 66 6f 72 20 63 75 72  ecord ID for cur
1150: 72 65 6e 74 20 76 65 72 73 69 6f 6e 20 2a 2f 0a  rent version */.
1160: 20 20 20 20 22 20 20 72 69 64 74 20 49 4e 54 45      "  ridt INTE
1170: 47 45 52 20 22 20 20 20 20 20 20 20 20 20 20 20  GER "           
1180: 20 20 2f 2a 20 52 65 63 6f 72 64 20 49 44 20 66    /* Record ID f
1190: 6f 72 20 74 61 72 67 65 74 20 2a 2f 0a 20 20 20  or target */.   
11a0: 20 22 29 3b 22 0a 20 20 20 20 22 49 4e 53 45 52   ");".    "INSER
11b0: 54 20 4f 52 20 49 47 4e 4f 52 45 20 49 4e 54 4f  T OR IGNORE INTO
11c0: 20 66 76 22 0a 20 20 20 20 22 20 53 45 4c 45 43   fv".    " SELEC
11d0: 54 20 70 61 74 68 6e 61 6d 65 2c 20 30 2c 20 30  T pathname, 0, 0
11e0: 2c 20 30 2c 20 30 2c 20 30 20 46 52 4f 4d 20 76  , 0, 0, 0 FROM v
11f0: 66 69 6c 65 22 0a 20 20 29 3b 0a 20 20 64 62 5f  file".  );.  db_
1200: 70 72 65 70 61 72 65 28 26 71 2c 0a 20 20 20 20  prepare(&q,.    
1210: 22 53 45 4c 45 43 54 20 69 64 2c 20 70 61 74 68  "SELECT id, path
1220: 6e 61 6d 65 2c 20 72 69 64 20 46 52 4f 4d 20 76  name, rid FROM v
1230: 66 69 6c 65 22 0a 20 20 20 20 22 20 57 48 45 52  file".    " WHER
1240: 45 20 76 69 64 3d 25 64 22 2c 20 74 69 64 0a 20  E vid=%d", tid. 
1250: 20 29 3b 0a 20 20 77 68 69 6c 65 28 20 64 62 5f   );.  while( db_
1260: 73 74 65 70 28 26 71 29 3d 3d 53 51 4c 49 54 45  step(&q)==SQLITE
1270: 5f 52 4f 57 20 29 7b 0a 20 20 20 20 69 6e 74 20  _ROW ){.    int 
1280: 69 64 20 3d 20 64 62 5f 63 6f 6c 75 6d 6e 5f 69  id = db_column_i
1290: 6e 74 28 26 71 2c 20 30 29 3b 0a 20 20 20 20 63  nt(&q, 0);.    c
12a0: 6f 6e 73 74 20 63 68 61 72 20 2a 66 6e 20 3d 20  onst char *fn = 
12b0: 64 62 5f 63 6f 6c 75 6d 6e 5f 74 65 78 74 28 26  db_column_text(&
12c0: 71 2c 20 31 29 3b 0a 20 20 20 20 69 6e 74 20 72  q, 1);.    int r
12d0: 69 64 20 3d 20 64 62 5f 63 6f 6c 75 6d 6e 5f 69  id = db_column_i
12e0: 6e 74 28 26 71 2c 20 32 29 3b 0a 20 20 20 20 64  nt(&q, 2);.    d
12f0: 62 5f 6d 75 6c 74 69 5f 65 78 65 63 28 0a 20 20  b_multi_exec(.  
1300: 20 20 20 20 22 55 50 44 41 54 45 20 66 76 20 53      "UPDATE fv S
1310: 45 54 20 69 64 74 3d 25 64 2c 20 72 69 64 74 3d  ET idt=%d, ridt=
1320: 25 64 20 57 48 45 52 45 20 66 6e 3d 25 51 22 2c  %d WHERE fn=%Q",
1330: 0a 20 20 20 20 20 20 69 64 2c 20 72 69 64 2c 20  .      id, rid, 
1340: 66 6e 0a 20 20 20 20 29 3b 0a 20 20 7d 0a 20 20  fn.    );.  }.  
1350: 64 62 5f 66 69 6e 61 6c 69 7a 65 28 26 71 29 3b  db_finalize(&q);
1360: 0a 20 20 64 62 5f 70 72 65 70 61 72 65 28 26 71  .  db_prepare(&q
1370: 2c 0a 20 20 20 20 22 53 45 4c 45 43 54 20 69 64  ,.    "SELECT id
1380: 2c 20 70 61 74 68 6e 61 6d 65 2c 20 72 69 64 2c  , pathname, rid,
1390: 20 63 68 6e 67 65 64 20 46 52 4f 4d 20 76 66 69   chnged FROM vfi
13a0: 6c 65 22 0a 20 20 20 20 22 20 57 48 45 52 45 20  le".    " WHERE 
13b0: 76 69 64 3d 25 64 22 2c 20 76 69 64 0a 20 20 29  vid=%d", vid.  )
13c0: 3b 0a 20 20 77 68 69 6c 65 28 20 64 62 5f 73 74  ;.  while( db_st
13d0: 65 70 28 26 71 29 3d 3d 53 51 4c 49 54 45 5f 52  ep(&q)==SQLITE_R
13e0: 4f 57 20 29 7b 0a 20 20 20 20 69 6e 74 20 69 64  OW ){.    int id
13f0: 20 3d 20 64 62 5f 63 6f 6c 75 6d 6e 5f 69 6e 74   = db_column_int
1400: 28 26 71 2c 20 30 29 3b 0a 20 20 20 20 63 6f 6e  (&q, 0);.    con
1410: 73 74 20 63 68 61 72 20 2a 66 6e 20 3d 20 64 62  st char *fn = db
1420: 5f 63 6f 6c 75 6d 6e 5f 74 65 78 74 28 26 71 2c  _column_text(&q,
1430: 20 31 29 3b 0a 20 20 20 20 69 6e 74 20 72 69 64   1);.    int rid
1440: 20 3d 20 64 62 5f 63 6f 6c 75 6d 6e 5f 69 6e 74   = db_column_int
1450: 28 26 71 2c 20 32 29 3b 0a 20 20 20 20 69 6e 74  (&q, 2);.    int
1460: 20 63 68 6e 67 65 64 20 3d 20 64 62 5f 63 6f 6c   chnged = db_col
1470: 75 6d 6e 5f 69 6e 74 28 26 71 2c 20 33 29 3b 0a  umn_int(&q, 3);.
1480: 20 20 20 20 64 62 5f 6d 75 6c 74 69 5f 65 78 65      db_multi_exe
1490: 63 28 0a 20 20 20 20 20 20 22 55 50 44 41 54 45  c(.      "UPDATE
14a0: 20 66 76 20 53 45 54 20 69 64 76 3d 25 64 2c 20   fv SET idv=%d, 
14b0: 72 69 64 76 3d 25 64 2c 20 63 68 6e 67 65 64 3d  ridv=%d, chnged=
14c0: 25 64 20 57 48 45 52 45 20 66 6e 3d 25 51 22 2c  %d WHERE fn=%Q",
14d0: 0a 20 20 20 20 20 20 69 64 2c 20 72 69 64 2c 20  .      id, rid, 
14e0: 63 68 6e 67 65 64 2c 20 66 6e 0a 20 20 20 20 29  chnged, fn.    )
14f0: 3b 0a 20 20 7d 0a 20 20 64 62 5f 66 69 6e 61 6c  ;.  }.  db_final
1500: 69 7a 65 28 26 71 29 3b 0a 0a 20 20 64 62 5f 70  ize(&q);..  db_p
1510: 72 65 70 61 72 65 28 26 71 2c 20 0a 20 20 20 20  repare(&q, .    
1520: 22 53 45 4c 45 43 54 20 66 6e 2c 20 69 64 76 2c  "SELECT fn, idv,
1530: 20 72 69 64 76 2c 20 69 64 74 2c 20 72 69 64 74   ridv, idt, ridt
1540: 2c 20 63 68 6e 67 65 64 20 46 52 4f 4d 20 66 76  , chnged FROM fv
1550: 20 4f 52 44 45 52 20 42 59 20 31 22 0a 20 20 29   ORDER BY 1".  )
1560: 3b 0a 20 20 77 68 69 6c 65 28 20 64 62 5f 73 74  ;.  while( db_st
1570: 65 70 28 26 71 29 3d 3d 53 51 4c 49 54 45 5f 52  ep(&q)==SQLITE_R
1580: 4f 57 20 29 7b 0a 20 20 20 20 63 6f 6e 73 74 20  OW ){.    const 
1590: 63 68 61 72 20 2a 7a 4e 61 6d 65 20 3d 20 64 62  char *zName = db
15a0: 5f 63 6f 6c 75 6d 6e 5f 74 65 78 74 28 26 71 2c  _column_text(&q,
15b0: 20 30 29 3b 0a 20 20 20 20 69 6e 74 20 69 64 76   0);.    int idv
15c0: 20 3d 20 64 62 5f 63 6f 6c 75 6d 6e 5f 69 6e 74   = db_column_int
15d0: 28 26 71 2c 20 31 29 3b 0a 20 20 20 20 69 6e 74  (&q, 1);.    int
15e0: 20 72 69 64 76 20 3d 20 64 62 5f 63 6f 6c 75 6d   ridv = db_colum
15f0: 6e 5f 69 6e 74 28 26 71 2c 20 32 29 3b 0a 20 20  n_int(&q, 2);.  
1600: 20 20 69 6e 74 20 69 64 74 20 3d 20 64 62 5f 63    int idt = db_c
1610: 6f 6c 75 6d 6e 5f 69 6e 74 28 26 71 2c 20 33 29  olumn_int(&q, 3)
1620: 3b 0a 20 20 20 20 69 6e 74 20 72 69 64 74 20 3d  ;.    int ridt =
1630: 20 64 62 5f 63 6f 6c 75 6d 6e 5f 69 6e 74 28 26   db_column_int(&
1640: 71 2c 20 34 29 3b 0a 20 20 20 20 69 6e 74 20 63  q, 4);.    int c
1650: 68 6e 67 65 64 20 3d 20 64 62 5f 63 6f 6c 75 6d  hnged = db_colum
1660: 6e 5f 69 6e 74 28 26 71 2c 20 35 29 3b 0a 0a 20  n_int(&q, 5);.. 
1670: 20 20 20 69 66 28 20 69 64 76 3e 30 20 26 26 20     if( idv>0 && 
1680: 72 69 64 76 3d 3d 30 20 26 26 20 69 64 74 3e 30  ridv==0 && idt>0
1690: 20 29 7b 0a 20 20 20 20 20 20 2f 2a 20 43 6f 6e   ){.      /* Con
16a0: 66 6c 69 63 74 2e 20 20 54 68 69 73 20 66 69 6c  flict.  This fil
16b0: 65 20 68 61 73 20 62 65 65 6e 20 61 64 64 65 64  e has been added
16c0: 20 74 6f 20 74 68 65 20 63 75 72 72 65 6e 74 20   to the current 
16d0: 63 68 65 63 6b 6f 75 74 0a 20 20 20 20 20 20 2a  checkout.      *
16e0: 2a 20 62 75 74 20 61 6c 73 6f 20 65 78 69 73 74  * but also exist
16f0: 73 20 69 6e 20 74 68 65 20 74 61 72 67 65 74 20  s in the target 
1700: 63 68 65 63 6b 6f 75 74 2e 20 20 55 73 65 20 74  checkout.  Use t
1710: 68 65 20 63 75 72 72 65 6e 74 20 76 65 72 73 69  he current versi
1720: 6f 6e 2e 0a 20 20 20 20 20 20 2a 2f 0a 20 20 20  on..      */.   
1730: 20 20 20 70 72 69 6e 74 66 28 22 43 4f 4e 46 4c     printf("CONFL
1740: 49 43 54 20 25 73 5c 6e 22 2c 20 7a 4e 61 6d 65  ICT %s\n", zName
1750: 29 3b 0a 20 20 20 20 7d 65 6c 73 65 20 69 66 28  );.    }else if(
1760: 20 69 64 74 3e 30 20 26 26 20 69 64 76 3d 3d 30   idt>0 && idv==0
1770: 20 29 7b 0a 20 20 20 20 20 20 2f 2a 20 46 69 6c   ){.      /* Fil
1780: 65 20 61 64 64 65 64 20 69 6e 20 74 68 65 20 74  e added in the t
1790: 61 72 67 65 74 2e 20 2a 2f 0a 20 20 20 20 20 20  arget. */.      
17a0: 70 72 69 6e 74 66 28 22 41 44 44 20 25 73 5c 6e  printf("ADD %s\n
17b0: 22 2c 20 7a 4e 61 6d 65 29 3b 0a 20 20 20 20 20  ", zName);.     
17c0: 20 75 6e 64 6f 5f 73 61 76 65 28 7a 4e 61 6d 65   undo_save(zName
17d0: 29 3b 0a 20 20 20 20 20 20 76 66 69 6c 65 5f 74  );.      vfile_t
17e0: 6f 5f 64 69 73 6b 28 30 2c 20 69 64 74 2c 20 30  o_disk(0, idt, 0
17f0: 29 3b 0a 20 20 20 20 7d 65 6c 73 65 20 69 66 28  );.    }else if(
1800: 20 69 64 74 3e 30 20 26 26 20 69 64 76 3e 30 20   idt>0 && idv>0 
1810: 26 26 20 72 69 64 74 21 3d 72 69 64 76 20 26 26  && ridt!=ridv &&
1820: 20 63 68 6e 67 65 64 3d 3d 30 20 29 7b 0a 20 20   chnged==0 ){.  
1830: 20 20 20 20 2f 2a 20 54 68 65 20 66 69 6c 65 20      /* The file 
1840: 69 73 20 75 6e 65 64 69 74 65 64 2e 20 20 43 68  is unedited.  Ch
1850: 61 6e 67 65 20 69 74 20 74 6f 20 74 68 65 20 74  ange it to the t
1860: 61 72 67 65 74 20 76 65 72 73 69 6f 6e 20 2a 2f  arget version */
1870: 0a 20 20 20 20 20 20 70 72 69 6e 74 66 28 22 55  .      printf("U
1880: 50 44 41 54 45 20 25 73 5c 6e 22 2c 20 7a 4e 61  PDATE %s\n", zNa
1890: 6d 65 29 3b 0a 20 20 20 20 20 20 75 6e 64 6f 5f  me);.      undo_
18a0: 73 61 76 65 28 7a 4e 61 6d 65 29 3b 0a 20 20 20  save(zName);.   
18b0: 20 20 20 76 66 69 6c 65 5f 74 6f 5f 64 69 73 6b     vfile_to_disk
18c0: 28 30 2c 20 69 64 74 2c 20 30 29 3b 0a 20 20 20  (0, idt, 0);.   
18d0: 20 7d 65 6c 73 65 20 69 66 28 20 69 64 74 3d 3d   }else if( idt==
18e0: 30 20 26 26 20 69 64 76 3e 30 20 29 7b 0a 20 20  0 && idv>0 ){.  
18f0: 20 20 20 20 69 66 28 20 63 68 6e 67 65 64 20 29      if( chnged )
1900: 7b 0a 20 20 20 20 20 20 20 20 70 72 69 6e 74 66  {.        printf
1910: 28 22 43 4f 4e 46 4c 49 43 54 20 25 73 5c 6e 22  ("CONFLICT %s\n"
1920: 2c 20 7a 4e 61 6d 65 29 3b 0a 20 20 20 20 20 20  , zName);.      
1930: 7d 65 6c 73 65 7b 0a 20 20 20 20 20 20 20 20 63  }else{.        c
1940: 68 61 72 20 2a 7a 46 75 6c 6c 50 61 74 68 3b 0a  har *zFullPath;.
1950: 20 20 20 20 20 20 20 20 70 72 69 6e 74 66 28 22          printf("
1960: 52 45 4d 4f 56 45 20 25 73 5c 6e 22 2c 20 7a 4e  REMOVE %s\n", zN
1970: 61 6d 65 29 3b 0a 20 20 20 20 20 20 20 20 75 6e  ame);.        un
1980: 64 6f 5f 73 61 76 65 28 7a 4e 61 6d 65 29 3b 0a  do_save(zName);.
1990: 20 20 20 20 20 20 20 20 7a 46 75 6c 6c 50 61 74          zFullPat
19a0: 68 20 3d 20 6d 70 72 69 6e 74 66 28 22 25 73 2f  h = mprintf("%s/
19b0: 25 73 22 2c 20 67 2e 7a 4c 6f 63 61 6c 52 6f 6f  %s", g.zLocalRoo
19c0: 74 2c 20 7a 4e 61 6d 65 29 3b 0a 20 20 20 20 20  t, zName);.     
19d0: 20 20 20 75 6e 6c 69 6e 6b 28 7a 46 75 6c 6c 50     unlink(zFullP
19e0: 61 74 68 29 3b 0a 20 20 20 20 20 20 20 20 66 72  ath);.        fr
19f0: 65 65 28 7a 46 75 6c 6c 50 61 74 68 29 3b 0a 20  ee(zFullPath);. 
1a00: 20 20 20 20 20 7d 0a 20 20 20 20 7d 65 6c 73 65       }.    }else
1a10: 20 69 66 28 20 69 64 74 3e 30 20 26 26 20 69 64   if( idt>0 && id
1a20: 76 3e 30 20 26 26 20 72 69 64 74 21 3d 72 69 64  v>0 && ridt!=rid
1a30: 76 20 26 26 20 63 68 6e 67 65 64 20 29 7b 0a 20  v && chnged ){. 
1a40: 20 20 20 20 20 2f 2a 20 4d 65 72 67 65 20 74 68       /* Merge th
1a50: 65 20 63 68 61 6e 67 65 73 20 69 6e 20 74 68 65  e changes in the
1a60: 20 63 75 72 72 65 6e 74 20 74 72 65 65 20 69 6e   current tree in
1a70: 74 6f 20 74 68 65 20 74 61 72 67 65 74 20 76 65  to the target ve
1a80: 72 73 69 6f 6e 20 2a 2f 0a 20 20 20 20 20 20 42  rsion */.      B
1a90: 6c 6f 62 20 65 2c 20 72 2c 20 74 2c 20 76 3b 0a  lob e, r, t, v;.
1aa0: 20 20 20 20 20 20 69 6e 74 20 72 63 3b 0a 20 20        int rc;.  
1ab0: 20 20 20 20 63 68 61 72 20 2a 7a 46 75 6c 6c 50      char *zFullP
1ac0: 61 74 68 3b 0a 20 20 20 20 20 20 70 72 69 6e 74  ath;.      print
1ad0: 66 28 22 4d 45 52 47 45 20 25 73 5c 6e 22 2c 20  f("MERGE %s\n", 
1ae0: 7a 4e 61 6d 65 29 3b 0a 20 20 20 20 20 20 75 6e  zName);.      un
1af0: 64 6f 5f 73 61 76 65 28 7a 4e 61 6d 65 29 3b 0a  do_save(zName);.
1b00: 20 20 20 20 20 20 7a 46 75 6c 6c 50 61 74 68 20        zFullPath 
1b10: 3d 20 6d 70 72 69 6e 74 66 28 22 25 73 2f 25 73  = mprintf("%s/%s
1b20: 22 2c 20 67 2e 7a 4c 6f 63 61 6c 52 6f 6f 74 2c  ", g.zLocalRoot,
1b30: 20 7a 4e 61 6d 65 29 3b 0a 20 20 20 20 20 20 63   zName);.      c
1b40: 6f 6e 74 65 6e 74 5f 67 65 74 28 72 69 64 74 2c  ontent_get(ridt,
1b50: 20 26 74 29 3b 0a 20 20 20 20 20 20 63 6f 6e 74   &t);.      cont
1b60: 65 6e 74 5f 67 65 74 28 72 69 64 76 2c 20 26 76  ent_get(ridv, &v
1b70: 29 3b 0a 20 20 20 20 20 20 62 6c 6f 62 5f 7a 65  );.      blob_ze
1b80: 72 6f 28 26 65 29 3b 0a 20 20 20 20 20 20 62 6c  ro(&e);.      bl
1b90: 6f 62 5f 72 65 61 64 5f 66 72 6f 6d 5f 66 69 6c  ob_read_from_fil
1ba0: 65 28 26 65 2c 20 7a 46 75 6c 6c 50 61 74 68 29  e(&e, zFullPath)
1bb0: 3b 0a 20 20 20 20 20 20 72 63 20 3d 20 62 6c 6f  ;.      rc = blo
1bc0: 62 5f 6d 65 72 67 65 28 26 76 2c 20 26 65 2c 20  b_merge(&v, &e, 
1bd0: 26 74 2c 20 26 72 29 3b 0a 20 20 20 20 20 20 69  &t, &r);.      i
1be0: 66 28 20 72 63 3e 3d 30 20 29 7b 0a 20 20 20 20  f( rc>=0 ){.    
1bf0: 20 20 20 20 62 6c 6f 62 5f 77 72 69 74 65 5f 74      blob_write_t
1c00: 6f 5f 66 69 6c 65 28 26 72 2c 20 7a 46 75 6c 6c  o_file(&r, zFull
1c10: 50 61 74 68 29 3b 0a 20 20 20 20 20 20 20 20 69  Path);.        i
1c20: 66 28 20 72 63 3e 30 20 29 7b 0a 20 20 20 20 20  f( rc>0 ){.     
1c30: 20 20 20 20 20 70 72 69 6e 74 66 28 22 2a 2a 2a       printf("***
1c40: 2a 2a 20 25 64 20 6d 65 72 67 65 20 63 6f 6e 66  ** %d merge conf
1c50: 6c 69 63 74 73 20 69 6e 20 25 73 5c 6e 22 2c 20  licts in %s\n", 
1c60: 72 63 2c 20 7a 4e 61 6d 65 29 3b 0a 20 20 20 20  rc, zName);.    
1c70: 20 20 20 20 7d 0a 20 20 20 20 20 20 7d 65 6c 73      }.      }els
1c80: 65 7b 0a 20 20 20 20 20 20 20 20 70 72 69 6e 74  e{.        print
1c90: 66 28 22 2a 2a 2a 2a 2a 20 43 61 6e 6e 6f 74 20  f("***** Cannot 
1ca0: 6d 65 72 67 65 20 62 69 6e 61 72 79 20 66 69 6c  merge binary fil
1cb0: 65 20 25 73 5c 6e 22 2c 20 7a 4e 61 6d 65 29 3b  e %s\n", zName);
1cc0: 0a 20 20 20 20 20 20 7d 0a 20 20 20 20 20 20 66  .      }.      f
1cd0: 72 65 65 28 7a 46 75 6c 6c 50 61 74 68 29 3b 0a  ree(zFullPath);.
1ce0: 20 20 20 20 20 20 62 6c 6f 62 5f 72 65 73 65 74        blob_reset
1cf0: 28 26 76 29 3b 0a 20 20 20 20 20 20 62 6c 6f 62  (&v);.      blob
1d00: 5f 72 65 73 65 74 28 26 65 29 3b 0a 20 20 20 20  _reset(&e);.    
1d10: 20 20 62 6c 6f 62 5f 72 65 73 65 74 28 26 74 29    blob_reset(&t)
1d20: 3b 0a 20 20 20 20 20 20 62 6c 6f 62 5f 72 65 73  ;.      blob_res
1d30: 65 74 28 26 72 29 3b 0a 20 20 20 20 20 20 0a 20  et(&r);.      . 
1d40: 20 20 20 7d 0a 20 20 7d 0a 20 20 64 62 5f 66 69     }.  }.  db_fi
1d50: 6e 61 6c 69 7a 65 28 26 71 29 3b 0a 20 20 0a 20  nalize(&q);.  . 
1d60: 20 2f 2a 0a 20 20 2a 2a 20 43 6c 65 61 6e 20 75   /*.  ** Clean u
1d70: 70 20 74 68 65 20 6d 69 64 20 61 6e 64 20 70 69  p the mid and pi
1d80: 64 20 56 46 49 4c 45 20 65 6e 74 72 69 65 73 2e  d VFILE entries.
1d90: 20 20 54 68 65 6e 20 63 6f 6d 6d 69 74 20 74 68    Then commit th
1da0: 65 20 63 68 61 6e 67 65 73 2e 0a 20 20 2a 2f 0a  e changes..  */.
1db0: 20 20 64 62 5f 6d 75 6c 74 69 5f 65 78 65 63 28    db_multi_exec(
1dc0: 22 44 45 4c 45 54 45 20 46 52 4f 4d 20 76 66 69  "DELETE FROM vfi
1dd0: 6c 65 20 57 48 45 52 45 20 76 69 64 21 3d 25 64  le WHERE vid!=%d
1de0: 22 2c 20 74 69 64 29 3b 0a 20 20 6d 61 6e 69 66  ", tid);.  manif
1df0: 65 73 74 5f 74 6f 5f 64 69 73 6b 28 74 69 64 29  est_to_disk(tid)
1e00: 3b 0a 20 20 64 62 5f 6c 73 65 74 5f 69 6e 74 28  ;.  db_lset_int(
1e10: 22 63 68 65 63 6b 6f 75 74 22 2c 20 74 69 64 29  "checkout", tid)
1e20: 3b 0a 20 20 64 62 5f 65 6e 64 5f 74 72 61 6e 73  ;.  db_end_trans
1e30: 61 63 74 69 6f 6e 28 30 29 3b 0a 7d 0a 0a 0a 2f  action(0);.}.../
1e40: 2a 0a 2a 2a 20 47 65 74 20 74 68 65 20 63 6f 6e  *.** Get the con
1e50: 74 65 6e 74 73 20 6f 66 20 61 20 66 69 6c 65 20  tents of a file 
1e60: 77 69 74 68 69 6e 20 61 20 67 69 76 65 6e 20 72  within a given r
1e70: 65 76 69 73 69 6f 6e 2e 0a 2a 2f 0a 69 6e 74 20  evision..*/.int 
1e80: 68 69 73 74 6f 72 69 63 61 6c 5f 76 65 72 73 69  historical_versi
1e90: 6f 6e 5f 6f 66 5f 66 69 6c 65 28 0a 20 20 63 6f  on_of_file(.  co
1ea0: 6e 73 74 20 63 68 61 72 20 2a 72 65 76 69 73 69  nst char *revisi
1eb0: 6f 6e 2c 20 20 20 20 2f 2a 20 54 68 65 20 62 61  on,    /* The ba
1ec0: 73 65 6c 69 6e 65 20 6e 61 6d 65 20 63 6f 6e 74  seline name cont
1ed0: 61 69 6e 69 6e 67 20 74 68 65 20 66 69 6c 65 20  aining the file 
1ee0: 2a 2f 0a 20 20 63 6f 6e 73 74 20 63 68 61 72 20  */.  const char 
1ef0: 2a 66 69 6c 65 2c 20 20 20 20 20 20 20 20 2f 2a  *file,        /*
1f00: 20 46 75 6c 6c 20 74 72 65 65 6e 61 6d 65 20 6f   Full treename o
1f10: 66 20 74 68 65 20 66 69 6c 65 20 2a 2f 0a 20 20  f the file */.  
1f20: 42 6c 6f 62 20 2a 63 6f 6e 74 65 6e 74 20 20 20  Blob *content   
1f30: 20 20 20 20 20 20 20 20 20 2f 2a 20 50 75 74 20           /* Put 
1f40: 74 68 65 20 63 6f 6e 74 65 6e 74 20 68 65 72 65  the content here
1f50: 20 2a 2f 0a 29 7b 0a 20 20 42 6c 6f 62 20 6d 66   */.){.  Blob mf
1f60: 69 6c 65 3b 0a 20 20 4d 61 6e 69 66 65 73 74 20  ile;.  Manifest 
1f70: 6d 3b 0a 20 20 69 6e 74 20 69 2c 20 72 69 64 3d  m;.  int i, rid=
1f80: 30 3b 0a 20 20 0a 20 20 72 69 64 20 3d 20 6e 61  0;.  .  rid = na
1f90: 6d 65 5f 74 6f 5f 72 69 64 28 72 65 76 69 73 69  me_to_rid(revisi
1fa0: 6f 6e 29 3b 0a 20 20 63 6f 6e 74 65 6e 74 5f 67  on);.  content_g
1fb0: 65 74 28 72 69 64 2c 20 26 6d 66 69 6c 65 29 3b  et(rid, &mfile);
1fc0: 0a 20 20 0a 20 20 69 66 28 20 6d 61 6e 69 66 65  .  .  if( manife
1fd0: 73 74 5f 70 61 72 73 65 28 26 6d 2c 20 26 6d 66  st_parse(&m, &mf
1fe0: 69 6c 65 29 20 29 7b 0a 20 20 20 20 66 6f 72 28  ile) ){.    for(
1ff0: 69 3d 30 3b 20 69 3c 6d 2e 6e 46 69 6c 65 3b 20  i=0; i<m.nFile; 
2000: 69 2b 2b 29 7b 0a 20 20 20 20 20 20 69 66 28 20  i++){.      if( 
2010: 73 74 72 63 6d 70 28 6d 2e 61 46 69 6c 65 5b 69  strcmp(m.aFile[i
2020: 5d 2e 7a 4e 61 6d 65 2c 20 66 69 6c 65 29 3d 3d  ].zName, file)==
2030: 30 20 29 7b 0a 20 20 20 20 20 20 20 20 72 69 64  0 ){.        rid
2040: 20 3d 20 75 75 69 64 5f 74 6f 5f 72 69 64 28 6d   = uuid_to_rid(m
2050: 2e 61 46 69 6c 65 5b 69 5d 2e 7a 55 75 69 64 2c  .aFile[i].zUuid,
2060: 20 30 29 3b 0a 20 20 20 20 20 20 20 20 72 65 74   0);.        ret
2070: 75 72 6e 20 63 6f 6e 74 65 6e 74 5f 67 65 74 28  urn content_get(
2080: 72 69 64 2c 20 63 6f 6e 74 65 6e 74 29 3b 0a 20  rid, content);. 
2090: 20 20 20 20 20 7d 0a 20 20 20 20 7d 0a 20 20 20       }.    }.   
20a0: 20 66 6f 73 73 69 6c 5f 66 61 74 61 6c 28 22 66   fossil_fatal("f
20b0: 69 6c 65 20 25 73 20 64 6f 65 73 20 6e 6f 74 20  ile %s does not 
20c0: 65 78 69 73 74 20 69 6e 20 62 61 73 65 6c 69 6e  exist in baselin
20d0: 65 3a 20 25 73 22 2c 20 66 69 6c 65 2c 20 72 65  e: %s", file, re
20e0: 76 69 73 69 6f 6e 29 3b 0a 20 20 7d 65 6c 73 65  vision);.  }else
20f0: 7b 0a 20 20 20 20 66 6f 73 73 69 6c 5f 70 61 6e  {.    fossil_pan
2100: 69 63 28 22 63 6f 75 6c 64 20 6e 6f 74 20 70 61  ic("could not pa
2110: 72 73 65 20 6d 61 6e 69 66 65 73 74 20 66 6f 72  rse manifest for
2120: 20 62 61 73 65 6c 69 6e 65 3a 20 25 73 22 2c 20   baseline: %s", 
2130: 72 65 76 69 73 69 6f 6e 29 3b 0a 20 20 7d 0a 20  revision);.  }. 
2140: 20 72 65 74 75 72 6e 20 30 3b 0a 7d 0a 0a 0a 2f   return 0;.}.../
2150: 2a 0a 2a 2a 20 43 4f 4d 4d 41 4e 44 3a 20 72 65  *.** COMMAND: re
2160: 76 65 72 74 0a 2a 2a 0a 2a 2a 20 55 73 61 67 65  vert.**.** Usage
2170: 3a 20 25 66 6f 73 73 69 6c 20 72 65 76 65 72 74  : %fossil revert
2180: 20 3f 2d 2d 79 65 73 3f 20 3f 2d 72 20 52 45 56   ?--yes? ?-r REV
2190: 49 53 49 4f 4e 3f 20 46 49 4c 45 0a 2a 2a 0a 2a  ISION? FILE.**.*
21a0: 2a 20 52 65 76 65 72 74 20 74 6f 20 74 68 65 20  * Revert to the 
21b0: 63 75 72 72 65 6e 74 20 72 65 70 6f 73 69 74 6f  current reposito
21c0: 72 79 20 76 65 72 73 69 6f 6e 20 6f 66 20 46 49  ry version of FI
21d0: 4c 45 2c 20 6f 72 20 74 6f 0a 2a 2a 20 74 68 65  LE, or to.** the
21e0: 20 76 65 72 73 69 6f 6e 20 61 73 73 6f 63 69 61   version associa
21f0: 74 65 64 20 77 69 74 68 20 62 61 73 65 6c 69 6e  ted with baselin
2200: 65 20 52 45 56 49 53 49 4f 4e 20 69 66 20 74 68  e REVISION if th
2210: 65 20 2d 72 20 66 6c 61 67 0a 2a 2a 20 61 70 70  e -r flag.** app
2220: 65 61 72 73 2e 20 20 54 68 69 73 20 63 6f 6d 6d  ears.  This comm
2230: 61 6e 64 20 77 69 6c 6c 20 63 6f 6e 66 69 72 6d  and will confirm
2240: 20 79 6f 75 72 20 6f 70 65 72 61 74 69 6f 6e 20   your operation 
2250: 75 6e 6c 65 73 73 20 74 68 65 0a 2a 2a 20 66 69  unless the.** fi
2260: 6c 65 20 69 73 20 6d 69 73 73 69 6e 67 20 6f 72  le is missing or
2270: 20 74 68 65 20 2d 2d 79 65 73 20 6f 70 74 69 6f   the --yes optio
2280: 6e 20 69 73 20 75 73 65 64 2e 0a 2a 2a 2f 0a 76  n is used..**/.v
2290: 6f 69 64 20 72 65 76 65 72 74 5f 63 6d 64 28 76  oid revert_cmd(v
22a0: 6f 69 64 29 7b 0a 20 20 63 6f 6e 73 74 20 63 68  oid){.  const ch
22b0: 61 72 20 2a 7a 46 69 6c 65 3b 0a 20 20 63 6f 6e  ar *zFile;.  con
22c0: 73 74 20 63 68 61 72 20 2a 7a 52 65 76 69 73 69  st char *zRevisi
22d0: 6f 6e 3b 0a 20 20 42 6c 6f 62 20 66 6e 61 6d 65  on;.  Blob fname
22e0: 3b 0a 20 20 42 6c 6f 62 20 72 65 63 6f 72 64 3b  ;.  Blob record;
22f0: 0a 20 20 42 6c 6f 62 20 61 6e 73 3b 0a 20 20 69  .  Blob ans;.  i
2300: 6e 74 20 72 69 64 20 3d 20 30 2c 20 79 65 73 52  nt rid = 0, yesR
2310: 65 76 65 72 74 3b 0a 20 20 0a 20 20 79 65 73 52  evert;.  .  yesR
2320: 65 76 65 72 74 20 3d 20 66 69 6e 64 5f 6f 70 74  evert = find_opt
2330: 69 6f 6e 28 22 79 65 73 22 2c 20 22 79 22 2c 20  ion("yes", "y", 
2340: 30 29 21 3d 30 3b 0a 20 20 7a 52 65 76 69 73 69  0)!=0;.  zRevisi
2350: 6f 6e 20 3d 20 66 69 6e 64 5f 6f 70 74 69 6f 6e  on = find_option
2360: 28 22 72 65 76 69 73 69 6f 6e 22 2c 20 22 72 22  ("revision", "r"
2370: 2c 20 31 29 3b 0a 20 20 76 65 72 69 66 79 5f 61  , 1);.  verify_a
2380: 6c 6c 5f 6f 70 74 69 6f 6e 73 28 29 3b 0a 20 20  ll_options();.  
2390: 0a 20 20 69 66 28 20 67 2e 61 72 67 63 3c 33 20  .  if( g.argc<3 
23a0: 29 7b 0a 20 20 20 20 75 73 61 67 65 28 22 3f 4f  ){.    usage("?O
23b0: 50 54 49 4f 4e 53 20 46 49 4c 45 22 29 3b 0a 20  PTIONS FILE");. 
23c0: 20 7d 0a 20 20 64 62 5f 6d 75 73 74 5f 62 65 5f   }.  db_must_be_
23d0: 77 69 74 68 69 6e 5f 74 72 65 65 28 29 3b 0a 20  within_tree();. 
23e0: 20 0a 20 20 7a 46 69 6c 65 20 3d 20 6d 70 72 69   .  zFile = mpri
23f0: 6e 74 66 28 22 25 2f 22 2c 20 67 2e 61 72 67 76  ntf("%/", g.argv
2400: 5b 67 2e 61 72 67 63 2d 31 5d 29 3b 0a 0a 20 20  [g.argc-1]);..  
2410: 66 69 6c 65 5f 74 72 65 65 5f 6e 61 6d 65 28 7a  file_tree_name(z
2420: 46 69 6c 65 2c 20 26 66 6e 61 6d 65 29 3b 0a 0a  File, &fname);..
2430: 20 20 69 66 28 20 61 63 63 65 73 73 28 7a 46 69    if( access(zFi
2440: 6c 65 2c 20 30 29 20 29 20 79 65 73 52 65 76 65  le, 0) ) yesReve
2450: 72 74 20 3d 20 31 3b 20 20 0a 20 20 69 66 28 20  rt = 1;  .  if( 
2460: 79 65 73 52 65 76 65 72 74 3d 3d 30 20 29 7b 0a  yesRevert==0 ){.
2470: 20 20 20 20 63 68 61 72 20 2a 70 72 6f 6d 70 74      char *prompt
2480: 20 3d 20 6d 70 72 69 6e 74 66 28 22 72 65 76 65   = mprintf("reve
2490: 72 74 20 66 69 6c 65 20 25 42 3f 20 74 68 69 73  rt file %B? this
24a0: 20 77 69 6c 6c 22 0a 20 20 20 20 20 20 20 20 20   will".         
24b0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
24c0: 20 20 22 20 64 65 73 74 72 6f 79 20 6c 6f 63 61    " destroy loca
24d0: 6c 20 63 68 61 6e 67 65 73 20 5b 79 2f 4e 5d 3f  l changes [y/N]?
24e0: 20 22 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20   ",.            
24f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 26                 &
2500: 66 6e 61 6d 65 29 3b 0a 20 20 20 20 62 6c 6f 62  fname);.    blob
2510: 5f 7a 65 72 6f 28 26 61 6e 73 29 3b 0a 20 20 20  _zero(&ans);.   
2520: 20 70 72 6f 6d 70 74 5f 75 73 65 72 28 70 72 6f   prompt_user(pro
2530: 6d 70 74 2c 20 26 61 6e 73 29 3b 0a 20 20 20 20  mpt, &ans);.    
2540: 66 72 65 65 28 20 70 72 6f 6d 70 74 20 29 3b 0a  free( prompt );.
2550: 20 20 20 20 69 66 28 20 62 6c 6f 62 5f 73 74 72      if( blob_str
2560: 28 26 61 6e 73 29 5b 30 5d 3d 3d 27 79 27 20 29  (&ans)[0]=='y' )
2570: 7b 0a 20 20 20 20 20 20 79 65 73 52 65 76 65 72  {.      yesRever
2580: 74 20 3d 20 31 3b 0a 20 20 20 20 7d 0a 20 20 7d  t = 1;.    }.  }
2590: 0a 0a 20 20 69 66 28 20 79 65 73 52 65 76 65 72  ..  if( yesRever
25a0: 74 3d 3d 31 20 26 26 20 7a 52 65 76 69 73 69 6f  t==1 && zRevisio
25b0: 6e 21 3d 30 20 29 7b 0a 20 20 20 20 68 69 73 74  n!=0 ){.    hist
25c0: 6f 72 69 63 61 6c 5f 76 65 72 73 69 6f 6e 5f 6f  orical_version_o
25d0: 66 5f 66 69 6c 65 28 7a 52 65 76 69 73 69 6f 6e  f_file(zRevision
25e0: 2c 20 7a 46 69 6c 65 2c 20 26 72 65 63 6f 72 64  , zFile, &record
25f0: 29 3b 0a 20 20 7d 65 6c 73 65 20 69 66 28 20 79  );.  }else if( y
2600: 65 73 52 65 76 65 72 74 3d 3d 31 20 29 7b 0a 20  esRevert==1 ){. 
2610: 20 20 20 72 69 64 20 3d 20 64 62 5f 69 6e 74 28     rid = db_int(
2620: 30 2c 20 22 53 45 4c 45 43 54 20 72 69 64 20 46  0, "SELECT rid F
2630: 52 4f 4d 20 76 66 69 6c 65 20 57 48 45 52 45 20  ROM vfile WHERE 
2640: 70 61 74 68 6e 61 6d 65 3d 25 42 22 2c 20 26 66  pathname=%B", &f
2650: 6e 61 6d 65 29 3b 0a 20 20 20 20 69 66 28 20 72  name);.    if( r
2660: 69 64 3d 3d 30 20 29 7b 0a 20 20 20 20 20 20 66  id==0 ){.      f
2670: 6f 73 73 69 6c 5f 70 61 6e 69 63 28 22 6e 6f 20  ossil_panic("no 
2680: 68 69 73 74 6f 72 79 20 66 6f 72 20 66 69 6c 65  history for file
2690: 3a 20 25 62 22 2c 20 26 66 6e 61 6d 65 29 3b 0a  : %b", &fname);.
26a0: 20 20 20 20 7d 0a 20 20 20 20 63 6f 6e 74 65 6e      }.    conten
26b0: 74 5f 67 65 74 28 72 69 64 2c 20 26 72 65 63 6f  t_get(rid, &reco
26c0: 72 64 29 3b 0a 20 20 7d 0a 20 20 0a 20 20 69 66  rd);.  }.  .  if
26d0: 28 20 79 65 73 52 65 76 65 72 74 3d 3d 31 20 29  ( yesRevert==1 )
26e0: 7b 0a 20 20 20 20 62 6c 6f 62 5f 77 72 69 74 65  {.    blob_write
26f0: 5f 74 6f 5f 66 69 6c 65 28 26 72 65 63 6f 72 64  _to_file(&record
2700: 2c 20 7a 46 69 6c 65 29 3b 0a 20 20 20 20 70 72  , zFile);.    pr
2710: 69 6e 74 66 28 22 25 73 20 72 65 76 65 72 74 65  intf("%s reverte
2720: 64 5c 6e 22 2c 20 7a 46 69 6c 65 29 3b 0a 20 20  d\n", zFile);.  
2730: 20 20 62 6c 6f 62 5f 72 65 73 65 74 28 26 72 65    blob_reset(&re
2740: 63 6f 72 64 29 3b 0a 20 20 20 20 62 6c 6f 62 5f  cord);.    blob_
2750: 72 65 73 65 74 28 26 66 6e 61 6d 65 29 3b 0a 20  reset(&fname);. 
2760: 20 7d 65 6c 73 65 7b 0a 20 20 20 20 70 72 69 6e   }else{.    prin
2770: 74 66 28 22 72 65 76 65 72 74 20 63 61 6e 63 65  tf("revert cance
2780: 6c 65 64 5c 6e 22 29 3b 0a 20 20 7d 0a 7d 0a     led\n");.  }.}.