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 31 29 3b 0a 20 20 7d 0a 20 20 0a 20 20 69 c(1);. }. . i
0c60: 66 28 20 74 69 64 3d 3d 30 20 29 7b 0a 20 20 20 f( tid==0 ){.
0c70: 20 63 6f 6d 70 75 74 65 5f 6c 65 61 76 65 73 28 compute_leaves(
0c80: 76 69 64 29 3b 0a 20 20 20 20 69 66 28 20 21 6c vid);. if( !l
0c90: 61 74 65 73 74 46 6c 61 67 20 26 26 20 64 62 5f atestFlag && db_
0ca0: 69 6e 74 28 30 2c 20 22 53 45 4c 45 43 54 20 63 int(0, "SELECT c
0cb0: 6f 75 6e 74 28 2a 29 20 46 52 4f 4d 20 6c 65 61 ount(*) FROM lea
0cc0: 76 65 73 22 29 3e 31 20 29 7b 0a 20 20 20 20 20 ves")>1 ){.
0cd0: 20 64 62 5f 70 72 65 70 61 72 65 28 26 71 2c 20 db_prepare(&q,
0ce0: 0a 20 20 20 20 20 20 20 20 22 25 73 20 22 0a 20 . "%s ".
0cf0: 20 20 20 20 20 20 20 22 20 20 20 41 4e 44 20 65 " AND e
0d00: 76 65 6e 74 2e 6f 62 6a 69 64 20 49 4e 20 6c 65 vent.objid IN le
0d10: 61 76 65 73 22 0a 20 20 20 20 20 20 20 20 22 20 aves". "
0d20: 4f 52 44 45 52 20 42 59 20 65 76 65 6e 74 2e 6d ORDER BY event.m
0d30: 74 69 6d 65 20 44 45 53 43 22 2c 0a 20 20 20 20 time DESC",.
0d40: 20 20 20 20 74 69 6d 65 6c 69 6e 65 5f 71 75 65 timeline_que
0d50: 72 79 5f 66 6f 72 5f 74 74 79 28 29 0a 20 20 20 ry_for_tty().
0d60: 20 20 20 29 3b 0a 20 20 20 20 20 20 70 72 69 6e );. prin
0d70: 74 5f 74 69 6d 65 6c 69 6e 65 28 26 71 2c 20 31 t_timeline(&q, 1
0d80: 30 30 29 3b 0a 20 20 20 20 20 20 64 62 5f 66 69 00);. db_fi
0d90: 6e 61 6c 69 7a 65 28 26 71 29 3b 0a 20 20 20 20 nalize(&q);.
0da0: 20 20 66 6f 73 73 69 6c 5f 66 61 74 61 6c 28 22 fossil_fatal("
0db0: 4d 75 6c 74 69 70 6c 65 20 64 65 73 63 65 6e 64 Multiple descend
0dc0: 65 6e 74 73 22 29 3b 0a 20 20 20 20 7d 0a 20 20 ents");. }.
0dd0: 20 20 74 69 64 20 3d 20 64 62 5f 69 6e 74 28 30 tid = db_int(0
0de0: 2c 20 22 53 45 4c 45 43 54 20 72 69 64 20 46 52 , "SELECT rid FR
0df0: 4f 4d 20 6c 65 61 76 65 73 2c 20 65 76 65 6e 74 OM leaves, event
0e00: 22 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ".
0e10: 20 20 20 20 20 20 22 20 57 48 45 52 45 20 65 76 " WHERE ev
0e20: 65 6e 74 2e 6f 62 6a 69 64 3d 6c 65 61 76 65 73 ent.objid=leaves
0e30: 2e 72 69 64 22 0a 20 20 20 20 20 20 20 20 20 20 .rid".
0e40: 20 20 20 20 20 20 20 20 20 20 22 20 4f 52 44 45 " ORDE
0e50: 52 20 42 59 20 65 76 65 6e 74 2e 6d 74 69 6d 65 R BY event.mtime
0e60: 20 44 45 53 43 22 29 3b 20 0a 20 20 7d 0a 0a 20 DESC"); . }..
0e70: 20 64 62 5f 62 65 67 69 6e 5f 74 72 61 6e 73 61 db_begin_transa
0e80: 63 74 69 6f 6e 28 29 3b 0a 20 20 76 66 69 6c 65 ction();. vfile
0e90: 5f 63 68 65 63 6b 5f 73 69 67 6e 61 74 75 72 65 _check_signature
0ea0: 28 76 69 64 29 3b 0a 20 20 75 6e 64 6f 5f 62 65 (vid);. undo_be
0eb0: 67 69 6e 28 29 3b 0a 20 20 6c 6f 61 64 5f 76 66 gin();. load_vf
0ec0: 69 6c 65 5f 66 72 6f 6d 5f 72 69 64 28 74 69 64 ile_from_rid(tid
0ed0: 29 3b 0a 0a 20 20 2f 2a 0a 20 20 2a 2a 20 54 68 );.. /*. ** Th
0ee0: 65 20 72 65 63 6f 72 64 2e 66 6e 20 66 69 65 6c e record.fn fiel
0ef0: 64 20 69 73 20 75 73 65 64 20 74 6f 20 6d 61 74 d is used to mat
0f00: 63 68 20 66 69 6c 65 73 20 61 67 61 69 6e 73 74 ch files against
0f10: 20 65 61 63 68 20 6f 74 68 65 72 2e 20 20 54 68 each other. Th
0f20: 65 0a 20 20 2a 2a 20 46 56 20 74 61 62 6c 65 20 e. ** FV table
0f30: 63 6f 6e 74 61 69 6e 73 20 6f 6e 65 20 72 6f 77 contains one row
0f40: 20 66 6f 72 20 65 61 63 68 20 65 61 63 68 20 75 for each each u
0f50: 6e 69 71 75 65 20 66 69 6c 65 6e 61 6d 65 20 69 nique filename i
0f60: 6e 0a 20 20 2a 2a 20 69 6e 20 74 68 65 20 63 75 n. ** in the cu
0f70: 72 72 65 6e 74 20 63 68 65 63 6b 6f 75 74 2c 20 rrent checkout,
0f80: 74 68 65 20 70 69 76 6f 74 2c 20 61 6e 64 20 74 the pivot, and t
0f90: 68 65 20 76 65 72 73 69 6f 6e 20 62 65 69 6e 67 he version being
0fa0: 20 6d 65 72 67 65 64 2e 0a 20 20 2a 2f 0a 20 20 merged.. */.
0fb0: 64 62 5f 6d 75 6c 74 69 5f 65 78 65 63 28 0a 20 db_multi_exec(.
0fc0: 20 20 20 22 44 52 4f 50 20 54 41 42 4c 45 20 49 "DROP TABLE I
0fd0: 46 20 45 58 49 53 54 53 20 66 76 3b 22 0a 20 20 F EXISTS fv;".
0fe0: 20 20 22 43 52 45 41 54 45 20 54 45 4d 50 20 54 "CREATE TEMP T
0ff0: 41 42 4c 45 20 66 76 28 22 0a 20 20 20 20 22 20 ABLE fv(". "
1000: 20 66 6e 20 54 45 58 54 20 50 52 49 4d 41 52 59 fn TEXT PRIMARY
1010: 20 4b 45 59 2c 22 20 20 20 20 20 20 2f 2a 20 54 KEY," /* T
1020: 68 65 20 66 69 6c 65 6e 61 6d 65 20 2a 2f 0a 20 he filename */.
1030: 20 20 20 22 20 20 69 64 76 20 49 4e 54 45 47 45 " idv INTEGE
1040: 52 2c 22 20 20 20 20 20 20 20 20 20 20 20 20 20 R,"
1050: 20 2f 2a 20 56 46 49 4c 45 20 65 6e 74 72 79 20 /* VFILE entry
1060: 66 6f 72 20 63 75 72 72 65 6e 74 20 76 65 72 73 for current vers
1070: 69 6f 6e 20 2a 2f 0a 20 20 20 20 22 20 20 69 64 ion */. " id
1080: 74 20 49 4e 54 45 47 45 52 2c 22 20 20 20 20 20 t INTEGER,"
1090: 20 20 20 20 20 20 20 20 20 2f 2a 20 56 46 49 4c /* VFIL
10a0: 45 20 65 6e 74 72 79 20 66 6f 72 20 74 61 72 67 E entry for targ
10b0: 65 74 20 76 65 72 73 69 6f 6e 20 2a 2f 0a 20 20 et version */.
10c0: 20 20 22 20 20 63 68 6e 67 65 64 20 42 4f 4f 4c " chnged BOOL
10d0: 45 41 4e 2c 22 20 20 20 20 20 20 20 20 20 20 20 EAN,"
10e0: 2f 2a 20 54 72 75 65 20 69 66 20 63 75 72 72 65 /* True if curre
10f0: 6e 74 20 76 65 72 73 69 6f 6e 20 68 61 73 20 62 nt version has b
1100: 65 65 6e 20 65 64 69 74 65 64 20 2a 2f 0a 20 20 een edited */.
1110: 20 20 22 20 20 72 69 64 76 20 49 4e 54 45 47 45 " ridv INTEGE
1120: 52 2c 22 20 20 20 20 20 20 20 20 20 20 20 20 20 R,"
1130: 2f 2a 20 52 65 63 6f 72 64 20 49 44 20 66 6f 72 /* Record ID for
1140: 20 63 75 72 72 65 6e 74 20 76 65 72 73 69 6f 6e current version
1150: 20 2a 2f 0a 20 20 20 20 22 20 20 72 69 64 74 20 */. " ridt
1160: 49 4e 54 45 47 45 52 20 22 20 20 20 20 20 20 20 INTEGER "
1170: 20 20 20 20 20 20 2f 2a 20 52 65 63 6f 72 64 20 /* Record
1180: 49 44 20 66 6f 72 20 74 61 72 67 65 74 20 2a 2f ID for target */
1190: 0a 20 20 20 20 22 29 3b 22 0a 20 20 20 20 22 49 . ");". "I
11a0: 4e 53 45 52 54 20 4f 52 20 49 47 4e 4f 52 45 20 NSERT OR IGNORE
11b0: 49 4e 54 4f 20 66 76 22 0a 20 20 20 20 22 20 53 INTO fv". " S
11c0: 45 4c 45 43 54 20 70 61 74 68 6e 61 6d 65 2c 20 ELECT pathname,
11d0: 30 2c 20 30 2c 20 30 2c 20 30 2c 20 30 20 46 52 0, 0, 0, 0, 0 FR
11e0: 4f 4d 20 76 66 69 6c 65 22 0a 20 20 29 3b 0a 20 OM vfile". );.
11f0: 20 64 62 5f 70 72 65 70 61 72 65 28 26 71 2c 0a db_prepare(&q,.
1200: 20 20 20 20 22 53 45 4c 45 43 54 20 69 64 2c 20 "SELECT id,
1210: 70 61 74 68 6e 61 6d 65 2c 20 72 69 64 20 46 52 pathname, rid FR
1220: 4f 4d 20 76 66 69 6c 65 22 0a 20 20 20 20 22 20 OM vfile". "
1230: 57 48 45 52 45 20 76 69 64 3d 25 64 22 2c 20 74 WHERE vid=%d", t
1240: 69 64 0a 20 20 29 3b 0a 20 20 77 68 69 6c 65 28 id. );. while(
1250: 20 64 62 5f 73 74 65 70 28 26 71 29 3d 3d 53 51 db_step(&q)==SQ
1260: 4c 49 54 45 5f 52 4f 57 20 29 7b 0a 20 20 20 20 LITE_ROW ){.
1270: 69 6e 74 20 69 64 20 3d 20 64 62 5f 63 6f 6c 75 int id = db_colu
1280: 6d 6e 5f 69 6e 74 28 26 71 2c 20 30 29 3b 0a 20 mn_int(&q, 0);.
1290: 20 20 20 63 6f 6e 73 74 20 63 68 61 72 20 2a 66 const char *f
12a0: 6e 20 3d 20 64 62 5f 63 6f 6c 75 6d 6e 5f 74 65 n = db_column_te
12b0: 78 74 28 26 71 2c 20 31 29 3b 0a 20 20 20 20 69 xt(&q, 1);. i
12c0: 6e 74 20 72 69 64 20 3d 20 64 62 5f 63 6f 6c 75 nt rid = db_colu
12d0: 6d 6e 5f 69 6e 74 28 26 71 2c 20 32 29 3b 0a 20 mn_int(&q, 2);.
12e0: 20 20 20 64 62 5f 6d 75 6c 74 69 5f 65 78 65 63 db_multi_exec
12f0: 28 0a 20 20 20 20 20 20 22 55 50 44 41 54 45 20 (. "UPDATE
1300: 66 76 20 53 45 54 20 69 64 74 3d 25 64 2c 20 72 fv SET idt=%d, r
1310: 69 64 74 3d 25 64 20 57 48 45 52 45 20 66 6e 3d idt=%d WHERE fn=
1320: 25 51 22 2c 0a 20 20 20 20 20 20 69 64 2c 20 72 %Q",. id, r
1330: 69 64 2c 20 66 6e 0a 20 20 20 20 29 3b 0a 20 20 id, fn. );.
1340: 7d 0a 20 20 64 62 5f 66 69 6e 61 6c 69 7a 65 28 }. db_finalize(
1350: 26 71 29 3b 0a 20 20 64 62 5f 70 72 65 70 61 72 &q);. db_prepar
1360: 65 28 26 71 2c 0a 20 20 20 20 22 53 45 4c 45 43 e(&q,. "SELEC
1370: 54 20 69 64 2c 20 70 61 74 68 6e 61 6d 65 2c 20 T id, pathname,
1380: 72 69 64 2c 20 63 68 6e 67 65 64 20 46 52 4f 4d rid, chnged FROM
1390: 20 76 66 69 6c 65 22 0a 20 20 20 20 22 20 57 48 vfile". " WH
13a0: 45 52 45 20 76 69 64 3d 25 64 22 2c 20 76 69 64 ERE vid=%d", vid
13b0: 0a 20 20 29 3b 0a 20 20 77 68 69 6c 65 28 20 64 . );. while( d
13c0: 62 5f 73 74 65 70 28 26 71 29 3d 3d 53 51 4c 49 b_step(&q)==SQLI
13d0: 54 45 5f 52 4f 57 20 29 7b 0a 20 20 20 20 69 6e TE_ROW ){. in
13e0: 74 20 69 64 20 3d 20 64 62 5f 63 6f 6c 75 6d 6e t id = db_column
13f0: 5f 69 6e 74 28 26 71 2c 20 30 29 3b 0a 20 20 20 _int(&q, 0);.
1400: 20 63 6f 6e 73 74 20 63 68 61 72 20 2a 66 6e 20 const char *fn
1410: 3d 20 64 62 5f 63 6f 6c 75 6d 6e 5f 74 65 78 74 = db_column_text
1420: 28 26 71 2c 20 31 29 3b 0a 20 20 20 20 69 6e 74 (&q, 1);. int
1430: 20 72 69 64 20 3d 20 64 62 5f 63 6f 6c 75 6d 6e rid = db_column
1440: 5f 69 6e 74 28 26 71 2c 20 32 29 3b 0a 20 20 20 _int(&q, 2);.
1450: 20 69 6e 74 20 63 68 6e 67 65 64 20 3d 20 64 62 int chnged = db
1460: 5f 63 6f 6c 75 6d 6e 5f 69 6e 74 28 26 71 2c 20 _column_int(&q,
1470: 33 29 3b 0a 20 20 20 20 64 62 5f 6d 75 6c 74 69 3);. db_multi
1480: 5f 65 78 65 63 28 0a 20 20 20 20 20 20 22 55 50 _exec(. "UP
1490: 44 41 54 45 20 66 76 20 53 45 54 20 69 64 76 3d DATE fv SET idv=
14a0: 25 64 2c 20 72 69 64 76 3d 25 64 2c 20 63 68 6e %d, ridv=%d, chn
14b0: 67 65 64 3d 25 64 20 57 48 45 52 45 20 66 6e 3d ged=%d WHERE fn=
14c0: 25 51 22 2c 0a 20 20 20 20 20 20 69 64 2c 20 72 %Q",. id, r
14d0: 69 64 2c 20 63 68 6e 67 65 64 2c 20 66 6e 0a 20 id, chnged, fn.
14e0: 20 20 20 29 3b 0a 20 20 7d 0a 20 20 64 62 5f 66 );. }. db_f
14f0: 69 6e 61 6c 69 7a 65 28 26 71 29 3b 0a 0a 20 20 inalize(&q);..
1500: 64 62 5f 70 72 65 70 61 72 65 28 26 71 2c 20 0a db_prepare(&q, .
1510: 20 20 20 20 22 53 45 4c 45 43 54 20 66 6e 2c 20 "SELECT fn,
1520: 69 64 76 2c 20 72 69 64 76 2c 20 69 64 74 2c 20 idv, ridv, idt,
1530: 72 69 64 74 2c 20 63 68 6e 67 65 64 20 46 52 4f ridt, chnged FRO
1540: 4d 20 66 76 20 4f 52 44 45 52 20 42 59 20 31 22 M fv ORDER BY 1"
1550: 0a 20 20 29 3b 0a 20 20 77 68 69 6c 65 28 20 64 . );. while( d
1560: 62 5f 73 74 65 70 28 26 71 29 3d 3d 53 51 4c 49 b_step(&q)==SQLI
1570: 54 45 5f 52 4f 57 20 29 7b 0a 20 20 20 20 63 6f TE_ROW ){. co
1580: 6e 73 74 20 63 68 61 72 20 2a 7a 4e 61 6d 65 20 nst char *zName
1590: 3d 20 64 62 5f 63 6f 6c 75 6d 6e 5f 74 65 78 74 = db_column_text
15a0: 28 26 71 2c 20 30 29 3b 0a 20 20 20 20 69 6e 74 (&q, 0);. int
15b0: 20 69 64 76 20 3d 20 64 62 5f 63 6f 6c 75 6d 6e idv = db_column
15c0: 5f 69 6e 74 28 26 71 2c 20 31 29 3b 0a 20 20 20 _int(&q, 1);.
15d0: 20 69 6e 74 20 72 69 64 76 20 3d 20 64 62 5f 63 int ridv = db_c
15e0: 6f 6c 75 6d 6e 5f 69 6e 74 28 26 71 2c 20 32 29 olumn_int(&q, 2)
15f0: 3b 0a 20 20 20 20 69 6e 74 20 69 64 74 20 3d 20 ;. int idt =
1600: 64 62 5f 63 6f 6c 75 6d 6e 5f 69 6e 74 28 26 71 db_column_int(&q
1610: 2c 20 33 29 3b 0a 20 20 20 20 69 6e 74 20 72 69 , 3);. int ri
1620: 64 74 20 3d 20 64 62 5f 63 6f 6c 75 6d 6e 5f 69 dt = db_column_i
1630: 6e 74 28 26 71 2c 20 34 29 3b 0a 20 20 20 20 69 nt(&q, 4);. i
1640: 6e 74 20 63 68 6e 67 65 64 20 3d 20 64 62 5f 63 nt chnged = db_c
1650: 6f 6c 75 6d 6e 5f 69 6e 74 28 26 71 2c 20 35 29 olumn_int(&q, 5)
1660: 3b 0a 0a 20 20 20 20 69 66 28 20 69 64 76 3e 30 ;.. if( idv>0
1670: 20 26 26 20 72 69 64 76 3d 3d 30 20 26 26 20 69 && ridv==0 && i
1680: 64 74 3e 30 20 29 7b 0a 20 20 20 20 20 20 2f 2a dt>0 ){. /*
1690: 20 43 6f 6e 66 6c 69 63 74 2e 20 20 54 68 69 73 Conflict. This
16a0: 20 66 69 6c 65 20 68 61 73 20 62 65 65 6e 20 61 file has been a
16b0: 64 64 65 64 20 74 6f 20 74 68 65 20 63 75 72 72 dded to the curr
16c0: 65 6e 74 20 63 68 65 63 6b 6f 75 74 0a 20 20 20 ent checkout.
16d0: 20 20 20 2a 2a 20 62 75 74 20 61 6c 73 6f 20 65 ** but also e
16e0: 78 69 73 74 73 20 69 6e 20 74 68 65 20 74 61 72 xists in the tar
16f0: 67 65 74 20 63 68 65 63 6b 6f 75 74 2e 20 20 55 get checkout. U
1700: 73 65 20 74 68 65 20 63 75 72 72 65 6e 74 20 76 se the current v
1710: 65 72 73 69 6f 6e 2e 0a 20 20 20 20 20 20 2a 2f ersion.. */
1720: 0a 20 20 20 20 20 20 70 72 69 6e 74 66 28 22 43 . printf("C
1730: 4f 4e 46 4c 49 43 54 20 25 73 5c 6e 22 2c 20 7a ONFLICT %s\n", z
1740: 4e 61 6d 65 29 3b 0a 20 20 20 20 7d 65 6c 73 65 Name);. }else
1750: 20 69 66 28 20 69 64 74 3e 30 20 26 26 20 69 64 if( idt>0 && id
1760: 76 3d 3d 30 20 29 7b 0a 20 20 20 20 20 20 2f 2a v==0 ){. /*
1770: 20 46 69 6c 65 20 61 64 64 65 64 20 69 6e 20 74 File added in t
1780: 68 65 20 74 61 72 67 65 74 2e 20 2a 2f 0a 20 20 he target. */.
1790: 20 20 20 20 70 72 69 6e 74 66 28 22 41 44 44 20 printf("ADD
17a0: 25 73 5c 6e 22 2c 20 7a 4e 61 6d 65 29 3b 0a 20 %s\n", zName);.
17b0: 20 20 20 20 20 75 6e 64 6f 5f 73 61 76 65 28 7a undo_save(z
17c0: 4e 61 6d 65 29 3b 0a 20 20 20 20 20 20 76 66 69 Name);. vfi
17d0: 6c 65 5f 74 6f 5f 64 69 73 6b 28 30 2c 20 69 64 le_to_disk(0, id
17e0: 74 2c 20 30 29 3b 0a 20 20 20 20 7d 65 6c 73 65 t, 0);. }else
17f0: 20 69 66 28 20 69 64 74 3e 30 20 26 26 20 69 64 if( idt>0 && id
1800: 76 3e 30 20 26 26 20 72 69 64 74 21 3d 72 69 64 v>0 && ridt!=rid
1810: 76 20 26 26 20 63 68 6e 67 65 64 3d 3d 30 20 29 v && chnged==0 )
1820: 7b 0a 20 20 20 20 20 20 2f 2a 20 54 68 65 20 66 {. /* The f
1830: 69 6c 65 20 69 73 20 75 6e 65 64 69 74 65 64 2e ile is unedited.
1840: 20 20 43 68 61 6e 67 65 20 69 74 20 74 6f 20 74 Change it to t
1850: 68 65 20 74 61 72 67 65 74 20 76 65 72 73 69 6f he target versio
1860: 6e 20 2a 2f 0a 20 20 20 20 20 20 70 72 69 6e 74 n */. print
1870: 66 28 22 55 50 44 41 54 45 20 25 73 5c 6e 22 2c f("UPDATE %s\n",
1880: 20 7a 4e 61 6d 65 29 3b 0a 20 20 20 20 20 20 75 zName);. u
1890: 6e 64 6f 5f 73 61 76 65 28 7a 4e 61 6d 65 29 3b ndo_save(zName);
18a0: 0a 20 20 20 20 20 20 76 66 69 6c 65 5f 74 6f 5f . vfile_to_
18b0: 64 69 73 6b 28 30 2c 20 69 64 74 2c 20 30 29 3b disk(0, idt, 0);
18c0: 0a 20 20 20 20 7d 65 6c 73 65 20 69 66 28 20 69 . }else if( i
18d0: 64 74 3d 3d 30 20 26 26 20 69 64 76 3e 30 20 29 dt==0 && idv>0 )
18e0: 7b 0a 20 20 20 20 20 20 69 66 28 20 63 68 6e 67 {. if( chng
18f0: 65 64 20 29 7b 0a 20 20 20 20 20 20 20 20 70 72 ed ){. pr
1900: 69 6e 74 66 28 22 43 4f 4e 46 4c 49 43 54 20 25 intf("CONFLICT %
1910: 73 5c 6e 22 2c 20 7a 4e 61 6d 65 29 3b 0a 20 20 s\n", zName);.
1920: 20 20 20 20 7d 65 6c 73 65 7b 0a 20 20 20 20 20 }else{.
1930: 20 20 20 63 68 61 72 20 2a 7a 46 75 6c 6c 50 61 char *zFullPa
1940: 74 68 3b 0a 20 20 20 20 20 20 20 20 70 72 69 6e th;. prin
1950: 74 66 28 22 52 45 4d 4f 56 45 20 25 73 5c 6e 22 tf("REMOVE %s\n"
1960: 2c 20 7a 4e 61 6d 65 29 3b 0a 20 20 20 20 20 20 , zName);.
1970: 20 20 75 6e 64 6f 5f 73 61 76 65 28 7a 4e 61 6d undo_save(zNam
1980: 65 29 3b 0a 20 20 20 20 20 20 20 20 7a 46 75 6c e);. zFul
1990: 6c 50 61 74 68 20 3d 20 6d 70 72 69 6e 74 66 28 lPath = mprintf(
19a0: 22 25 73 2f 25 73 22 2c 20 67 2e 7a 4c 6f 63 61 "%s/%s", g.zLoca
19b0: 6c 52 6f 6f 74 2c 20 7a 4e 61 6d 65 29 3b 0a 20 lRoot, zName);.
19c0: 20 20 20 20 20 20 20 75 6e 6c 69 6e 6b 28 7a 46 unlink(zF
19d0: 75 6c 6c 50 61 74 68 29 3b 0a 20 20 20 20 20 20 ullPath);.
19e0: 20 20 66 72 65 65 28 7a 46 75 6c 6c 50 61 74 68 free(zFullPath
19f0: 29 3b 0a 20 20 20 20 20 20 7d 0a 20 20 20 20 7d );. }. }
1a00: 65 6c 73 65 20 69 66 28 20 69 64 74 3e 30 20 26 else if( idt>0 &
1a10: 26 20 69 64 76 3e 30 20 26 26 20 72 69 64 74 21 & idv>0 && ridt!
1a20: 3d 72 69 64 76 20 26 26 20 63 68 6e 67 65 64 20 =ridv && chnged
1a30: 29 7b 0a 20 20 20 20 20 20 2f 2a 20 4d 65 72 67 ){. /* Merg
1a40: 65 20 74 68 65 20 63 68 61 6e 67 65 73 20 69 6e e the changes in
1a50: 20 74 68 65 20 63 75 72 72 65 6e 74 20 74 72 65 the current tre
1a60: 65 20 69 6e 74 6f 20 74 68 65 20 74 61 72 67 65 e into the targe
1a70: 74 20 76 65 72 73 69 6f 6e 20 2a 2f 0a 20 20 20 t version */.
1a80: 20 20 20 42 6c 6f 62 20 65 2c 20 72 2c 20 74 2c Blob e, r, t,
1a90: 20 76 3b 0a 20 20 20 20 20 20 69 6e 74 20 72 63 v;. int rc
1aa0: 3b 0a 20 20 20 20 20 20 63 68 61 72 20 2a 7a 46 ;. char *zF
1ab0: 75 6c 6c 50 61 74 68 3b 0a 20 20 20 20 20 20 70 ullPath;. p
1ac0: 72 69 6e 74 66 28 22 4d 45 52 47 45 20 25 73 5c rintf("MERGE %s\
1ad0: 6e 22 2c 20 7a 4e 61 6d 65 29 3b 0a 20 20 20 20 n", zName);.
1ae0: 20 20 75 6e 64 6f 5f 73 61 76 65 28 7a 4e 61 6d undo_save(zNam
1af0: 65 29 3b 0a 20 20 20 20 20 20 7a 46 75 6c 6c 50 e);. zFullP
1b00: 61 74 68 20 3d 20 6d 70 72 69 6e 74 66 28 22 25 ath = mprintf("%
1b10: 73 2f 25 73 22 2c 20 67 2e 7a 4c 6f 63 61 6c 52 s/%s", g.zLocalR
1b20: 6f 6f 74 2c 20 7a 4e 61 6d 65 29 3b 0a 20 20 20 oot, zName);.
1b30: 20 20 20 63 6f 6e 74 65 6e 74 5f 67 65 74 28 72 content_get(r
1b40: 69 64 74 2c 20 26 74 29 3b 0a 20 20 20 20 20 20 idt, &t);.
1b50: 63 6f 6e 74 65 6e 74 5f 67 65 74 28 72 69 64 76 content_get(ridv
1b60: 2c 20 26 76 29 3b 0a 20 20 20 20 20 20 62 6c 6f , &v);. blo
1b70: 62 5f 7a 65 72 6f 28 26 65 29 3b 0a 20 20 20 20 b_zero(&e);.
1b80: 20 20 62 6c 6f 62 5f 72 65 61 64 5f 66 72 6f 6d blob_read_from
1b90: 5f 66 69 6c 65 28 26 65 2c 20 7a 46 75 6c 6c 50 _file(&e, zFullP
1ba0: 61 74 68 29 3b 0a 20 20 20 20 20 20 72 63 20 3d ath);. rc =
1bb0: 20 62 6c 6f 62 5f 6d 65 72 67 65 28 26 76 2c 20 blob_merge(&v,
1bc0: 26 65 2c 20 26 74 2c 20 26 72 29 3b 0a 20 20 20 &e, &t, &r);.
1bd0: 20 20 20 69 66 28 20 72 63 3e 3d 30 20 29 7b 0a if( rc>=0 ){.
1be0: 20 20 20 20 20 20 20 20 62 6c 6f 62 5f 77 72 69 blob_wri
1bf0: 74 65 5f 74 6f 5f 66 69 6c 65 28 26 72 2c 20 7a te_to_file(&r, z
1c00: 46 75 6c 6c 50 61 74 68 29 3b 0a 20 20 20 20 20 FullPath);.
1c10: 20 20 20 69 66 28 20 72 63 3e 30 20 29 7b 0a 20 if( rc>0 ){.
1c20: 20 20 20 20 20 20 20 20 20 70 72 69 6e 74 66 28 printf(
1c30: 22 2a 2a 2a 2a 2a 20 25 64 20 6d 65 72 67 65 20 "***** %d merge
1c40: 63 6f 6e 66 6c 69 63 74 73 20 69 6e 20 25 73 5c conflicts in %s\
1c50: 6e 22 2c 20 72 63 2c 20 7a 4e 61 6d 65 29 3b 0a n", rc, zName);.
1c60: 20 20 20 20 20 20 20 20 7d 0a 20 20 20 20 20 20 }.
1c70: 7d 65 6c 73 65 7b 0a 20 20 20 20 20 20 20 20 70 }else{. p
1c80: 72 69 6e 74 66 28 22 2a 2a 2a 2a 2a 20 43 61 6e rintf("***** Can
1c90: 6e 6f 74 20 6d 65 72 67 65 20 62 69 6e 61 72 79 not merge binary
1ca0: 20 66 69 6c 65 20 25 73 5c 6e 22 2c 20 7a 4e 61 file %s\n", zNa
1cb0: 6d 65 29 3b 0a 20 20 20 20 20 20 7d 0a 20 20 20 me);. }.
1cc0: 20 20 20 66 72 65 65 28 7a 46 75 6c 6c 50 61 74 free(zFullPat
1cd0: 68 29 3b 0a 20 20 20 20 20 20 62 6c 6f 62 5f 72 h);. blob_r
1ce0: 65 73 65 74 28 26 76 29 3b 0a 20 20 20 20 20 20 eset(&v);.
1cf0: 62 6c 6f 62 5f 72 65 73 65 74 28 26 65 29 3b 0a blob_reset(&e);.
1d00: 20 20 20 20 20 20 62 6c 6f 62 5f 72 65 73 65 74 blob_reset
1d10: 28 26 74 29 3b 0a 20 20 20 20 20 20 62 6c 6f 62 (&t);. blob
1d20: 5f 72 65 73 65 74 28 26 72 29 3b 0a 20 20 20 20 _reset(&r);.
1d30: 20 20 0a 20 20 20 20 7d 0a 20 20 7d 0a 20 20 64 . }. }. d
1d40: 62 5f 66 69 6e 61 6c 69 7a 65 28 26 71 29 3b 0a b_finalize(&q);.
1d50: 20 20 0a 20 20 2f 2a 0a 20 20 2a 2a 20 43 6c 65 . /*. ** Cle
1d60: 61 6e 20 75 70 20 74 68 65 20 6d 69 64 20 61 6e an up the mid an
1d70: 64 20 70 69 64 20 56 46 49 4c 45 20 65 6e 74 72 d pid VFILE entr
1d80: 69 65 73 2e 20 20 54 68 65 6e 20 63 6f 6d 6d 69 ies. Then commi
1d90: 74 20 74 68 65 20 63 68 61 6e 67 65 73 2e 0a 20 t the changes..
1da0: 20 2a 2f 0a 20 20 64 62 5f 6d 75 6c 74 69 5f 65 */. db_multi_e
1db0: 78 65 63 28 22 44 45 4c 45 54 45 20 46 52 4f 4d xec("DELETE FROM
1dc0: 20 76 66 69 6c 65 20 57 48 45 52 45 20 76 69 64 vfile WHERE vid
1dd0: 21 3d 25 64 22 2c 20 74 69 64 29 3b 0a 20 20 6d !=%d", tid);. m
1de0: 61 6e 69 66 65 73 74 5f 74 6f 5f 64 69 73 6b 28 anifest_to_disk(
1df0: 74 69 64 29 3b 0a 20 20 64 62 5f 6c 73 65 74 5f tid);. db_lset_
1e00: 69 6e 74 28 22 63 68 65 63 6b 6f 75 74 22 2c 20 int("checkout",
1e10: 74 69 64 29 3b 0a 20 20 64 62 5f 65 6e 64 5f 74 tid);. db_end_t
1e20: 72 61 6e 73 61 63 74 69 6f 6e 28 30 29 3b 0a 7d ransaction(0);.}
1e30: 0a 0a 0a 2f 2a 0a 2a 2a 20 47 65 74 20 74 68 65 .../*.** Get the
1e40: 20 63 6f 6e 74 65 6e 74 73 20 6f 66 20 61 20 66 contents of a f
1e50: 69 6c 65 20 77 69 74 68 69 6e 20 61 20 67 69 76 ile within a giv
1e60: 65 6e 20 72 65 76 69 73 69 6f 6e 2e 0a 2a 2f 0a en revision..*/.
1e70: 69 6e 74 20 68 69 73 74 6f 72 69 63 61 6c 5f 76 int historical_v
1e80: 65 72 73 69 6f 6e 5f 6f 66 5f 66 69 6c 65 28 0a ersion_of_file(.
1e90: 20 20 63 6f 6e 73 74 20 63 68 61 72 20 2a 72 65 const char *re
1ea0: 76 69 73 69 6f 6e 2c 20 20 20 20 2f 2a 20 54 68 vision, /* Th
1eb0: 65 20 62 61 73 65 6c 69 6e 65 20 6e 61 6d 65 20 e baseline name
1ec0: 63 6f 6e 74 61 69 6e 69 6e 67 20 74 68 65 20 66 containing the f
1ed0: 69 6c 65 20 2a 2f 0a 20 20 63 6f 6e 73 74 20 63 ile */. const c
1ee0: 68 61 72 20 2a 66 69 6c 65 2c 20 20 20 20 20 20 har *file,
1ef0: 20 20 2f 2a 20 46 75 6c 6c 20 74 72 65 65 6e 61 /* Full treena
1f00: 6d 65 20 6f 66 20 74 68 65 20 66 69 6c 65 20 2a me of the file *
1f10: 2f 0a 20 20 42 6c 6f 62 20 2a 63 6f 6e 74 65 6e /. Blob *conten
1f20: 74 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 t /*
1f30: 50 75 74 20 74 68 65 20 63 6f 6e 74 65 6e 74 20 Put the content
1f40: 68 65 72 65 20 2a 2f 0a 29 7b 0a 20 20 42 6c 6f here */.){. Blo
1f50: 62 20 6d 66 69 6c 65 3b 0a 20 20 4d 61 6e 69 66 b mfile;. Manif
1f60: 65 73 74 20 6d 3b 0a 20 20 69 6e 74 20 69 2c 20 est m;. int i,
1f70: 72 69 64 3d 30 3b 0a 20 20 0a 20 20 72 69 64 20 rid=0;. . rid
1f80: 3d 20 6e 61 6d 65 5f 74 6f 5f 72 69 64 28 72 65 = name_to_rid(re
1f90: 76 69 73 69 6f 6e 29 3b 0a 20 20 63 6f 6e 74 65 vision);. conte
1fa0: 6e 74 5f 67 65 74 28 72 69 64 2c 20 26 6d 66 69 nt_get(rid, &mfi
1fb0: 6c 65 29 3b 0a 20 20 0a 20 20 69 66 28 20 6d 61 le);. . if( ma
1fc0: 6e 69 66 65 73 74 5f 70 61 72 73 65 28 26 6d 2c nifest_parse(&m,
1fd0: 20 26 6d 66 69 6c 65 29 20 29 7b 0a 20 20 20 20 &mfile) ){.
1fe0: 66 6f 72 28 69 3d 30 3b 20 69 3c 6d 2e 6e 46 69 for(i=0; i<m.nFi
1ff0: 6c 65 3b 20 69 2b 2b 29 7b 0a 20 20 20 20 20 20 le; i++){.
2000: 69 66 28 20 73 74 72 63 6d 70 28 6d 2e 61 46 69 if( strcmp(m.aFi
2010: 6c 65 5b 69 5d 2e 7a 4e 61 6d 65 2c 20 66 69 6c le[i].zName, fil
2020: 65 29 3d 3d 30 20 29 7b 0a 20 20 20 20 20 20 20 e)==0 ){.
2030: 20 72 69 64 20 3d 20 75 75 69 64 5f 74 6f 5f 72 rid = uuid_to_r
2040: 69 64 28 6d 2e 61 46 69 6c 65 5b 69 5d 2e 7a 55 id(m.aFile[i].zU
2050: 75 69 64 2c 20 30 29 3b 0a 20 20 20 20 20 20 20 uid, 0);.
2060: 20 72 65 74 75 72 6e 20 63 6f 6e 74 65 6e 74 5f return content_
2070: 67 65 74 28 72 69 64 2c 20 63 6f 6e 74 65 6e 74 get(rid, content
2080: 29 3b 0a 20 20 20 20 20 20 7d 0a 20 20 20 20 7d );. }. }
2090: 0a 20 20 20 20 66 6f 73 73 69 6c 5f 66 61 74 61 . fossil_fata
20a0: 6c 28 22 66 69 6c 65 20 25 73 20 64 6f 65 73 20 l("file %s does
20b0: 6e 6f 74 20 65 78 69 73 74 20 69 6e 20 62 61 73 not exist in bas
20c0: 65 6c 69 6e 65 3a 20 25 73 22 2c 20 66 69 6c 65 eline: %s", file
20d0: 2c 20 72 65 76 69 73 69 6f 6e 29 3b 0a 20 20 7d , revision);. }
20e0: 65 6c 73 65 7b 0a 20 20 20 20 66 6f 73 73 69 6c else{. fossil
20f0: 5f 70 61 6e 69 63 28 22 63 6f 75 6c 64 20 6e 6f _panic("could no
2100: 74 20 70 61 72 73 65 20 6d 61 6e 69 66 65 73 74 t parse manifest
2110: 20 66 6f 72 20 62 61 73 65 6c 69 6e 65 3a 20 25 for baseline: %
2120: 73 22 2c 20 72 65 76 69 73 69 6f 6e 29 3b 0a 20 s", revision);.
2130: 20 7d 0a 20 20 72 65 74 75 72 6e 20 30 3b 0a 7d }. return 0;.}
2140: 0a 0a 0a 2f 2a 0a 2a 2a 20 43 4f 4d 4d 41 4e 44 .../*.** COMMAND
2150: 3a 20 72 65 76 65 72 74 0a 2a 2a 0a 2a 2a 20 55 : revert.**.** U
2160: 73 61 67 65 3a 20 25 66 6f 73 73 69 6c 20 72 65 sage: %fossil re
2170: 76 65 72 74 20 3f 2d 2d 79 65 73 3f 20 3f 2d 72 vert ?--yes? ?-r
2180: 20 52 45 56 49 53 49 4f 4e 3f 20 46 49 4c 45 0a REVISION? FILE.
2190: 2a 2a 0a 2a 2a 20 52 65 76 65 72 74 20 74 6f 20 **.** Revert to
21a0: 74 68 65 20 63 75 72 72 65 6e 74 20 72 65 70 6f the current repo
21b0: 73 69 74 6f 72 79 20 76 65 72 73 69 6f 6e 20 6f sitory version o
21c0: 66 20 46 49 4c 45 2c 20 6f 72 20 74 6f 0a 2a 2a f FILE, or to.**
21d0: 20 74 68 65 20 76 65 72 73 69 6f 6e 20 61 73 73 the version ass
21e0: 6f 63 69 61 74 65 64 20 77 69 74 68 20 62 61 73 ociated with bas
21f0: 65 6c 69 6e 65 20 52 45 56 49 53 49 4f 4e 20 69 eline REVISION i
2200: 66 20 74 68 65 20 2d 72 20 66 6c 61 67 0a 2a 2a f the -r flag.**
2210: 20 61 70 70 65 61 72 73 2e 20 20 54 68 69 73 20 appears. This
2220: 63 6f 6d 6d 61 6e 64 20 77 69 6c 6c 20 63 6f 6e command will con
2230: 66 69 72 6d 20 79 6f 75 72 20 6f 70 65 72 61 74 firm your operat
2240: 69 6f 6e 20 75 6e 6c 65 73 73 20 74 68 65 0a 2a ion unless the.*
2250: 2a 20 66 69 6c 65 20 69 73 20 6d 69 73 73 69 6e * file is missin
2260: 67 20 6f 72 20 74 68 65 20 2d 2d 79 65 73 20 6f g or the --yes o
2270: 70 74 69 6f 6e 20 69 73 20 75 73 65 64 2e 0a 2a ption is used..*
2280: 2a 2f 0a 76 6f 69 64 20 72 65 76 65 72 74 5f 63 */.void revert_c
2290: 6d 64 28 76 6f 69 64 29 7b 0a 20 20 63 6f 6e 73 md(void){. cons
22a0: 74 20 63 68 61 72 20 2a 7a 46 69 6c 65 3b 0a 20 t char *zFile;.
22b0: 20 63 6f 6e 73 74 20 63 68 61 72 20 2a 7a 52 65 const char *zRe
22c0: 76 69 73 69 6f 6e 3b 0a 20 20 42 6c 6f 62 20 66 vision;. Blob f
22d0: 6e 61 6d 65 3b 0a 20 20 42 6c 6f 62 20 72 65 63 name;. Blob rec
22e0: 6f 72 64 3b 0a 20 20 42 6c 6f 62 20 61 6e 73 3b ord;. Blob ans;
22f0: 0a 20 20 69 6e 74 20 72 69 64 20 3d 20 30 2c 20 . int rid = 0,
2300: 79 65 73 52 65 76 65 72 74 3b 0a 20 20 0a 20 20 yesRevert;. .
2310: 79 65 73 52 65 76 65 72 74 20 3d 20 66 69 6e 64 yesRevert = find
2320: 5f 6f 70 74 69 6f 6e 28 22 79 65 73 22 2c 20 22 _option("yes", "
2330: 79 22 2c 20 30 29 21 3d 30 3b 0a 20 20 7a 52 65 y", 0)!=0;. zRe
2340: 76 69 73 69 6f 6e 20 3d 20 66 69 6e 64 5f 6f 70 vision = find_op
2350: 74 69 6f 6e 28 22 72 65 76 69 73 69 6f 6e 22 2c tion("revision",
2360: 20 22 72 22 2c 20 31 29 3b 0a 20 20 76 65 72 69 "r", 1);. veri
2370: 66 79 5f 61 6c 6c 5f 6f 70 74 69 6f 6e 73 28 29 fy_all_options()
2380: 3b 0a 20 20 0a 20 20 69 66 28 20 67 2e 61 72 67 ;. . if( g.arg
2390: 63 3c 33 20 29 7b 0a 20 20 20 20 75 73 61 67 65 c<3 ){. usage
23a0: 28 22 3f 4f 50 54 49 4f 4e 53 20 46 49 4c 45 22 ("?OPTIONS FILE"
23b0: 29 3b 0a 20 20 7d 0a 20 20 64 62 5f 6d 75 73 74 );. }. db_must
23c0: 5f 62 65 5f 77 69 74 68 69 6e 5f 74 72 65 65 28 _be_within_tree(
23d0: 29 3b 0a 20 20 0a 20 20 7a 46 69 6c 65 20 3d 20 );. . zFile =
23e0: 6d 70 72 69 6e 74 66 28 22 25 2f 22 2c 20 67 2e mprintf("%/", g.
23f0: 61 72 67 76 5b 67 2e 61 72 67 63 2d 31 5d 29 3b argv[g.argc-1]);
2400: 0a 0a 20 20 66 69 6c 65 5f 74 72 65 65 5f 6e 61 .. file_tree_na
2410: 6d 65 28 7a 46 69 6c 65 2c 20 26 66 6e 61 6d 65 me(zFile, &fname
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 .}.