Hex Artifact Content
Not logged in

Artifact 6e48a711267d2bffce4f6a45d09b13e6bf2b4130:

File src/update.c part of check-in [107f38dd01] - Make "revert" complain about excess arguments. Ticket 36d5fbf9a4. by eric on 2009-10-27 20:15:30.

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 75 72 6c 5f 70 72 6f 78 79 5f 6f 70  ..  url_proxy_op
07d0: 74 69 6f 6e 73 28 29 3b 0a 20 20 6c 61 74 65 73  tions();.  lates
07e0: 74 46 6c 61 67 20 3d 20 66 69 6e 64 5f 6f 70 74  tFlag = find_opt
07f0: 69 6f 6e 28 22 6c 61 74 65 73 74 22 2c 30 2c 20  ion("latest",0, 
0800: 30 29 21 3d 30 3b 0a 20 20 66 6f 72 63 65 46 6c  0)!=0;.  forceFl
0810: 61 67 20 3d 20 66 69 6e 64 5f 6f 70 74 69 6f 6e  ag = find_option
0820: 28 22 66 6f 72 63 65 22 2c 22 66 22 2c 30 29 21  ("force","f",0)!
0830: 3d 30 3b 0a 20 20 69 66 28 20 67 2e 61 72 67 63  =0;.  if( g.argc
0840: 21 3d 33 20 26 26 20 67 2e 61 72 67 63 21 3d 32  !=3 && g.argc!=2
0850: 20 29 7b 0a 20 20 20 20 75 73 61 67 65 28 22 3f   ){.    usage("?
0860: 56 45 52 53 49 4f 4e 3f 22 29 3b 0a 20 20 7d 0a  VERSION?");.  }.
0870: 20 20 64 62 5f 6d 75 73 74 5f 62 65 5f 77 69 74    db_must_be_wit
0880: 68 69 6e 5f 74 72 65 65 28 29 3b 0a 20 20 76 69  hin_tree();.  vi
0890: 64 20 3d 20 64 62 5f 6c 67 65 74 5f 69 6e 74 28  d = db_lget_int(
08a0: 22 63 68 65 63 6b 6f 75 74 22 2c 20 30 29 3b 0a  "checkout", 0);.
08b0: 20 20 69 66 28 20 76 69 64 3d 3d 30 20 29 7b 0a    if( vid==0 ){.
08c0: 20 20 20 20 66 6f 73 73 69 6c 5f 66 61 74 61 6c      fossil_fatal
08d0: 28 22 63 61 6e 6e 6f 74 20 66 69 6e 64 20 63 75  ("cannot find cu
08e0: 72 72 65 6e 74 20 76 65 72 73 69 6f 6e 22 29 3b  rrent version");
08f0: 0a 20 20 7d 0a 20 20 69 66 28 20 64 62 5f 65 78  .  }.  if( db_ex
0900: 69 73 74 73 28 22 53 45 4c 45 43 54 20 31 20 46  ists("SELECT 1 F
0910: 52 4f 4d 20 76 6d 65 72 67 65 22 29 20 29 7b 0a  ROM vmerge") ){.
0920: 20 20 20 20 66 6f 73 73 69 6c 5f 66 61 74 61 6c      fossil_fatal
0930: 28 22 63 61 6e 6e 6f 74 20 75 70 64 61 74 65 20  ("cannot update 
0940: 61 6e 20 75 6e 63 6f 6d 6d 69 74 74 65 64 20 6d  an uncommitted m
0950: 65 72 67 65 22 29 3b 0a 20 20 7d 0a 0a 20 20 69  erge");.  }..  i
0960: 66 28 20 67 2e 61 72 67 63 3d 3d 33 20 29 7b 0a  f( g.argc==3 ){.
0970: 20 20 20 20 74 69 64 20 3d 20 6e 61 6d 65 5f 74      tid = name_t
0980: 6f 5f 72 69 64 28 67 2e 61 72 67 76 5b 32 5d 29  o_rid(g.argv[2])
0990: 3b 0a 20 20 20 20 69 66 28 20 74 69 64 3d 3d 30  ;.    if( tid==0
09a0: 20 29 7b 0a 20 20 20 20 20 20 66 6f 73 73 69 6c   ){.      fossil
09b0: 5f 66 61 74 61 6c 28 22 6e 6f 74 20 61 20 76 65  _fatal("not a ve
09c0: 72 73 69 6f 6e 3a 20 25 73 22 2c 20 67 2e 61 72  rsion: %s", g.ar
09d0: 67 76 5b 32 5d 29 3b 0a 20 20 20 20 7d 0a 20 20  gv[2]);.    }.  
09e0: 20 20 69 66 28 20 21 69 73 5f 61 5f 76 65 72 73    if( !is_a_vers
09f0: 69 6f 6e 28 74 69 64 29 20 29 7b 0a 20 20 20 20  ion(tid) ){.    
0a00: 20 20 66 6f 73 73 69 6c 5f 66 61 74 61 6c 28 22    fossil_fatal("
0a10: 6e 6f 74 20 61 20 76 65 72 73 69 6f 6e 3a 20 25  not a version: %
0a20: 73 22 2c 20 67 2e 61 72 67 76 5b 32 5d 29 3b 0a  s", g.argv[2]);.
0a30: 20 20 20 20 7d 0a 20 20 7d 0a 0a 20 20 69 66 28      }.  }..  if(
0a40: 20 74 69 64 3d 3d 30 20 29 7b 0a 20 20 20 20 2f   tid==0 ){.    /
0a50: 2a 20 0a 20 20 20 20 2a 2a 20 44 6f 20 61 6e 20  * .    ** Do an 
0a60: 61 75 74 6f 73 79 6e 63 20 70 75 6c 6c 20 70 72  autosync pull pr
0a70: 69 6f 72 20 74 6f 20 74 68 65 20 75 70 64 61 74  ior to the updat
0a80: 65 2c 20 69 66 20 61 75 74 6f 73 79 6e 63 20 69  e, if autosync i
0a90: 73 20 6f 6e 20 61 6e 64 20 74 68 65 79 0a 20 20  s on and they.  
0aa0: 20 20 2a 2a 20 64 69 64 20 6e 6f 74 20 77 61 6e    ** did not wan
0ab0: 74 20 61 20 73 70 65 63 69 66 69 63 20 76 65 72  t a specific ver
0ac0: 73 69 6f 6e 20 28 69 2e 65 2e 20 61 6e 6f 74 68  sion (i.e. anoth
0ad0: 65 72 20 62 72 61 6e 63 68 2c 20 61 20 70 61 73  er branch, a pas
0ae0: 74 20 72 65 76 69 73 69 6f 6e 29 2e 0a 20 20 20  t revision)..   
0af0: 20 2a 2a 20 42 79 20 6e 6f 74 20 67 69 76 69 6e   ** By not givin
0b00: 67 20 61 20 73 70 65 63 69 66 69 63 20 76 65 72  g a specific ver
0b10: 73 69 6f 6e 2c 20 74 68 65 79 20 61 72 65 20 61  sion, they are a
0b20: 73 6b 69 6e 67 20 66 6f 72 20 74 68 65 20 6c 61  sking for the la
0b30: 74 65 73 74 2c 20 74 68 75 73 0a 20 20 20 20 2a  test, thus.    *
0b40: 2a 20 70 75 6c 6c 20 74 6f 20 67 65 74 20 74 68  * pull to get th
0b50: 65 20 6c 61 74 65 73 74 2c 20 74 68 65 6e 20 75  e latest, then u
0b60: 70 64 61 74 65 2e 0a 20 20 20 20 2a 2f 0a 20 20  pdate..    */.  
0b70: 20 20 61 75 74 6f 73 79 6e 63 28 41 55 54 4f 53    autosync(AUTOS
0b80: 59 4e 43 5f 50 55 4c 4c 29 3b 0a 20 20 7d 0a 20  YNC_PULL);.  }. 
0b90: 20 0a 20 20 69 66 28 20 74 69 64 3d 3d 30 20 29   .  if( tid==0 )
0ba0: 7b 0a 20 20 20 20 63 6f 6d 70 75 74 65 5f 6c 65  {.    compute_le
0bb0: 61 76 65 73 28 76 69 64 2c 20 31 29 3b 0a 20 20  aves(vid, 1);.  
0bc0: 20 20 69 66 28 20 21 6c 61 74 65 73 74 46 6c 61    if( !latestFla
0bd0: 67 20 26 26 20 64 62 5f 69 6e 74 28 30 2c 20 22  g && db_int(0, "
0be0: 53 45 4c 45 43 54 20 63 6f 75 6e 74 28 2a 29 20  SELECT count(*) 
0bf0: 46 52 4f 4d 20 6c 65 61 76 65 73 22 29 3e 31 20  FROM leaves")>1 
0c00: 29 7b 0a 20 20 20 20 20 20 64 62 5f 70 72 65 70  ){.      db_prep
0c10: 61 72 65 28 26 71 2c 20 0a 20 20 20 20 20 20 20  are(&q, .       
0c20: 20 22 25 73 20 22 0a 20 20 20 20 20 20 20 20 22   "%s ".        "
0c30: 20 20 20 41 4e 44 20 65 76 65 6e 74 2e 6f 62 6a     AND event.obj
0c40: 69 64 20 49 4e 20 6c 65 61 76 65 73 22 0a 20 20  id IN leaves".  
0c50: 20 20 20 20 20 20 22 20 4f 52 44 45 52 20 42 59        " ORDER BY
0c60: 20 65 76 65 6e 74 2e 6d 74 69 6d 65 20 44 45 53   event.mtime DES
0c70: 43 22 2c 0a 20 20 20 20 20 20 20 20 74 69 6d 65  C",.        time
0c80: 6c 69 6e 65 5f 71 75 65 72 79 5f 66 6f 72 5f 74  line_query_for_t
0c90: 74 79 28 29 0a 20 20 20 20 20 20 29 3b 0a 20 20  ty().      );.  
0ca0: 20 20 20 20 70 72 69 6e 74 5f 74 69 6d 65 6c 69      print_timeli
0cb0: 6e 65 28 26 71 2c 20 31 30 30 29 3b 0a 20 20 20  ne(&q, 100);.   
0cc0: 20 20 20 64 62 5f 66 69 6e 61 6c 69 7a 65 28 26     db_finalize(&
0cd0: 71 29 3b 0a 20 20 20 20 20 20 66 6f 73 73 69 6c  q);.      fossil
0ce0: 5f 66 61 74 61 6c 28 22 4d 75 6c 74 69 70 6c 65  _fatal("Multiple
0cf0: 20 64 65 73 63 65 6e 64 61 6e 74 73 22 29 3b 0a   descendants");.
0d00: 20 20 20 20 7d 0a 20 20 20 20 74 69 64 20 3d 20      }.    tid = 
0d10: 64 62 5f 69 6e 74 28 30 2c 20 22 53 45 4c 45 43  db_int(0, "SELEC
0d20: 54 20 72 69 64 20 46 52 4f 4d 20 6c 65 61 76 65  T rid FROM leave
0d30: 73 2c 20 65 76 65 6e 74 22 0a 20 20 20 20 20 20  s, event".      
0d40: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 22 20                " 
0d50: 57 48 45 52 45 20 65 76 65 6e 74 2e 6f 62 6a 69  WHERE event.obji
0d60: 64 3d 6c 65 61 76 65 73 2e 72 69 64 22 0a 20 20  d=leaves.rid".  
0d70: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0d80: 20 20 22 20 4f 52 44 45 52 20 42 59 20 65 76 65    " ORDER BY eve
0d90: 6e 74 2e 6d 74 69 6d 65 20 44 45 53 43 22 29 3b  nt.mtime DESC");
0da0: 20 0a 20 20 7d 0a 0a 20 20 64 62 5f 62 65 67 69   .  }..  db_begi
0db0: 6e 5f 74 72 61 6e 73 61 63 74 69 6f 6e 28 29 3b  n_transaction();
0dc0: 0a 20 20 76 66 69 6c 65 5f 63 68 65 63 6b 5f 73  .  vfile_check_s
0dd0: 69 67 6e 61 74 75 72 65 28 76 69 64 29 3b 0a 20  ignature(vid);. 
0de0: 20 75 6e 64 6f 5f 62 65 67 69 6e 28 29 3b 0a 20   undo_begin();. 
0df0: 20 6c 6f 61 64 5f 76 66 69 6c 65 5f 66 72 6f 6d   load_vfile_from
0e00: 5f 72 69 64 28 74 69 64 29 3b 0a 0a 20 20 2f 2a  _rid(tid);..  /*
0e10: 0a 20 20 2a 2a 20 54 68 65 20 72 65 63 6f 72 64  .  ** The record
0e20: 2e 66 6e 20 66 69 65 6c 64 20 69 73 20 75 73 65  .fn field is use
0e30: 64 20 74 6f 20 6d 61 74 63 68 20 66 69 6c 65 73  d to match files
0e40: 20 61 67 61 69 6e 73 74 20 65 61 63 68 20 6f 74   against each ot
0e50: 68 65 72 2e 20 20 54 68 65 0a 20 20 2a 2a 20 46  her.  The.  ** F
0e60: 56 20 74 61 62 6c 65 20 63 6f 6e 74 61 69 6e 73  V table contains
0e70: 20 6f 6e 65 20 72 6f 77 20 66 6f 72 20 65 61 63   one row for eac
0e80: 68 20 65 61 63 68 20 75 6e 69 71 75 65 20 66 69  h each unique fi
0e90: 6c 65 6e 61 6d 65 20 69 6e 0a 20 20 2a 2a 20 69  lename in.  ** i
0ea0: 6e 20 74 68 65 20 63 75 72 72 65 6e 74 20 63 68  n the current ch
0eb0: 65 63 6b 6f 75 74 2c 20 74 68 65 20 70 69 76 6f  eckout, the pivo
0ec0: 74 2c 20 61 6e 64 20 74 68 65 20 76 65 72 73 69  t, and the versi
0ed0: 6f 6e 20 62 65 69 6e 67 20 6d 65 72 67 65 64 2e  on being merged.
0ee0: 0a 20 20 2a 2f 0a 20 20 64 62 5f 6d 75 6c 74 69  .  */.  db_multi
0ef0: 5f 65 78 65 63 28 0a 20 20 20 20 22 44 52 4f 50  _exec(.    "DROP
0f00: 20 54 41 42 4c 45 20 49 46 20 45 58 49 53 54 53   TABLE IF EXISTS
0f10: 20 66 76 3b 22 0a 20 20 20 20 22 43 52 45 41 54   fv;".    "CREAT
0f20: 45 20 54 45 4d 50 20 54 41 42 4c 45 20 66 76 28  E TEMP TABLE fv(
0f30: 22 0a 20 20 20 20 22 20 20 66 6e 20 54 45 58 54  ".    "  fn TEXT
0f40: 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 22 20 20   PRIMARY KEY,"  
0f50: 20 20 20 20 2f 2a 20 54 68 65 20 66 69 6c 65 6e      /* The filen
0f60: 61 6d 65 20 2a 2f 0a 20 20 20 20 22 20 20 69 64  ame */.    "  id
0f70: 76 20 49 4e 54 45 47 45 52 2c 22 20 20 20 20 20  v INTEGER,"     
0f80: 20 20 20 20 20 20 20 20 20 2f 2a 20 56 46 49 4c           /* VFIL
0f90: 45 20 65 6e 74 72 79 20 66 6f 72 20 63 75 72 72  E entry for curr
0fa0: 65 6e 74 20 76 65 72 73 69 6f 6e 20 2a 2f 0a 20  ent version */. 
0fb0: 20 20 20 22 20 20 69 64 74 20 49 4e 54 45 47 45     "  idt INTEGE
0fc0: 52 2c 22 20 20 20 20 20 20 20 20 20 20 20 20 20  R,"             
0fd0: 20 2f 2a 20 56 46 49 4c 45 20 65 6e 74 72 79 20   /* VFILE entry 
0fe0: 66 6f 72 20 74 61 72 67 65 74 20 76 65 72 73 69  for target versi
0ff0: 6f 6e 20 2a 2f 0a 20 20 20 20 22 20 20 63 68 6e  on */.    "  chn
1000: 67 65 64 20 42 4f 4f 4c 45 41 4e 2c 22 20 20 20  ged BOOLEAN,"   
1010: 20 20 20 20 20 20 20 20 2f 2a 20 54 72 75 65 20          /* True 
1020: 69 66 20 63 75 72 72 65 6e 74 20 76 65 72 73 69  if current versi
1030: 6f 6e 20 68 61 73 20 62 65 65 6e 20 65 64 69 74  on has been edit
1040: 65 64 20 2a 2f 0a 20 20 20 20 22 20 20 72 69 64  ed */.    "  rid
1050: 76 20 49 4e 54 45 47 45 52 2c 22 20 20 20 20 20  v INTEGER,"     
1060: 20 20 20 20 20 20 20 20 2f 2a 20 52 65 63 6f 72          /* Recor
1070: 64 20 49 44 20 66 6f 72 20 63 75 72 72 65 6e 74  d ID for current
1080: 20 76 65 72 73 69 6f 6e 20 2a 2f 0a 20 20 20 20   version */.    
1090: 22 20 20 72 69 64 74 20 49 4e 54 45 47 45 52 20  "  ridt INTEGER 
10a0: 22 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a  "             /*
10b0: 20 52 65 63 6f 72 64 20 49 44 20 66 6f 72 20 74   Record ID for t
10c0: 61 72 67 65 74 20 2a 2f 0a 20 20 20 20 22 29 3b  arget */.    ");
10d0: 22 0a 20 20 20 20 22 49 4e 53 45 52 54 20 4f 52  ".    "INSERT OR
10e0: 20 49 47 4e 4f 52 45 20 49 4e 54 4f 20 66 76 22   IGNORE INTO fv"
10f0: 0a 20 20 20 20 22 20 53 45 4c 45 43 54 20 70 61  .    " SELECT pa
1100: 74 68 6e 61 6d 65 2c 20 30 2c 20 30 2c 20 30 2c  thname, 0, 0, 0,
1110: 20 30 2c 20 30 20 46 52 4f 4d 20 76 66 69 6c 65   0, 0 FROM vfile
1120: 22 0a 20 20 29 3b 0a 20 20 64 62 5f 70 72 65 70  ".  );.  db_prep
1130: 61 72 65 28 26 71 2c 0a 20 20 20 20 22 53 45 4c  are(&q,.    "SEL
1140: 45 43 54 20 69 64 2c 20 70 61 74 68 6e 61 6d 65  ECT id, pathname
1150: 2c 20 72 69 64 20 46 52 4f 4d 20 76 66 69 6c 65  , rid FROM vfile
1160: 22 0a 20 20 20 20 22 20 57 48 45 52 45 20 76 69  ".    " WHERE vi
1170: 64 3d 25 64 22 2c 20 74 69 64 0a 20 20 29 3b 0a  d=%d", tid.  );.
1180: 20 20 77 68 69 6c 65 28 20 64 62 5f 73 74 65 70    while( db_step
1190: 28 26 71 29 3d 3d 53 51 4c 49 54 45 5f 52 4f 57  (&q)==SQLITE_ROW
11a0: 20 29 7b 0a 20 20 20 20 69 6e 74 20 69 64 20 3d   ){.    int id =
11b0: 20 64 62 5f 63 6f 6c 75 6d 6e 5f 69 6e 74 28 26   db_column_int(&
11c0: 71 2c 20 30 29 3b 0a 20 20 20 20 63 6f 6e 73 74  q, 0);.    const
11d0: 20 63 68 61 72 20 2a 66 6e 20 3d 20 64 62 5f 63   char *fn = db_c
11e0: 6f 6c 75 6d 6e 5f 74 65 78 74 28 26 71 2c 20 31  olumn_text(&q, 1
11f0: 29 3b 0a 20 20 20 20 69 6e 74 20 72 69 64 20 3d  );.    int rid =
1200: 20 64 62 5f 63 6f 6c 75 6d 6e 5f 69 6e 74 28 26   db_column_int(&
1210: 71 2c 20 32 29 3b 0a 20 20 20 20 64 62 5f 6d 75  q, 2);.    db_mu
1220: 6c 74 69 5f 65 78 65 63 28 0a 20 20 20 20 20 20  lti_exec(.      
1230: 22 55 50 44 41 54 45 20 66 76 20 53 45 54 20 69  "UPDATE fv SET i
1240: 64 74 3d 25 64 2c 20 72 69 64 74 3d 25 64 20 57  dt=%d, ridt=%d W
1250: 48 45 52 45 20 66 6e 3d 25 51 22 2c 0a 20 20 20  HERE fn=%Q",.   
1260: 20 20 20 69 64 2c 20 72 69 64 2c 20 66 6e 0a 20     id, rid, fn. 
1270: 20 20 20 29 3b 0a 20 20 7d 0a 20 20 64 62 5f 66     );.  }.  db_f
1280: 69 6e 61 6c 69 7a 65 28 26 71 29 3b 0a 20 20 64  inalize(&q);.  d
1290: 62 5f 70 72 65 70 61 72 65 28 26 71 2c 0a 20 20  b_prepare(&q,.  
12a0: 20 20 22 53 45 4c 45 43 54 20 69 64 2c 20 70 61    "SELECT id, pa
12b0: 74 68 6e 61 6d 65 2c 20 72 69 64 2c 20 63 68 6e  thname, rid, chn
12c0: 67 65 64 20 46 52 4f 4d 20 76 66 69 6c 65 22 0a  ged FROM vfile".
12d0: 20 20 20 20 22 20 57 48 45 52 45 20 76 69 64 3d      " WHERE vid=
12e0: 25 64 22 2c 20 76 69 64 0a 20 20 29 3b 0a 20 20  %d", vid.  );.  
12f0: 77 68 69 6c 65 28 20 64 62 5f 73 74 65 70 28 26  while( db_step(&
1300: 71 29 3d 3d 53 51 4c 49 54 45 5f 52 4f 57 20 29  q)==SQLITE_ROW )
1310: 7b 0a 20 20 20 20 69 6e 74 20 69 64 20 3d 20 64  {.    int id = d
1320: 62 5f 63 6f 6c 75 6d 6e 5f 69 6e 74 28 26 71 2c  b_column_int(&q,
1330: 20 30 29 3b 0a 20 20 20 20 63 6f 6e 73 74 20 63   0);.    const c
1340: 68 61 72 20 2a 66 6e 20 3d 20 64 62 5f 63 6f 6c  har *fn = db_col
1350: 75 6d 6e 5f 74 65 78 74 28 26 71 2c 20 31 29 3b  umn_text(&q, 1);
1360: 0a 20 20 20 20 69 6e 74 20 72 69 64 20 3d 20 64  .    int rid = d
1370: 62 5f 63 6f 6c 75 6d 6e 5f 69 6e 74 28 26 71 2c  b_column_int(&q,
1380: 20 32 29 3b 0a 20 20 20 20 69 6e 74 20 63 68 6e   2);.    int chn
1390: 67 65 64 20 3d 20 64 62 5f 63 6f 6c 75 6d 6e 5f  ged = db_column_
13a0: 69 6e 74 28 26 71 2c 20 33 29 3b 0a 20 20 20 20  int(&q, 3);.    
13b0: 64 62 5f 6d 75 6c 74 69 5f 65 78 65 63 28 0a 20  db_multi_exec(. 
13c0: 20 20 20 20 20 22 55 50 44 41 54 45 20 66 76 20       "UPDATE fv 
13d0: 53 45 54 20 69 64 76 3d 25 64 2c 20 72 69 64 76  SET idv=%d, ridv
13e0: 3d 25 64 2c 20 63 68 6e 67 65 64 3d 25 64 20 57  =%d, chnged=%d W
13f0: 48 45 52 45 20 66 6e 3d 25 51 22 2c 0a 20 20 20  HERE fn=%Q",.   
1400: 20 20 20 69 64 2c 20 72 69 64 2c 20 63 68 6e 67     id, rid, chng
1410: 65 64 2c 20 66 6e 0a 20 20 20 20 29 3b 0a 20 20  ed, fn.    );.  
1420: 7d 0a 20 20 64 62 5f 66 69 6e 61 6c 69 7a 65 28  }.  db_finalize(
1430: 26 71 29 3b 0a 0a 20 20 64 62 5f 70 72 65 70 61  &q);..  db_prepa
1440: 72 65 28 26 71 2c 20 0a 20 20 20 20 22 53 45 4c  re(&q, .    "SEL
1450: 45 43 54 20 66 6e 2c 20 69 64 76 2c 20 72 69 64  ECT fn, idv, rid
1460: 76 2c 20 69 64 74 2c 20 72 69 64 74 2c 20 63 68  v, idt, ridt, ch
1470: 6e 67 65 64 20 46 52 4f 4d 20 66 76 20 4f 52 44  nged FROM fv ORD
1480: 45 52 20 42 59 20 31 22 0a 20 20 29 3b 0a 20 20  ER BY 1".  );.  
1490: 77 68 69 6c 65 28 20 64 62 5f 73 74 65 70 28 26  while( db_step(&
14a0: 71 29 3d 3d 53 51 4c 49 54 45 5f 52 4f 57 20 29  q)==SQLITE_ROW )
14b0: 7b 0a 20 20 20 20 63 6f 6e 73 74 20 63 68 61 72  {.    const char
14c0: 20 2a 7a 4e 61 6d 65 20 3d 20 64 62 5f 63 6f 6c   *zName = db_col
14d0: 75 6d 6e 5f 74 65 78 74 28 26 71 2c 20 30 29 3b  umn_text(&q, 0);
14e0: 0a 20 20 20 20 69 6e 74 20 69 64 76 20 3d 20 64  .    int idv = d
14f0: 62 5f 63 6f 6c 75 6d 6e 5f 69 6e 74 28 26 71 2c  b_column_int(&q,
1500: 20 31 29 3b 0a 20 20 20 20 69 6e 74 20 72 69 64   1);.    int rid
1510: 76 20 3d 20 64 62 5f 63 6f 6c 75 6d 6e 5f 69 6e  v = db_column_in
1520: 74 28 26 71 2c 20 32 29 3b 0a 20 20 20 20 69 6e  t(&q, 2);.    in
1530: 74 20 69 64 74 20 3d 20 64 62 5f 63 6f 6c 75 6d  t idt = db_colum
1540: 6e 5f 69 6e 74 28 26 71 2c 20 33 29 3b 0a 20 20  n_int(&q, 3);.  
1550: 20 20 69 6e 74 20 72 69 64 74 20 3d 20 64 62 5f    int ridt = db_
1560: 63 6f 6c 75 6d 6e 5f 69 6e 74 28 26 71 2c 20 34  column_int(&q, 4
1570: 29 3b 0a 20 20 20 20 69 6e 74 20 63 68 6e 67 65  );.    int chnge
1580: 64 20 3d 20 64 62 5f 63 6f 6c 75 6d 6e 5f 69 6e  d = db_column_in
1590: 74 28 26 71 2c 20 35 29 3b 0a 0a 20 20 20 20 69  t(&q, 5);..    i
15a0: 66 28 20 69 64 76 3e 30 20 26 26 20 72 69 64 76  f( idv>0 && ridv
15b0: 3d 3d 30 20 26 26 20 69 64 74 3e 30 20 29 7b 0a  ==0 && idt>0 ){.
15c0: 20 20 20 20 20 20 2f 2a 20 43 6f 6e 66 6c 69 63        /* Conflic
15d0: 74 2e 20 20 54 68 69 73 20 66 69 6c 65 20 68 61  t.  This file ha
15e0: 73 20 62 65 65 6e 20 61 64 64 65 64 20 74 6f 20  s been added to 
15f0: 74 68 65 20 63 75 72 72 65 6e 74 20 63 68 65 63  the current chec
1600: 6b 6f 75 74 0a 20 20 20 20 20 20 2a 2a 20 62 75  kout.      ** bu
1610: 74 20 61 6c 73 6f 20 65 78 69 73 74 73 20 69 6e  t also exists in
1620: 20 74 68 65 20 74 61 72 67 65 74 20 63 68 65 63   the target chec
1630: 6b 6f 75 74 2e 20 20 55 73 65 20 74 68 65 20 63  kout.  Use the c
1640: 75 72 72 65 6e 74 20 76 65 72 73 69 6f 6e 2e 0a  urrent version..
1650: 20 20 20 20 20 20 2a 2f 0a 20 20 20 20 20 20 70        */.      p
1660: 72 69 6e 74 66 28 22 43 4f 4e 46 4c 49 43 54 20  rintf("CONFLICT 
1670: 25 73 5c 6e 22 2c 20 7a 4e 61 6d 65 29 3b 0a 20  %s\n", zName);. 
1680: 20 20 20 7d 65 6c 73 65 20 69 66 28 20 69 64 74     }else if( idt
1690: 3e 30 20 26 26 20 69 64 76 3d 3d 30 20 29 7b 0a  >0 && idv==0 ){.
16a0: 20 20 20 20 20 20 2f 2a 20 46 69 6c 65 20 61 64        /* File ad
16b0: 64 65 64 20 69 6e 20 74 68 65 20 74 61 72 67 65  ded in the targe
16c0: 74 2e 20 2a 2f 0a 20 20 20 20 20 20 70 72 69 6e  t. */.      prin
16d0: 74 66 28 22 41 44 44 20 25 73 5c 6e 22 2c 20 7a  tf("ADD %s\n", z
16e0: 4e 61 6d 65 29 3b 0a 20 20 20 20 20 20 75 6e 64  Name);.      und
16f0: 6f 5f 73 61 76 65 28 7a 4e 61 6d 65 29 3b 0a 20  o_save(zName);. 
1700: 20 20 20 20 20 76 66 69 6c 65 5f 74 6f 5f 64 69       vfile_to_di
1710: 73 6b 28 30 2c 20 69 64 74 2c 20 30 29 3b 0a 20  sk(0, idt, 0);. 
1720: 20 20 20 7d 65 6c 73 65 20 69 66 28 20 69 64 74     }else if( idt
1730: 3e 30 20 26 26 20 69 64 76 3e 30 20 26 26 20 72  >0 && idv>0 && r
1740: 69 64 74 21 3d 72 69 64 76 20 26 26 20 63 68 6e  idt!=ridv && chn
1750: 67 65 64 3d 3d 30 20 29 7b 0a 20 20 20 20 20 20  ged==0 ){.      
1760: 2f 2a 20 54 68 65 20 66 69 6c 65 20 69 73 20 75  /* The file is u
1770: 6e 65 64 69 74 65 64 2e 20 20 43 68 61 6e 67 65  nedited.  Change
1780: 20 69 74 20 74 6f 20 74 68 65 20 74 61 72 67 65   it to the targe
1790: 74 20 76 65 72 73 69 6f 6e 20 2a 2f 0a 20 20 20  t version */.   
17a0: 20 20 20 70 72 69 6e 74 66 28 22 55 50 44 41 54     printf("UPDAT
17b0: 45 20 25 73 5c 6e 22 2c 20 7a 4e 61 6d 65 29 3b  E %s\n", zName);
17c0: 0a 20 20 20 20 20 20 75 6e 64 6f 5f 73 61 76 65  .      undo_save
17d0: 28 7a 4e 61 6d 65 29 3b 0a 20 20 20 20 20 20 76  (zName);.      v
17e0: 66 69 6c 65 5f 74 6f 5f 64 69 73 6b 28 30 2c 20  file_to_disk(0, 
17f0: 69 64 74 2c 20 30 29 3b 0a 20 20 20 20 7d 65 6c  idt, 0);.    }el
1800: 73 65 20 69 66 28 20 69 64 74 3d 3d 30 20 26 26  se if( idt==0 &&
1810: 20 69 64 76 3e 30 20 29 7b 0a 20 20 20 20 20 20   idv>0 ){.      
1820: 69 66 28 20 72 69 64 76 3d 3d 30 20 29 7b 0a 20  if( ridv==0 ){. 
1830: 20 20 20 20 20 20 20 2f 2a 20 41 64 64 65 64 20         /* Added 
1840: 69 6e 20 63 75 72 72 65 6e 74 20 63 68 65 63 6b  in current check
1850: 6f 75 74 2e 20 20 43 6f 6e 74 69 6e 75 65 20 74  out.  Continue t
1860: 6f 20 68 6f 6c 64 20 74 68 65 20 66 69 6c 65 20  o hold the file 
1870: 61 73 0a 20 20 20 20 20 20 20 20 2a 2a 20 61 73  as.        ** as
1880: 20 61 6e 20 61 64 64 69 74 69 6f 6e 20 2a 2f 0a   an addition */.
1890: 20 20 20 20 20 20 20 20 64 62 5f 6d 75 6c 74 69          db_multi
18a0: 5f 65 78 65 63 28 22 55 50 44 41 54 45 20 76 66  _exec("UPDATE vf
18b0: 69 6c 65 20 53 45 54 20 76 69 64 3d 25 64 20 57  ile SET vid=%d W
18c0: 48 45 52 45 20 69 64 3d 25 64 22 2c 20 74 69 64  HERE id=%d", tid
18d0: 2c 20 69 64 76 29 3b 0a 20 20 20 20 20 20 7d 65  , idv);.      }e
18e0: 6c 73 65 20 69 66 28 20 63 68 6e 67 65 64 20 29  lse if( chnged )
18f0: 7b 0a 20 20 20 20 20 20 20 20 70 72 69 6e 74 66  {.        printf
1900: 28 22 43 4f 4e 46 4c 49 43 54 20 25 73 5c 6e 22  ("CONFLICT %s\n"
1910: 2c 20 7a 4e 61 6d 65 29 3b 0a 20 20 20 20 20 20  , zName);.      
1920: 7d 65 6c 73 65 7b 0a 20 20 20 20 20 20 20 20 63  }else{.        c
1930: 68 61 72 20 2a 7a 46 75 6c 6c 50 61 74 68 3b 0a  har *zFullPath;.
1940: 20 20 20 20 20 20 20 20 70 72 69 6e 74 66 28 22          printf("
1950: 52 45 4d 4f 56 45 20 25 73 5c 6e 22 2c 20 7a 4e  REMOVE %s\n", zN
1960: 61 6d 65 29 3b 0a 20 20 20 20 20 20 20 20 75 6e  ame);.        un
1970: 64 6f 5f 73 61 76 65 28 7a 4e 61 6d 65 29 3b 0a  do_save(zName);.
1980: 20 20 20 20 20 20 20 20 7a 46 75 6c 6c 50 61 74          zFullPat
1990: 68 20 3d 20 6d 70 72 69 6e 74 66 28 22 25 73 2f  h = mprintf("%s/
19a0: 25 73 22 2c 20 67 2e 7a 4c 6f 63 61 6c 52 6f 6f  %s", g.zLocalRoo
19b0: 74 2c 20 7a 4e 61 6d 65 29 3b 0a 20 20 20 20 20  t, zName);.     
19c0: 20 20 20 75 6e 6c 69 6e 6b 28 7a 46 75 6c 6c 50     unlink(zFullP
19d0: 61 74 68 29 3b 0a 20 20 20 20 20 20 20 20 66 72  ath);.        fr
19e0: 65 65 28 7a 46 75 6c 6c 50 61 74 68 29 3b 0a 20  ee(zFullPath);. 
19f0: 20 20 20 20 20 7d 0a 20 20 20 20 7d 65 6c 73 65       }.    }else
1a00: 20 69 66 28 20 69 64 74 3e 30 20 26 26 20 69 64   if( idt>0 && id
1a10: 76 3e 30 20 26 26 20 72 69 64 74 21 3d 72 69 64  v>0 && ridt!=rid
1a20: 76 20 26 26 20 63 68 6e 67 65 64 20 29 7b 0a 20  v && chnged ){. 
1a30: 20 20 20 20 20 2f 2a 20 4d 65 72 67 65 20 74 68       /* Merge th
1a40: 65 20 63 68 61 6e 67 65 73 20 69 6e 20 74 68 65  e changes in the
1a50: 20 63 75 72 72 65 6e 74 20 74 72 65 65 20 69 6e   current tree in
1a60: 74 6f 20 74 68 65 20 74 61 72 67 65 74 20 76 65  to the target ve
1a70: 72 73 69 6f 6e 20 2a 2f 0a 20 20 20 20 20 20 42  rsion */.      B
1a80: 6c 6f 62 20 65 2c 20 72 2c 20 74 2c 20 76 3b 0a  lob e, r, t, v;.
1a90: 20 20 20 20 20 20 69 6e 74 20 72 63 3b 0a 20 20        int rc;.  
1aa0: 20 20 20 20 63 68 61 72 20 2a 7a 46 75 6c 6c 50      char *zFullP
1ab0: 61 74 68 3b 0a 20 20 20 20 20 20 70 72 69 6e 74  ath;.      print
1ac0: 66 28 22 4d 45 52 47 45 20 25 73 5c 6e 22 2c 20  f("MERGE %s\n", 
1ad0: 7a 4e 61 6d 65 29 3b 0a 20 20 20 20 20 20 75 6e  zName);.      un
1ae0: 64 6f 5f 73 61 76 65 28 7a 4e 61 6d 65 29 3b 0a  do_save(zName);.
1af0: 20 20 20 20 20 20 7a 46 75 6c 6c 50 61 74 68 20        zFullPath 
1b00: 3d 20 6d 70 72 69 6e 74 66 28 22 25 73 2f 25 73  = mprintf("%s/%s
1b10: 22 2c 20 67 2e 7a 4c 6f 63 61 6c 52 6f 6f 74 2c  ", g.zLocalRoot,
1b20: 20 7a 4e 61 6d 65 29 3b 0a 20 20 20 20 20 20 63   zName);.      c
1b30: 6f 6e 74 65 6e 74 5f 67 65 74 28 72 69 64 74 2c  ontent_get(ridt,
1b40: 20 26 74 29 3b 0a 20 20 20 20 20 20 63 6f 6e 74   &t);.      cont
1b50: 65 6e 74 5f 67 65 74 28 72 69 64 76 2c 20 26 76  ent_get(ridv, &v
1b60: 29 3b 0a 20 20 20 20 20 20 62 6c 6f 62 5f 7a 65  );.      blob_ze
1b70: 72 6f 28 26 65 29 3b 0a 20 20 20 20 20 20 62 6c  ro(&e);.      bl
1b80: 6f 62 5f 72 65 61 64 5f 66 72 6f 6d 5f 66 69 6c  ob_read_from_fil
1b90: 65 28 26 65 2c 20 7a 46 75 6c 6c 50 61 74 68 29  e(&e, zFullPath)
1ba0: 3b 0a 20 20 20 20 20 20 72 63 20 3d 20 62 6c 6f  ;.      rc = blo
1bb0: 62 5f 6d 65 72 67 65 28 26 76 2c 20 26 65 2c 20  b_merge(&v, &e, 
1bc0: 26 74 2c 20 26 72 29 3b 0a 20 20 20 20 20 20 69  &t, &r);.      i
1bd0: 66 28 20 72 63 3e 3d 30 20 29 7b 0a 20 20 20 20  f( rc>=0 ){.    
1be0: 20 20 20 20 62 6c 6f 62 5f 77 72 69 74 65 5f 74      blob_write_t
1bf0: 6f 5f 66 69 6c 65 28 26 72 2c 20 7a 46 75 6c 6c  o_file(&r, zFull
1c00: 50 61 74 68 29 3b 0a 20 20 20 20 20 20 20 20 69  Path);.        i
1c10: 66 28 20 72 63 3e 30 20 29 7b 0a 20 20 20 20 20  f( rc>0 ){.     
1c20: 20 20 20 20 20 70 72 69 6e 74 66 28 22 2a 2a 2a       printf("***
1c30: 2a 2a 20 25 64 20 6d 65 72 67 65 20 63 6f 6e 66  ** %d merge conf
1c40: 6c 69 63 74 73 20 69 6e 20 25 73 5c 6e 22 2c 20  licts in %s\n", 
1c50: 72 63 2c 20 7a 4e 61 6d 65 29 3b 0a 20 20 20 20  rc, zName);.    
1c60: 20 20 20 20 7d 0a 20 20 20 20 20 20 7d 65 6c 73      }.      }els
1c70: 65 7b 0a 20 20 20 20 20 20 20 20 70 72 69 6e 74  e{.        print
1c80: 66 28 22 2a 2a 2a 2a 2a 20 43 61 6e 6e 6f 74 20  f("***** Cannot 
1c90: 6d 65 72 67 65 20 62 69 6e 61 72 79 20 66 69 6c  merge binary fil
1ca0: 65 20 25 73 5c 6e 22 2c 20 7a 4e 61 6d 65 29 3b  e %s\n", zName);
1cb0: 0a 20 20 20 20 20 20 7d 0a 20 20 20 20 20 20 66  .      }.      f
1cc0: 72 65 65 28 7a 46 75 6c 6c 50 61 74 68 29 3b 0a  ree(zFullPath);.
1cd0: 20 20 20 20 20 20 62 6c 6f 62 5f 72 65 73 65 74        blob_reset
1ce0: 28 26 76 29 3b 0a 20 20 20 20 20 20 62 6c 6f 62  (&v);.      blob
1cf0: 5f 72 65 73 65 74 28 26 65 29 3b 0a 20 20 20 20  _reset(&e);.    
1d00: 20 20 62 6c 6f 62 5f 72 65 73 65 74 28 26 74 29    blob_reset(&t)
1d10: 3b 0a 20 20 20 20 20 20 62 6c 6f 62 5f 72 65 73  ;.      blob_res
1d20: 65 74 28 26 72 29 3b 0a 20 20 20 20 20 20 0a 20  et(&r);.      . 
1d30: 20 20 20 7d 0a 20 20 7d 0a 20 20 64 62 5f 66 69     }.  }.  db_fi
1d40: 6e 61 6c 69 7a 65 28 26 71 29 3b 0a 20 20 0a 20  nalize(&q);.  . 
1d50: 20 2f 2a 0a 20 20 2a 2a 20 43 6c 65 61 6e 20 75   /*.  ** Clean u
1d60: 70 20 74 68 65 20 6d 69 64 20 61 6e 64 20 70 69  p the mid and pi
1d70: 64 20 56 46 49 4c 45 20 65 6e 74 72 69 65 73 2e  d VFILE entries.
1d80: 20 20 54 68 65 6e 20 63 6f 6d 6d 69 74 20 74 68    Then commit th
1d90: 65 20 63 68 61 6e 67 65 73 2e 0a 20 20 2a 2f 0a  e changes..  */.
1da0: 20 20 64 62 5f 6d 75 6c 74 69 5f 65 78 65 63 28    db_multi_exec(
1db0: 22 44 45 4c 45 54 45 20 46 52 4f 4d 20 76 66 69  "DELETE FROM vfi
1dc0: 6c 65 20 57 48 45 52 45 20 76 69 64 21 3d 25 64  le WHERE vid!=%d
1dd0: 22 2c 20 74 69 64 29 3b 0a 20 20 6d 61 6e 69 66  ", tid);.  manif
1de0: 65 73 74 5f 74 6f 5f 64 69 73 6b 28 74 69 64 29  est_to_disk(tid)
1df0: 3b 0a 20 20 64 62 5f 6c 73 65 74 5f 69 6e 74 28  ;.  db_lset_int(
1e00: 22 63 68 65 63 6b 6f 75 74 22 2c 20 74 69 64 29  "checkout", tid)
1e10: 3b 0a 20 20 64 62 5f 65 6e 64 5f 74 72 61 6e 73  ;.  db_end_trans
1e20: 61 63 74 69 6f 6e 28 30 29 3b 0a 7d 0a 0a 0a 2f  action(0);.}.../
1e30: 2a 0a 2a 2a 20 47 65 74 20 74 68 65 20 63 6f 6e  *.** Get the con
1e40: 74 65 6e 74 73 20 6f 66 20 61 20 66 69 6c 65 20  tents of a file 
1e50: 77 69 74 68 69 6e 20 61 20 67 69 76 65 6e 20 72  within a given r
1e60: 65 76 69 73 69 6f 6e 2e 0a 2a 2f 0a 69 6e 74 20  evision..*/.int 
1e70: 68 69 73 74 6f 72 69 63 61 6c 5f 76 65 72 73 69  historical_versi
1e80: 6f 6e 5f 6f 66 5f 66 69 6c 65 28 0a 20 20 63 6f  on_of_file(.  co
1e90: 6e 73 74 20 63 68 61 72 20 2a 72 65 76 69 73 69  nst char *revisi
1ea0: 6f 6e 2c 20 20 20 20 2f 2a 20 54 68 65 20 62 61  on,    /* The ba
1eb0: 73 65 6c 69 6e 65 20 6e 61 6d 65 20 63 6f 6e 74  seline name cont
1ec0: 61 69 6e 69 6e 67 20 74 68 65 20 66 69 6c 65 20  aining the file 
1ed0: 2a 2f 0a 20 20 63 6f 6e 73 74 20 63 68 61 72 20  */.  const char 
1ee0: 2a 66 69 6c 65 2c 20 20 20 20 20 20 20 20 2f 2a  *file,        /*
1ef0: 20 46 75 6c 6c 20 74 72 65 65 6e 61 6d 65 20 6f   Full treename o
1f00: 66 20 74 68 65 20 66 69 6c 65 20 2a 2f 0a 20 20  f the file */.  
1f10: 42 6c 6f 62 20 2a 63 6f 6e 74 65 6e 74 20 20 20  Blob *content   
1f20: 20 20 20 20 20 20 20 20 20 2f 2a 20 50 75 74 20           /* Put 
1f30: 74 68 65 20 63 6f 6e 74 65 6e 74 20 68 65 72 65  the content here
1f40: 20 2a 2f 0a 29 7b 0a 20 20 42 6c 6f 62 20 6d 66   */.){.  Blob mf
1f50: 69 6c 65 3b 0a 20 20 4d 61 6e 69 66 65 73 74 20  ile;.  Manifest 
1f60: 6d 3b 0a 20 20 69 6e 74 20 69 2c 20 72 69 64 3d  m;.  int i, rid=
1f70: 30 3b 0a 20 20 0a 20 20 72 69 64 20 3d 20 6e 61  0;.  .  rid = na
1f80: 6d 65 5f 74 6f 5f 72 69 64 28 72 65 76 69 73 69  me_to_rid(revisi
1f90: 6f 6e 29 3b 0a 20 20 63 6f 6e 74 65 6e 74 5f 67  on);.  content_g
1fa0: 65 74 28 72 69 64 2c 20 26 6d 66 69 6c 65 29 3b  et(rid, &mfile);
1fb0: 0a 20 20 0a 20 20 69 66 28 20 6d 61 6e 69 66 65  .  .  if( manife
1fc0: 73 74 5f 70 61 72 73 65 28 26 6d 2c 20 26 6d 66  st_parse(&m, &mf
1fd0: 69 6c 65 29 20 29 7b 0a 20 20 20 20 66 6f 72 28  ile) ){.    for(
1fe0: 69 3d 30 3b 20 69 3c 6d 2e 6e 46 69 6c 65 3b 20  i=0; i<m.nFile; 
1ff0: 69 2b 2b 29 7b 0a 20 20 20 20 20 20 69 66 28 20  i++){.      if( 
2000: 73 74 72 63 6d 70 28 6d 2e 61 46 69 6c 65 5b 69  strcmp(m.aFile[i
2010: 5d 2e 7a 4e 61 6d 65 2c 20 66 69 6c 65 29 3d 3d  ].zName, file)==
2020: 30 20 29 7b 0a 20 20 20 20 20 20 20 20 72 69 64  0 ){.        rid
2030: 20 3d 20 75 75 69 64 5f 74 6f 5f 72 69 64 28 6d   = uuid_to_rid(m
2040: 2e 61 46 69 6c 65 5b 69 5d 2e 7a 55 75 69 64 2c  .aFile[i].zUuid,
2050: 20 30 29 3b 0a 20 20 20 20 20 20 20 20 72 65 74   0);.        ret
2060: 75 72 6e 20 63 6f 6e 74 65 6e 74 5f 67 65 74 28  urn content_get(
2070: 72 69 64 2c 20 63 6f 6e 74 65 6e 74 29 3b 0a 20  rid, content);. 
2080: 20 20 20 20 20 7d 0a 20 20 20 20 7d 0a 20 20 20       }.    }.   
2090: 20 66 6f 73 73 69 6c 5f 66 61 74 61 6c 28 22 66   fossil_fatal("f
20a0: 69 6c 65 20 25 73 20 64 6f 65 73 20 6e 6f 74 20  ile %s does not 
20b0: 65 78 69 73 74 20 69 6e 20 62 61 73 65 6c 69 6e  exist in baselin
20c0: 65 3a 20 25 73 22 2c 20 66 69 6c 65 2c 20 72 65  e: %s", file, re
20d0: 76 69 73 69 6f 6e 29 3b 0a 20 20 7d 65 6c 73 65  vision);.  }else
20e0: 7b 0a 20 20 20 20 66 6f 73 73 69 6c 5f 70 61 6e  {.    fossil_pan
20f0: 69 63 28 22 63 6f 75 6c 64 20 6e 6f 74 20 70 61  ic("could not pa
2100: 72 73 65 20 6d 61 6e 69 66 65 73 74 20 66 6f 72  rse manifest for
2110: 20 62 61 73 65 6c 69 6e 65 3a 20 25 73 22 2c 20   baseline: %s", 
2120: 72 65 76 69 73 69 6f 6e 29 3b 0a 20 20 7d 0a 20  revision);.  }. 
2130: 20 72 65 74 75 72 6e 20 30 3b 0a 7d 0a 0a 0a 2f   return 0;.}.../
2140: 2a 0a 2a 2a 20 43 4f 4d 4d 41 4e 44 3a 20 72 65  *.** COMMAND: re
2150: 76 65 72 74 0a 2a 2a 0a 2a 2a 20 55 73 61 67 65  vert.**.** Usage
2160: 3a 20 25 66 6f 73 73 69 6c 20 72 65 76 65 72 74  : %fossil revert
2170: 20 3f 2d 2d 79 65 73 3f 20 3f 2d 72 20 52 45 56   ?--yes? ?-r REV
2180: 49 53 49 4f 4e 3f 20 46 49 4c 45 0a 2a 2a 0a 2a  ISION? FILE.**.*
2190: 2a 20 52 65 76 65 72 74 20 74 6f 20 74 68 65 20  * Revert to the 
21a0: 63 75 72 72 65 6e 74 20 72 65 70 6f 73 69 74 6f  current reposito
21b0: 72 79 20 76 65 72 73 69 6f 6e 20 6f 66 20 46 49  ry version of FI
21c0: 4c 45 2c 20 6f 72 20 74 6f 0a 2a 2a 20 74 68 65  LE, or to.** the
21d0: 20 76 65 72 73 69 6f 6e 20 61 73 73 6f 63 69 61   version associa
21e0: 74 65 64 20 77 69 74 68 20 62 61 73 65 6c 69 6e  ted with baselin
21f0: 65 20 52 45 56 49 53 49 4f 4e 20 69 66 20 74 68  e REVISION if th
2200: 65 20 2d 72 20 66 6c 61 67 0a 2a 2a 20 61 70 70  e -r flag.** app
2210: 65 61 72 73 2e 20 20 54 68 69 73 20 63 6f 6d 6d  ears.  This comm
2220: 61 6e 64 20 77 69 6c 6c 20 63 6f 6e 66 69 72 6d  and will confirm
2230: 20 79 6f 75 72 20 6f 70 65 72 61 74 69 6f 6e 20   your operation 
2240: 75 6e 6c 65 73 73 20 74 68 65 0a 2a 2a 20 66 69  unless the.** fi
2250: 6c 65 20 69 73 20 6d 69 73 73 69 6e 67 20 6f 72  le is missing or
2260: 20 74 68 65 20 2d 2d 79 65 73 20 6f 70 74 69 6f   the --yes optio
2270: 6e 20 69 73 20 75 73 65 64 2e 0a 2a 2a 2f 0a 76  n is used..**/.v
2280: 6f 69 64 20 72 65 76 65 72 74 5f 63 6d 64 28 76  oid revert_cmd(v
2290: 6f 69 64 29 7b 0a 20 20 63 6f 6e 73 74 20 63 68  oid){.  const ch
22a0: 61 72 20 2a 7a 46 69 6c 65 3b 0a 20 20 63 6f 6e  ar *zFile;.  con
22b0: 73 74 20 63 68 61 72 20 2a 7a 52 65 76 69 73 69  st char *zRevisi
22c0: 6f 6e 3b 0a 20 20 42 6c 6f 62 20 66 6e 61 6d 65  on;.  Blob fname
22d0: 3b 0a 20 20 42 6c 6f 62 20 72 65 63 6f 72 64 3b  ;.  Blob record;
22e0: 0a 20 20 42 6c 6f 62 20 61 6e 73 3b 0a 20 20 69  .  Blob ans;.  i
22f0: 6e 74 20 72 69 64 20 3d 20 30 2c 20 79 65 73 52  nt rid = 0, yesR
2300: 65 76 65 72 74 3b 0a 20 20 0a 20 20 79 65 73 52  evert;.  .  yesR
2310: 65 76 65 72 74 20 3d 20 66 69 6e 64 5f 6f 70 74  evert = find_opt
2320: 69 6f 6e 28 22 79 65 73 22 2c 20 22 79 22 2c 20  ion("yes", "y", 
2330: 30 29 21 3d 30 3b 0a 20 20 7a 52 65 76 69 73 69  0)!=0;.  zRevisi
2340: 6f 6e 20 3d 20 66 69 6e 64 5f 6f 70 74 69 6f 6e  on = find_option
2350: 28 22 72 65 76 69 73 69 6f 6e 22 2c 20 22 72 22  ("revision", "r"
2360: 2c 20 31 29 3b 0a 20 20 76 65 72 69 66 79 5f 61  , 1);.  verify_a
2370: 6c 6c 5f 6f 70 74 69 6f 6e 73 28 29 3b 0a 20 20  ll_options();.  
2380: 0a 20 20 69 66 28 20 67 2e 61 72 67 63 21 3d 33  .  if( g.argc!=3
2390: 20 29 7b 0a 20 20 20 20 75 73 61 67 65 28 22 3f   ){.    usage("?
23a0: 4f 50 54 49 4f 4e 53 20 46 49 4c 45 22 29 3b 0a  OPTIONS FILE");.
23b0: 20 20 7d 0a 20 20 64 62 5f 6d 75 73 74 5f 62 65    }.  db_must_be
23c0: 5f 77 69 74 68 69 6e 5f 74 72 65 65 28 29 3b 0a  _within_tree();.
23d0: 20 20 0a 20 20 7a 46 69 6c 65 20 3d 20 6d 70 72    .  zFile = mpr
23e0: 69 6e 74 66 28 22 25 2f 22 2c 20 67 2e 61 72 67  intf("%/", g.arg
23f0: 76 5b 67 2e 61 72 67 63 2d 31 5d 29 3b 0a 0a 20  v[g.argc-1]);.. 
2400: 20 66 69 6c 65 5f 74 72 65 65 5f 6e 61 6d 65 28   file_tree_name(
2410: 7a 46 69 6c 65 2c 20 26 66 6e 61 6d 65 2c 20 31  zFile, &fname, 1
2420: 29 3b 0a 0a 20 20 69 66 28 20 61 63 63 65 73 73  );..  if( access
2430: 28 7a 46 69 6c 65 2c 20 30 29 20 29 20 79 65 73  (zFile, 0) ) yes
2440: 52 65 76 65 72 74 20 3d 20 31 3b 20 20 0a 20 20  Revert = 1;  .  
2450: 69 66 28 20 79 65 73 52 65 76 65 72 74 3d 3d 30  if( yesRevert==0
2460: 20 29 7b 0a 20 20 20 20 63 68 61 72 20 2a 70 72   ){.    char *pr
2470: 6f 6d 70 74 20 3d 20 6d 70 72 69 6e 74 66 28 22  ompt = mprintf("
2480: 72 65 76 65 72 74 20 66 69 6c 65 20 25 42 3f 20  revert file %B? 
2490: 74 68 69 73 20 77 69 6c 6c 22 0a 20 20 20 20 20  this will".     
24a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
24b0: 20 20 20 20 20 20 22 20 64 65 73 74 72 6f 79 20        " destroy 
24c0: 6c 6f 63 61 6c 20 63 68 61 6e 67 65 73 20 5b 79  local changes [y
24d0: 2f 4e 5d 3f 20 22 2c 0a 20 20 20 20 20 20 20 20  /N]? ",.        
24e0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
24f0: 20 20 20 26 66 6e 61 6d 65 29 3b 0a 20 20 20 20     &fname);.    
2500: 62 6c 6f 62 5f 7a 65 72 6f 28 26 61 6e 73 29 3b  blob_zero(&ans);
2510: 0a 20 20 20 20 70 72 6f 6d 70 74 5f 75 73 65 72  .    prompt_user
2520: 28 70 72 6f 6d 70 74 2c 20 26 61 6e 73 29 3b 0a  (prompt, &ans);.
2530: 20 20 20 20 66 72 65 65 28 20 70 72 6f 6d 70 74      free( prompt
2540: 20 29 3b 0a 20 20 20 20 69 66 28 20 62 6c 6f 62   );.    if( blob
2550: 5f 73 74 72 28 26 61 6e 73 29 5b 30 5d 3d 3d 27  _str(&ans)[0]=='
2560: 79 27 20 29 7b 0a 20 20 20 20 20 20 79 65 73 52  y' ){.      yesR
2570: 65 76 65 72 74 20 3d 20 31 3b 0a 20 20 20 20 7d  evert = 1;.    }
2580: 0a 20 20 7d 0a 0a 20 20 69 66 28 20 79 65 73 52  .  }..  if( yesR
2590: 65 76 65 72 74 3d 3d 31 20 26 26 20 7a 52 65 76  evert==1 && zRev
25a0: 69 73 69 6f 6e 21 3d 30 20 29 7b 0a 20 20 20 20  ision!=0 ){.    
25b0: 68 69 73 74 6f 72 69 63 61 6c 5f 76 65 72 73 69  historical_versi
25c0: 6f 6e 5f 6f 66 5f 66 69 6c 65 28 7a 52 65 76 69  on_of_file(zRevi
25d0: 73 69 6f 6e 2c 20 7a 46 69 6c 65 2c 20 26 72 65  sion, zFile, &re
25e0: 63 6f 72 64 29 3b 0a 20 20 7d 65 6c 73 65 20 69  cord);.  }else i
25f0: 66 28 20 79 65 73 52 65 76 65 72 74 3d 3d 31 20  f( yesRevert==1 
2600: 29 7b 0a 20 20 20 20 72 69 64 20 3d 20 64 62 5f  ){.    rid = db_
2610: 69 6e 74 28 30 2c 20 22 53 45 4c 45 43 54 20 72  int(0, "SELECT r
2620: 69 64 20 46 52 4f 4d 20 76 66 69 6c 65 20 57 48  id FROM vfile WH
2630: 45 52 45 20 70 61 74 68 6e 61 6d 65 3d 25 42 22  ERE pathname=%B"
2640: 2c 20 26 66 6e 61 6d 65 29 3b 0a 20 20 20 20 69  , &fname);.    i
2650: 66 28 20 72 69 64 3d 3d 30 20 29 7b 0a 20 20 20  f( rid==0 ){.   
2660: 20 20 20 66 6f 73 73 69 6c 5f 70 61 6e 69 63 28     fossil_panic(
2670: 22 6e 6f 20 68 69 73 74 6f 72 79 20 66 6f 72 20  "no history for 
2680: 66 69 6c 65 3a 20 25 62 22 2c 20 26 66 6e 61 6d  file: %b", &fnam
2690: 65 29 3b 0a 20 20 20 20 7d 0a 20 20 20 20 63 6f  e);.    }.    co
26a0: 6e 74 65 6e 74 5f 67 65 74 28 72 69 64 2c 20 26  ntent_get(rid, &
26b0: 72 65 63 6f 72 64 29 3b 0a 20 20 7d 0a 20 20 0a  record);.  }.  .
26c0: 20 20 69 66 28 20 79 65 73 52 65 76 65 72 74 3d    if( yesRevert=
26d0: 3d 31 20 29 7b 0a 20 20 20 20 62 6c 6f 62 5f 77  =1 ){.    blob_w
26e0: 72 69 74 65 5f 74 6f 5f 66 69 6c 65 28 26 72 65  rite_to_file(&re
26f0: 63 6f 72 64 2c 20 7a 46 69 6c 65 29 3b 0a 20 20  cord, zFile);.  
2700: 20 20 70 72 69 6e 74 66 28 22 25 73 20 72 65 76    printf("%s rev
2710: 65 72 74 65 64 5c 6e 22 2c 20 7a 46 69 6c 65 29  erted\n", zFile)
2720: 3b 0a 20 20 20 20 62 6c 6f 62 5f 72 65 73 65 74  ;.    blob_reset
2730: 28 26 72 65 63 6f 72 64 29 3b 0a 20 20 20 20 62  (&record);.    b
2740: 6c 6f 62 5f 72 65 73 65 74 28 26 66 6e 61 6d 65  lob_reset(&fname
2750: 29 3b 0a 20 20 7d 65 6c 73 65 7b 0a 20 20 20 20  );.  }else{.    
2760: 70 72 69 6e 74 66 28 22 72 65 76 65 72 74 20 63  printf("revert c
2770: 61 6e 63 65 6c 65 64 5c 6e 22 29 3b 0a 20 20 7d  anceled\n");.  }
2780: 0a 7d 0a                                         .}.