Hex Artifact Content
Not logged in

Artifact e7d09d92910f3726b57df42ed536669ea4419c37:

File src/update.c part of check-in [b6e22e62cf] - Attempting to rationalize the tagging and branching logic. The "branch" command has been resurrected and appears to work now. The "tag branch" command has been removed. Special tags "newbranch" and "closed" used to manage branches. New changes are not well-tested - use with caution. You must "rebuild" when upgrading through this version. by drh on 2009-01-20 16:51:19.

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 63 68 6e 67 65 64 20 29 7b 0a 20 20  if( chnged ){.  
1830: 20 20 20 20 20 20 70 72 69 6e 74 66 28 22 43 4f        printf("CO
1840: 4e 46 4c 49 43 54 20 25 73 5c 6e 22 2c 20 7a 4e  NFLICT %s\n", zN
1850: 61 6d 65 29 3b 0a 20 20 20 20 20 20 7d 65 6c 73  ame);.      }els
1860: 65 7b 0a 20 20 20 20 20 20 20 20 63 68 61 72 20  e{.        char 
1870: 2a 7a 46 75 6c 6c 50 61 74 68 3b 0a 20 20 20 20  *zFullPath;.    
1880: 20 20 20 20 70 72 69 6e 74 66 28 22 52 45 4d 4f      printf("REMO
1890: 56 45 20 25 73 5c 6e 22 2c 20 7a 4e 61 6d 65 29  VE %s\n", zName)
18a0: 3b 0a 20 20 20 20 20 20 20 20 75 6e 64 6f 5f 73  ;.        undo_s
18b0: 61 76 65 28 7a 4e 61 6d 65 29 3b 0a 20 20 20 20  ave(zName);.    
18c0: 20 20 20 20 7a 46 75 6c 6c 50 61 74 68 20 3d 20      zFullPath = 
18d0: 6d 70 72 69 6e 74 66 28 22 25 73 2f 25 73 22 2c  mprintf("%s/%s",
18e0: 20 67 2e 7a 4c 6f 63 61 6c 52 6f 6f 74 2c 20 7a   g.zLocalRoot, z
18f0: 4e 61 6d 65 29 3b 0a 20 20 20 20 20 20 20 20 75  Name);.        u
1900: 6e 6c 69 6e 6b 28 7a 46 75 6c 6c 50 61 74 68 29  nlink(zFullPath)
1910: 3b 0a 20 20 20 20 20 20 20 20 66 72 65 65 28 7a  ;.        free(z
1920: 46 75 6c 6c 50 61 74 68 29 3b 0a 20 20 20 20 20  FullPath);.     
1930: 20 7d 0a 20 20 20 20 7d 65 6c 73 65 20 69 66 28   }.    }else if(
1940: 20 69 64 74 3e 30 20 26 26 20 69 64 76 3e 30 20   idt>0 && idv>0 
1950: 26 26 20 72 69 64 74 21 3d 72 69 64 76 20 26 26  && ridt!=ridv &&
1960: 20 63 68 6e 67 65 64 20 29 7b 0a 20 20 20 20 20   chnged ){.     
1970: 20 2f 2a 20 4d 65 72 67 65 20 74 68 65 20 63 68   /* Merge the ch
1980: 61 6e 67 65 73 20 69 6e 20 74 68 65 20 63 75 72  anges in the cur
1990: 72 65 6e 74 20 74 72 65 65 20 69 6e 74 6f 20 74  rent tree into t
19a0: 68 65 20 74 61 72 67 65 74 20 76 65 72 73 69 6f  he target versio
19b0: 6e 20 2a 2f 0a 20 20 20 20 20 20 42 6c 6f 62 20  n */.      Blob 
19c0: 65 2c 20 72 2c 20 74 2c 20 76 3b 0a 20 20 20 20  e, r, t, v;.    
19d0: 20 20 69 6e 74 20 72 63 3b 0a 20 20 20 20 20 20    int rc;.      
19e0: 63 68 61 72 20 2a 7a 46 75 6c 6c 50 61 74 68 3b  char *zFullPath;
19f0: 0a 20 20 20 20 20 20 70 72 69 6e 74 66 28 22 4d  .      printf("M
1a00: 45 52 47 45 20 25 73 5c 6e 22 2c 20 7a 4e 61 6d  ERGE %s\n", zNam
1a10: 65 29 3b 0a 20 20 20 20 20 20 75 6e 64 6f 5f 73  e);.      undo_s
1a20: 61 76 65 28 7a 4e 61 6d 65 29 3b 0a 20 20 20 20  ave(zName);.    
1a30: 20 20 7a 46 75 6c 6c 50 61 74 68 20 3d 20 6d 70    zFullPath = mp
1a40: 72 69 6e 74 66 28 22 25 73 2f 25 73 22 2c 20 67  rintf("%s/%s", g
1a50: 2e 7a 4c 6f 63 61 6c 52 6f 6f 74 2c 20 7a 4e 61  .zLocalRoot, zNa
1a60: 6d 65 29 3b 0a 20 20 20 20 20 20 63 6f 6e 74 65  me);.      conte
1a70: 6e 74 5f 67 65 74 28 72 69 64 74 2c 20 26 74 29  nt_get(ridt, &t)
1a80: 3b 0a 20 20 20 20 20 20 63 6f 6e 74 65 6e 74 5f  ;.      content_
1a90: 67 65 74 28 72 69 64 76 2c 20 26 76 29 3b 0a 20  get(ridv, &v);. 
1aa0: 20 20 20 20 20 62 6c 6f 62 5f 7a 65 72 6f 28 26       blob_zero(&
1ab0: 65 29 3b 0a 20 20 20 20 20 20 62 6c 6f 62 5f 72  e);.      blob_r
1ac0: 65 61 64 5f 66 72 6f 6d 5f 66 69 6c 65 28 26 65  ead_from_file(&e
1ad0: 2c 20 7a 46 75 6c 6c 50 61 74 68 29 3b 0a 20 20  , zFullPath);.  
1ae0: 20 20 20 20 72 63 20 3d 20 62 6c 6f 62 5f 6d 65      rc = blob_me
1af0: 72 67 65 28 26 76 2c 20 26 65 2c 20 26 74 2c 20  rge(&v, &e, &t, 
1b00: 26 72 29 3b 0a 20 20 20 20 20 20 69 66 28 20 72  &r);.      if( r
1b10: 63 3e 3d 30 20 29 7b 0a 20 20 20 20 20 20 20 20  c>=0 ){.        
1b20: 62 6c 6f 62 5f 77 72 69 74 65 5f 74 6f 5f 66 69  blob_write_to_fi
1b30: 6c 65 28 26 72 2c 20 7a 46 75 6c 6c 50 61 74 68  le(&r, zFullPath
1b40: 29 3b 0a 20 20 20 20 20 20 20 20 69 66 28 20 72  );.        if( r
1b50: 63 3e 30 20 29 7b 0a 20 20 20 20 20 20 20 20 20  c>0 ){.         
1b60: 20 70 72 69 6e 74 66 28 22 2a 2a 2a 2a 2a 20 25   printf("***** %
1b70: 64 20 6d 65 72 67 65 20 63 6f 6e 66 6c 69 63 74  d merge conflict
1b80: 73 20 69 6e 20 25 73 5c 6e 22 2c 20 72 63 2c 20  s in %s\n", rc, 
1b90: 7a 4e 61 6d 65 29 3b 0a 20 20 20 20 20 20 20 20  zName);.        
1ba0: 7d 0a 20 20 20 20 20 20 7d 65 6c 73 65 7b 0a 20  }.      }else{. 
1bb0: 20 20 20 20 20 20 20 70 72 69 6e 74 66 28 22 2a         printf("*
1bc0: 2a 2a 2a 2a 20 43 61 6e 6e 6f 74 20 6d 65 72 67  **** Cannot merg
1bd0: 65 20 62 69 6e 61 72 79 20 66 69 6c 65 20 25 73  e binary file %s
1be0: 5c 6e 22 2c 20 7a 4e 61 6d 65 29 3b 0a 20 20 20  \n", zName);.   
1bf0: 20 20 20 7d 0a 20 20 20 20 20 20 66 72 65 65 28     }.      free(
1c00: 7a 46 75 6c 6c 50 61 74 68 29 3b 0a 20 20 20 20  zFullPath);.    
1c10: 20 20 62 6c 6f 62 5f 72 65 73 65 74 28 26 76 29    blob_reset(&v)
1c20: 3b 0a 20 20 20 20 20 20 62 6c 6f 62 5f 72 65 73  ;.      blob_res
1c30: 65 74 28 26 65 29 3b 0a 20 20 20 20 20 20 62 6c  et(&e);.      bl
1c40: 6f 62 5f 72 65 73 65 74 28 26 74 29 3b 0a 20 20  ob_reset(&t);.  
1c50: 20 20 20 20 62 6c 6f 62 5f 72 65 73 65 74 28 26      blob_reset(&
1c60: 72 29 3b 0a 20 20 20 20 20 20 0a 20 20 20 20 7d  r);.      .    }
1c70: 0a 20 20 7d 0a 20 20 64 62 5f 66 69 6e 61 6c 69  .  }.  db_finali
1c80: 7a 65 28 26 71 29 3b 0a 20 20 0a 20 20 2f 2a 0a  ze(&q);.  .  /*.
1c90: 20 20 2a 2a 20 43 6c 65 61 6e 20 75 70 20 74 68    ** Clean up th
1ca0: 65 20 6d 69 64 20 61 6e 64 20 70 69 64 20 56 46  e mid and pid VF
1cb0: 49 4c 45 20 65 6e 74 72 69 65 73 2e 20 20 54 68  ILE entries.  Th
1cc0: 65 6e 20 63 6f 6d 6d 69 74 20 74 68 65 20 63 68  en commit the ch
1cd0: 61 6e 67 65 73 2e 0a 20 20 2a 2f 0a 20 20 64 62  anges..  */.  db
1ce0: 5f 6d 75 6c 74 69 5f 65 78 65 63 28 22 44 45 4c  _multi_exec("DEL
1cf0: 45 54 45 20 46 52 4f 4d 20 76 66 69 6c 65 20 57  ETE FROM vfile W
1d00: 48 45 52 45 20 76 69 64 21 3d 25 64 22 2c 20 74  HERE vid!=%d", t
1d10: 69 64 29 3b 0a 20 20 6d 61 6e 69 66 65 73 74 5f  id);.  manifest_
1d20: 74 6f 5f 64 69 73 6b 28 74 69 64 29 3b 0a 20 20  to_disk(tid);.  
1d30: 64 62 5f 6c 73 65 74 5f 69 6e 74 28 22 63 68 65  db_lset_int("che
1d40: 63 6b 6f 75 74 22 2c 20 74 69 64 29 3b 0a 20 20  ckout", tid);.  
1d50: 64 62 5f 65 6e 64 5f 74 72 61 6e 73 61 63 74 69  db_end_transacti
1d60: 6f 6e 28 30 29 3b 0a 7d 0a 0a 0a 2f 2a 0a 2a 2a  on(0);.}.../*.**
1d70: 20 47 65 74 20 74 68 65 20 63 6f 6e 74 65 6e 74   Get the content
1d80: 73 20 6f 66 20 61 20 66 69 6c 65 20 77 69 74 68  s of a file with
1d90: 69 6e 20 61 20 67 69 76 65 6e 20 72 65 76 69 73  in a given revis
1da0: 69 6f 6e 2e 0a 2a 2f 0a 69 6e 74 20 68 69 73 74  ion..*/.int hist
1db0: 6f 72 69 63 61 6c 5f 76 65 72 73 69 6f 6e 5f 6f  orical_version_o
1dc0: 66 5f 66 69 6c 65 28 0a 20 20 63 6f 6e 73 74 20  f_file(.  const 
1dd0: 63 68 61 72 20 2a 72 65 76 69 73 69 6f 6e 2c 20  char *revision, 
1de0: 20 20 20 2f 2a 20 54 68 65 20 62 61 73 65 6c 69     /* The baseli
1df0: 6e 65 20 6e 61 6d 65 20 63 6f 6e 74 61 69 6e 69  ne name containi
1e00: 6e 67 20 74 68 65 20 66 69 6c 65 20 2a 2f 0a 20  ng the file */. 
1e10: 20 63 6f 6e 73 74 20 63 68 61 72 20 2a 66 69 6c   const char *fil
1e20: 65 2c 20 20 20 20 20 20 20 20 2f 2a 20 46 75 6c  e,        /* Ful
1e30: 6c 20 74 72 65 65 6e 61 6d 65 20 6f 66 20 74 68  l treename of th
1e40: 65 20 66 69 6c 65 20 2a 2f 0a 20 20 42 6c 6f 62  e file */.  Blob
1e50: 20 2a 63 6f 6e 74 65 6e 74 20 20 20 20 20 20 20   *content       
1e60: 20 20 20 20 20 2f 2a 20 50 75 74 20 74 68 65 20       /* Put the 
1e70: 63 6f 6e 74 65 6e 74 20 68 65 72 65 20 2a 2f 0a  content here */.
1e80: 29 7b 0a 20 20 42 6c 6f 62 20 6d 66 69 6c 65 3b  ){.  Blob mfile;
1e90: 0a 20 20 4d 61 6e 69 66 65 73 74 20 6d 3b 0a 20  .  Manifest m;. 
1ea0: 20 69 6e 74 20 69 2c 20 72 69 64 3d 30 3b 0a 20   int i, rid=0;. 
1eb0: 20 0a 20 20 72 69 64 20 3d 20 6e 61 6d 65 5f 74   .  rid = name_t
1ec0: 6f 5f 72 69 64 28 72 65 76 69 73 69 6f 6e 29 3b  o_rid(revision);
1ed0: 0a 20 20 63 6f 6e 74 65 6e 74 5f 67 65 74 28 72  .  content_get(r
1ee0: 69 64 2c 20 26 6d 66 69 6c 65 29 3b 0a 20 20 0a  id, &mfile);.  .
1ef0: 20 20 69 66 28 20 6d 61 6e 69 66 65 73 74 5f 70    if( manifest_p
1f00: 61 72 73 65 28 26 6d 2c 20 26 6d 66 69 6c 65 29  arse(&m, &mfile)
1f10: 20 29 7b 0a 20 20 20 20 66 6f 72 28 69 3d 30 3b   ){.    for(i=0;
1f20: 20 69 3c 6d 2e 6e 46 69 6c 65 3b 20 69 2b 2b 29   i<m.nFile; i++)
1f30: 7b 0a 20 20 20 20 20 20 69 66 28 20 73 74 72 63  {.      if( strc
1f40: 6d 70 28 6d 2e 61 46 69 6c 65 5b 69 5d 2e 7a 4e  mp(m.aFile[i].zN
1f50: 61 6d 65 2c 20 66 69 6c 65 29 3d 3d 30 20 29 7b  ame, file)==0 ){
1f60: 0a 20 20 20 20 20 20 20 20 72 69 64 20 3d 20 75  .        rid = u
1f70: 75 69 64 5f 74 6f 5f 72 69 64 28 6d 2e 61 46 69  uid_to_rid(m.aFi
1f80: 6c 65 5b 69 5d 2e 7a 55 75 69 64 2c 20 30 29 3b  le[i].zUuid, 0);
1f90: 0a 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20  .        return 
1fa0: 63 6f 6e 74 65 6e 74 5f 67 65 74 28 72 69 64 2c  content_get(rid,
1fb0: 20 63 6f 6e 74 65 6e 74 29 3b 0a 20 20 20 20 20   content);.     
1fc0: 20 7d 0a 20 20 20 20 7d 0a 20 20 20 20 66 6f 73   }.    }.    fos
1fd0: 73 69 6c 5f 66 61 74 61 6c 28 22 66 69 6c 65 20  sil_fatal("file 
1fe0: 25 73 20 64 6f 65 73 20 6e 6f 74 20 65 78 69 73  %s does not exis
1ff0: 74 20 69 6e 20 62 61 73 65 6c 69 6e 65 3a 20 25  t in baseline: %
2000: 73 22 2c 20 66 69 6c 65 2c 20 72 65 76 69 73 69  s", file, revisi
2010: 6f 6e 29 3b 0a 20 20 7d 65 6c 73 65 7b 0a 20 20  on);.  }else{.  
2020: 20 20 66 6f 73 73 69 6c 5f 70 61 6e 69 63 28 22    fossil_panic("
2030: 63 6f 75 6c 64 20 6e 6f 74 20 70 61 72 73 65 20  could not parse 
2040: 6d 61 6e 69 66 65 73 74 20 66 6f 72 20 62 61 73  manifest for bas
2050: 65 6c 69 6e 65 3a 20 25 73 22 2c 20 72 65 76 69  eline: %s", revi
2060: 73 69 6f 6e 29 3b 0a 20 20 7d 0a 20 20 72 65 74  sion);.  }.  ret
2070: 75 72 6e 20 30 3b 0a 7d 0a 0a 0a 2f 2a 0a 2a 2a  urn 0;.}.../*.**
2080: 20 43 4f 4d 4d 41 4e 44 3a 20 72 65 76 65 72 74   COMMAND: revert
2090: 0a 2a 2a 0a 2a 2a 20 55 73 61 67 65 3a 20 25 66  .**.** Usage: %f
20a0: 6f 73 73 69 6c 20 72 65 76 65 72 74 20 3f 2d 2d  ossil revert ?--
20b0: 79 65 73 3f 20 3f 2d 72 20 52 45 56 49 53 49 4f  yes? ?-r REVISIO
20c0: 4e 3f 20 46 49 4c 45 0a 2a 2a 0a 2a 2a 20 52 65  N? FILE.**.** Re
20d0: 76 65 72 74 20 74 6f 20 74 68 65 20 63 75 72 72  vert to the curr
20e0: 65 6e 74 20 72 65 70 6f 73 69 74 6f 72 79 20 76  ent repository v
20f0: 65 72 73 69 6f 6e 20 6f 66 20 46 49 4c 45 2c 20  ersion of FILE, 
2100: 6f 72 20 74 6f 0a 2a 2a 20 74 68 65 20 76 65 72  or to.** the ver
2110: 73 69 6f 6e 20 61 73 73 6f 63 69 61 74 65 64 20  sion associated 
2120: 77 69 74 68 20 62 61 73 65 6c 69 6e 65 20 52 45  with baseline RE
2130: 56 49 53 49 4f 4e 20 69 66 20 74 68 65 20 2d 72  VISION if the -r
2140: 20 66 6c 61 67 0a 2a 2a 20 61 70 70 65 61 72 73   flag.** appears
2150: 2e 20 20 54 68 69 73 20 63 6f 6d 6d 61 6e 64 20  .  This command 
2160: 77 69 6c 6c 20 63 6f 6e 66 69 72 6d 20 79 6f 75  will confirm you
2170: 72 20 6f 70 65 72 61 74 69 6f 6e 20 75 6e 6c 65  r operation unle
2180: 73 73 20 74 68 65 0a 2a 2a 20 66 69 6c 65 20 69  ss the.** file i
2190: 73 20 6d 69 73 73 69 6e 67 20 6f 72 20 74 68 65  s missing or the
21a0: 20 2d 2d 79 65 73 20 6f 70 74 69 6f 6e 20 69 73   --yes option is
21b0: 20 75 73 65 64 2e 0a 2a 2a 2f 0a 76 6f 69 64 20   used..**/.void 
21c0: 72 65 76 65 72 74 5f 63 6d 64 28 76 6f 69 64 29  revert_cmd(void)
21d0: 7b 0a 20 20 63 6f 6e 73 74 20 63 68 61 72 20 2a  {.  const char *
21e0: 7a 46 69 6c 65 3b 0a 20 20 63 6f 6e 73 74 20 63  zFile;.  const c
21f0: 68 61 72 20 2a 7a 52 65 76 69 73 69 6f 6e 3b 0a  har *zRevision;.
2200: 20 20 42 6c 6f 62 20 66 6e 61 6d 65 3b 0a 20 20    Blob fname;.  
2210: 42 6c 6f 62 20 72 65 63 6f 72 64 3b 0a 20 20 42  Blob record;.  B
2220: 6c 6f 62 20 61 6e 73 3b 0a 20 20 69 6e 74 20 72  lob ans;.  int r
2230: 69 64 20 3d 20 30 2c 20 79 65 73 52 65 76 65 72  id = 0, yesRever
2240: 74 3b 0a 20 20 0a 20 20 79 65 73 52 65 76 65 72  t;.  .  yesRever
2250: 74 20 3d 20 66 69 6e 64 5f 6f 70 74 69 6f 6e 28  t = find_option(
2260: 22 79 65 73 22 2c 20 22 79 22 2c 20 30 29 21 3d  "yes", "y", 0)!=
2270: 30 3b 0a 20 20 7a 52 65 76 69 73 69 6f 6e 20 3d  0;.  zRevision =
2280: 20 66 69 6e 64 5f 6f 70 74 69 6f 6e 28 22 72 65   find_option("re
2290: 76 69 73 69 6f 6e 22 2c 20 22 72 22 2c 20 31 29  vision", "r", 1)
22a0: 3b 0a 20 20 76 65 72 69 66 79 5f 61 6c 6c 5f 6f  ;.  verify_all_o
22b0: 70 74 69 6f 6e 73 28 29 3b 0a 20 20 0a 20 20 69  ptions();.  .  i
22c0: 66 28 20 67 2e 61 72 67 63 3c 33 20 29 7b 0a 20  f( g.argc<3 ){. 
22d0: 20 20 20 75 73 61 67 65 28 22 3f 4f 50 54 49 4f     usage("?OPTIO
22e0: 4e 53 20 46 49 4c 45 22 29 3b 0a 20 20 7d 0a 20  NS FILE");.  }. 
22f0: 20 64 62 5f 6d 75 73 74 5f 62 65 5f 77 69 74 68   db_must_be_with
2300: 69 6e 5f 74 72 65 65 28 29 3b 0a 20 20 0a 20 20  in_tree();.  .  
2310: 7a 46 69 6c 65 20 3d 20 6d 70 72 69 6e 74 66 28  zFile = mprintf(
2320: 22 25 2f 22 2c 20 67 2e 61 72 67 76 5b 67 2e 61  "%/", g.argv[g.a
2330: 72 67 63 2d 31 5d 29 3b 0a 0a 20 20 66 69 6c 65  rgc-1]);..  file
2340: 5f 74 72 65 65 5f 6e 61 6d 65 28 7a 46 69 6c 65  _tree_name(zFile
2350: 2c 20 26 66 6e 61 6d 65 2c 20 31 29 3b 0a 0a 20  , &fname, 1);.. 
2360: 20 69 66 28 20 61 63 63 65 73 73 28 7a 46 69 6c   if( access(zFil
2370: 65 2c 20 30 29 20 29 20 79 65 73 52 65 76 65 72  e, 0) ) yesRever
2380: 74 20 3d 20 31 3b 20 20 0a 20 20 69 66 28 20 79  t = 1;  .  if( y
2390: 65 73 52 65 76 65 72 74 3d 3d 30 20 29 7b 0a 20  esRevert==0 ){. 
23a0: 20 20 20 63 68 61 72 20 2a 70 72 6f 6d 70 74 20     char *prompt 
23b0: 3d 20 6d 70 72 69 6e 74 66 28 22 72 65 76 65 72  = mprintf("rever
23c0: 74 20 66 69 6c 65 20 25 42 3f 20 74 68 69 73 20  t file %B? this 
23d0: 77 69 6c 6c 22 0a 20 20 20 20 20 20 20 20 20 20  will".          
23e0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
23f0: 20 22 20 64 65 73 74 72 6f 79 20 6c 6f 63 61 6c   " destroy local
2400: 20 63 68 61 6e 67 65 73 20 5b 79 2f 4e 5d 3f 20   changes [y/N]? 
2410: 22 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20  ",.             
2420: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 26 66                &f
2430: 6e 61 6d 65 29 3b 0a 20 20 20 20 62 6c 6f 62 5f  name);.    blob_
2440: 7a 65 72 6f 28 26 61 6e 73 29 3b 0a 20 20 20 20  zero(&ans);.    
2450: 70 72 6f 6d 70 74 5f 75 73 65 72 28 70 72 6f 6d  prompt_user(prom
2460: 70 74 2c 20 26 61 6e 73 29 3b 0a 20 20 20 20 66  pt, &ans);.    f
2470: 72 65 65 28 20 70 72 6f 6d 70 74 20 29 3b 0a 20  ree( prompt );. 
2480: 20 20 20 69 66 28 20 62 6c 6f 62 5f 73 74 72 28     if( blob_str(
2490: 26 61 6e 73 29 5b 30 5d 3d 3d 27 79 27 20 29 7b  &ans)[0]=='y' ){
24a0: 0a 20 20 20 20 20 20 79 65 73 52 65 76 65 72 74  .      yesRevert
24b0: 20 3d 20 31 3b 0a 20 20 20 20 7d 0a 20 20 7d 0a   = 1;.    }.  }.
24c0: 0a 20 20 69 66 28 20 79 65 73 52 65 76 65 72 74  .  if( yesRevert
24d0: 3d 3d 31 20 26 26 20 7a 52 65 76 69 73 69 6f 6e  ==1 && zRevision
24e0: 21 3d 30 20 29 7b 0a 20 20 20 20 68 69 73 74 6f  !=0 ){.    histo
24f0: 72 69 63 61 6c 5f 76 65 72 73 69 6f 6e 5f 6f 66  rical_version_of
2500: 5f 66 69 6c 65 28 7a 52 65 76 69 73 69 6f 6e 2c  _file(zRevision,
2510: 20 7a 46 69 6c 65 2c 20 26 72 65 63 6f 72 64 29   zFile, &record)
2520: 3b 0a 20 20 7d 65 6c 73 65 20 69 66 28 20 79 65  ;.  }else if( ye
2530: 73 52 65 76 65 72 74 3d 3d 31 20 29 7b 0a 20 20  sRevert==1 ){.  
2540: 20 20 72 69 64 20 3d 20 64 62 5f 69 6e 74 28 30    rid = db_int(0
2550: 2c 20 22 53 45 4c 45 43 54 20 72 69 64 20 46 52  , "SELECT rid FR
2560: 4f 4d 20 76 66 69 6c 65 20 57 48 45 52 45 20 70  OM vfile WHERE p
2570: 61 74 68 6e 61 6d 65 3d 25 42 22 2c 20 26 66 6e  athname=%B", &fn
2580: 61 6d 65 29 3b 0a 20 20 20 20 69 66 28 20 72 69  ame);.    if( ri
2590: 64 3d 3d 30 20 29 7b 0a 20 20 20 20 20 20 66 6f  d==0 ){.      fo
25a0: 73 73 69 6c 5f 70 61 6e 69 63 28 22 6e 6f 20 68  ssil_panic("no h
25b0: 69 73 74 6f 72 79 20 66 6f 72 20 66 69 6c 65 3a  istory for file:
25c0: 20 25 62 22 2c 20 26 66 6e 61 6d 65 29 3b 0a 20   %b", &fname);. 
25d0: 20 20 20 7d 0a 20 20 20 20 63 6f 6e 74 65 6e 74     }.    content
25e0: 5f 67 65 74 28 72 69 64 2c 20 26 72 65 63 6f 72  _get(rid, &recor
25f0: 64 29 3b 0a 20 20 7d 0a 20 20 0a 20 20 69 66 28  d);.  }.  .  if(
2600: 20 79 65 73 52 65 76 65 72 74 3d 3d 31 20 29 7b   yesRevert==1 ){
2610: 0a 20 20 20 20 62 6c 6f 62 5f 77 72 69 74 65 5f  .    blob_write_
2620: 74 6f 5f 66 69 6c 65 28 26 72 65 63 6f 72 64 2c  to_file(&record,
2630: 20 7a 46 69 6c 65 29 3b 0a 20 20 20 20 70 72 69   zFile);.    pri
2640: 6e 74 66 28 22 25 73 20 72 65 76 65 72 74 65 64  ntf("%s reverted
2650: 5c 6e 22 2c 20 7a 46 69 6c 65 29 3b 0a 20 20 20  \n", zFile);.   
2660: 20 62 6c 6f 62 5f 72 65 73 65 74 28 26 72 65 63   blob_reset(&rec
2670: 6f 72 64 29 3b 0a 20 20 20 20 62 6c 6f 62 5f 72  ord);.    blob_r
2680: 65 73 65 74 28 26 66 6e 61 6d 65 29 3b 0a 20 20  eset(&fname);.  
2690: 7d 65 6c 73 65 7b 0a 20 20 20 20 70 72 69 6e 74  }else{.    print
26a0: 66 28 22 72 65 76 65 72 74 20 63 61 6e 63 65 6c  f("revert cancel
26b0: 65 64 5c 6e 22 29 3b 0a 20 20 7d 0a 7d 0a        ed\n");.  }.}.