Hex Artifact Content
Not logged in

Artifact fe0fcda1069a016540d31d56583c0a55520fc59e:

File src/checkin.c part of check-in [e2a42f7a68] - Error message on "commit" or "user default" if the user does not exist. by drh on 2008-01-29 01:11:27.

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 63 68 65 63 6b 2d 6f 75 74  sed to check-out
0390: 20 76 65 72 73 69 6f 6e 73 20 6f 66 20 74 68 65   versions of the
03a0: 20 70 72 6f 6a 65 63 74 0a 2a 2a 20 66 72 6f 6d   project.** from
03b0: 20 74 68 65 20 6c 6f 63 61 6c 20 72 65 70 6f 73   the local repos
03c0: 69 74 6f 72 79 2e 0a 2a 2f 0a 23 69 6e 63 6c 75  itory..*/.#inclu
03d0: 64 65 20 22 63 6f 6e 66 69 67 2e 68 22 0a 23 69  de "config.h".#i
03e0: 6e 63 6c 75 64 65 20 22 63 68 65 63 6b 69 6e 2e  nclude "checkin.
03f0: 68 22 0a 23 69 6e 63 6c 75 64 65 20 3c 61 73 73  h".#include <ass
0400: 65 72 74 2e 68 3e 0a 0a 2f 2a 0a 2a 2a 20 47 65  ert.h>../*.** Ge
0410: 6e 65 72 61 74 65 20 74 65 78 74 20 64 65 73 63  nerate text desc
0420: 72 69 62 69 6e 67 20 61 6c 6c 20 63 68 61 6e 67  ribing all chang
0430: 65 73 2e 20 20 50 72 65 70 65 6e 64 20 7a 50 72  es.  Prepend zPr
0440: 65 66 69 78 20 74 6f 20 65 61 63 68 20 6c 69 6e  efix to each lin
0450: 65 0a 2a 2a 20 6f 66 20 6f 75 74 70 75 74 2e 0a  e.** of output..
0460: 2a 2a 0a 2a 2a 20 57 65 20 61 73 73 75 6d 65 20  **.** We assume 
0470: 74 68 61 74 20 76 66 69 6c 65 5f 63 68 65 63 6b  that vfile_check
0480: 5f 73 69 67 6e 61 74 75 72 65 20 68 61 73 20 62  _signature has b
0490: 65 65 6e 20 72 75 6e 2e 0a 2a 2f 0a 73 74 61 74  een run..*/.stat
04a0: 69 63 20 76 6f 69 64 20 73 74 61 74 75 73 5f 72  ic void status_r
04b0: 65 70 6f 72 74 28 42 6c 6f 62 20 2a 72 65 70 6f  eport(Blob *repo
04c0: 72 74 2c 20 63 6f 6e 73 74 20 63 68 61 72 20 2a  rt, const char *
04d0: 7a 50 72 65 66 69 78 29 7b 0a 20 20 53 74 6d 74  zPrefix){.  Stmt
04e0: 20 71 3b 0a 20 20 69 6e 74 20 6e 50 72 65 66 69   q;.  int nPrefi
04f0: 78 20 3d 20 73 74 72 6c 65 6e 28 7a 50 72 65 66  x = strlen(zPref
0500: 69 78 29 3b 0a 20 20 64 62 5f 70 72 65 70 61 72  ix);.  db_prepar
0510: 65 28 26 71 2c 20 0a 20 20 20 20 22 53 45 4c 45  e(&q, .    "SELE
0520: 43 54 20 70 61 74 68 6e 61 6d 65 2c 20 64 65 6c  CT pathname, del
0530: 65 74 65 64 2c 20 63 68 6e 67 65 64 2c 20 72 69  eted, chnged, ri
0540: 64 20 46 52 4f 4d 20 76 66 69 6c 65 20 22 0a 20  d FROM vfile ". 
0550: 20 20 20 22 57 48 45 52 45 20 66 69 6c 65 5f 69     "WHERE file_i
0560: 73 5f 73 65 6c 65 63 74 65 64 28 69 64 29 20 41  s_selected(id) A
0570: 4e 44 20 28 63 68 6e 67 65 64 20 4f 52 20 64 65  ND (chnged OR de
0580: 6c 65 74 65 64 20 4f 52 20 72 69 64 3d 30 29 20  leted OR rid=0) 
0590: 4f 52 44 45 52 20 42 59 20 31 22 0a 20 20 29 3b  ORDER BY 1".  );
05a0: 0a 20 20 77 68 69 6c 65 28 20 64 62 5f 73 74 65  .  while( db_ste
05b0: 70 28 26 71 29 3d 3d 53 51 4c 49 54 45 5f 52 4f  p(&q)==SQLITE_RO
05c0: 57 20 29 7b 0a 20 20 20 20 63 6f 6e 73 74 20 63  W ){.    const c
05d0: 68 61 72 20 2a 7a 50 61 74 68 6e 61 6d 65 20 3d  har *zPathname =
05e0: 20 64 62 5f 63 6f 6c 75 6d 6e 5f 74 65 78 74 28   db_column_text(
05f0: 26 71 2c 30 29 3b 0a 20 20 20 20 69 6e 74 20 69  &q,0);.    int i
0600: 73 44 65 6c 65 74 65 64 20 3d 20 64 62 5f 63 6f  sDeleted = db_co
0610: 6c 75 6d 6e 5f 69 6e 74 28 26 71 2c 20 31 29 3b  lumn_int(&q, 1);
0620: 0a 20 20 20 20 69 6e 74 20 69 73 43 68 6e 67 65  .    int isChnge
0630: 64 20 3d 20 64 62 5f 63 6f 6c 75 6d 6e 5f 69 6e  d = db_column_in
0640: 74 28 26 71 2c 32 29 3b 0a 20 20 20 20 69 6e 74  t(&q,2);.    int
0650: 20 69 73 4e 65 77 20 3d 20 64 62 5f 63 6f 6c 75   isNew = db_colu
0660: 6d 6e 5f 69 6e 74 28 26 71 2c 33 29 3d 3d 30 3b  mn_int(&q,3)==0;
0670: 0a 20 20 20 20 63 68 61 72 20 2a 7a 46 75 6c 6c  .    char *zFull
0680: 4e 61 6d 65 20 3d 20 6d 70 72 69 6e 74 66 28 22  Name = mprintf("
0690: 25 73 2f 25 73 22 2c 20 67 2e 7a 4c 6f 63 61 6c  %s/%s", g.zLocal
06a0: 52 6f 6f 74 2c 20 7a 50 61 74 68 6e 61 6d 65 29  Root, zPathname)
06b0: 3b 0a 20 20 20 20 62 6c 6f 62 5f 61 70 70 65 6e  ;.    blob_appen
06c0: 64 28 72 65 70 6f 72 74 2c 20 7a 50 72 65 66 69  d(report, zPrefi
06d0: 78 2c 20 6e 50 72 65 66 69 78 29 3b 0a 20 20 20  x, nPrefix);.   
06e0: 20 69 66 28 20 61 63 63 65 73 73 28 7a 46 75 6c   if( access(zFul
06f0: 6c 4e 61 6d 65 2c 20 30 29 20 29 7b 0a 20 20 20  lName, 0) ){.   
0700: 20 20 20 62 6c 6f 62 5f 61 70 70 65 6e 64 66 28     blob_appendf(
0710: 72 65 70 6f 72 74 2c 20 22 4d 49 53 53 49 4e 47  report, "MISSING
0720: 20 20 25 73 5c 6e 22 2c 20 7a 50 61 74 68 6e 61    %s\n", zPathna
0730: 6d 65 29 3b 0a 20 20 20 20 7d 65 6c 73 65 20 69  me);.    }else i
0740: 66 28 20 69 73 4e 65 77 20 29 7b 0a 20 20 20 20  f( isNew ){.    
0750: 20 20 62 6c 6f 62 5f 61 70 70 65 6e 64 66 28 72    blob_appendf(r
0760: 65 70 6f 72 74 2c 20 22 41 44 44 45 44 20 20 20  eport, "ADDED   
0770: 20 25 73 5c 6e 22 2c 20 7a 50 61 74 68 6e 61 6d   %s\n", zPathnam
0780: 65 29 3b 0a 20 20 20 20 7d 65 6c 73 65 20 69 66  e);.    }else if
0790: 28 20 69 73 44 65 6c 65 74 65 64 20 29 7b 0a 20  ( isDeleted ){. 
07a0: 20 20 20 20 20 62 6c 6f 62 5f 61 70 70 65 6e 64       blob_append
07b0: 66 28 72 65 70 6f 72 74 2c 20 22 44 45 4c 45 54  f(report, "DELET
07c0: 45 44 20 20 25 73 5c 6e 22 2c 20 7a 50 61 74 68  ED  %s\n", zPath
07d0: 6e 61 6d 65 29 3b 0a 20 20 20 20 7d 65 6c 73 65  name);.    }else
07e0: 20 69 66 28 20 69 73 43 68 6e 67 65 64 3d 3d 32   if( isChnged==2
07f0: 20 29 7b 0a 20 20 20 20 20 20 62 6c 6f 62 5f 61   ){.      blob_a
0800: 70 70 65 6e 64 66 28 72 65 70 6f 72 74 2c 20 22  ppendf(report, "
0810: 55 50 44 41 54 45 44 5f 42 59 5f 4d 45 52 47 45  UPDATED_BY_MERGE
0820: 20 25 73 5c 6e 22 2c 20 7a 50 61 74 68 6e 61 6d   %s\n", zPathnam
0830: 65 29 3b 0a 20 20 20 20 7d 65 6c 73 65 20 69 66  e);.    }else if
0840: 28 20 69 73 43 68 6e 67 65 64 3d 3d 33 20 29 7b  ( isChnged==3 ){
0850: 0a 20 20 20 20 20 20 62 6c 6f 62 5f 61 70 70 65  .      blob_appe
0860: 6e 64 66 28 72 65 70 6f 72 74 2c 20 22 41 44 44  ndf(report, "ADD
0870: 45 44 5f 42 59 5f 4d 45 52 47 45 20 25 73 5c 6e  ED_BY_MERGE %s\n
0880: 22 2c 20 7a 50 61 74 68 6e 61 6d 65 29 3b 0a 20  ", zPathname);. 
0890: 20 20 20 7d 65 6c 73 65 7b 0a 20 20 20 20 20 20     }else{.      
08a0: 62 6c 6f 62 5f 61 70 70 65 6e 64 66 28 72 65 70  blob_appendf(rep
08b0: 6f 72 74 2c 20 22 45 44 49 54 45 44 20 20 20 25  ort, "EDITED   %
08c0: 73 5c 6e 22 2c 20 7a 50 61 74 68 6e 61 6d 65 29  s\n", zPathname)
08d0: 3b 0a 20 20 20 20 7d 0a 20 20 20 20 66 72 65 65  ;.    }.    free
08e0: 28 7a 46 75 6c 6c 4e 61 6d 65 29 3b 0a 20 20 7d  (zFullName);.  }
08f0: 0a 20 20 64 62 5f 66 69 6e 61 6c 69 7a 65 28 26  .  db_finalize(&
0900: 71 29 3b 0a 20 20 64 62 5f 70 72 65 70 61 72 65  q);.  db_prepare
0910: 28 26 71 2c 20 22 53 45 4c 45 43 54 20 75 75 69  (&q, "SELECT uui
0920: 64 20 46 52 4f 4d 20 76 6d 65 72 67 65 20 4a 4f  d FROM vmerge JO
0930: 49 4e 20 62 6c 6f 62 20 4f 4e 20 6d 65 72 67 65  IN blob ON merge
0940: 3d 72 69 64 22 0a 20 20 20 20 20 20 20 20 20 20  =rid".          
0950: 20 20 20 20 20 20 20 22 20 57 48 45 52 45 20 69         " WHERE i
0960: 64 3d 30 22 29 3b 0a 20 20 77 68 69 6c 65 28 20  d=0");.  while( 
0970: 64 62 5f 73 74 65 70 28 26 71 29 3d 3d 53 51 4c  db_step(&q)==SQL
0980: 49 54 45 5f 52 4f 57 20 29 7b 0a 20 20 20 20 62  ITE_ROW ){.    b
0990: 6c 6f 62 5f 61 70 70 65 6e 64 28 72 65 70 6f 72  lob_append(repor
09a0: 74 2c 20 7a 50 72 65 66 69 78 2c 20 6e 50 72 65  t, zPrefix, nPre
09b0: 66 69 78 29 3b 0a 20 20 20 20 62 6c 6f 62 5f 61  fix);.    blob_a
09c0: 70 70 65 6e 64 66 28 72 65 70 6f 72 74 2c 20 22  ppendf(report, "
09d0: 4d 45 52 47 45 44 5f 57 49 54 48 20 25 73 5c 6e  MERGED_WITH %s\n
09e0: 22 2c 20 64 62 5f 63 6f 6c 75 6d 6e 5f 74 65 78  ", db_column_tex
09f0: 74 28 26 71 2c 20 30 29 29 3b 0a 20 20 7d 0a 20  t(&q, 0));.  }. 
0a00: 20 64 62 5f 66 69 6e 61 6c 69 7a 65 28 26 71 29   db_finalize(&q)
0a10: 3b 0a 7d 0a 0a 2f 2a 0a 2a 2a 20 43 4f 4d 4d 41  ;.}../*.** COMMA
0a20: 4e 44 3a 20 63 68 61 6e 67 65 73 0a 2a 2a 0a 2a  ND: changes.**.*
0a30: 2a 20 55 73 61 67 65 3a 20 25 66 6f 73 73 69 6c  * Usage: %fossil
0a40: 20 63 68 61 6e 67 65 73 0a 2a 2a 20 52 65 70 6f   changes.** Repo
0a50: 72 74 20 6f 6e 20 74 68 65 20 65 64 69 74 20 73  rt on the edit s
0a60: 74 61 74 75 73 20 6f 66 20 61 6c 6c 20 66 69 6c  tatus of all fil
0a70: 65 73 20 69 6e 20 74 68 65 20 63 75 72 72 65 6e  es in the curren
0a80: 74 20 63 68 65 63 6b 6f 75 74 2e 0a 2a 2a 20 53  t checkout..** S
0a90: 65 65 20 61 6c 73 6f 20 74 68 65 20 22 73 74 61  ee also the "sta
0aa0: 74 75 73 22 20 61 6e 64 20 22 65 78 74 72 61 22  tus" and "extra"
0ab0: 20 63 6f 6d 6d 61 6e 64 73 2e 0a 2a 2f 0a 76 6f   commands..*/.vo
0ac0: 69 64 20 63 68 61 6e 67 65 73 5f 63 6d 64 28 76  id changes_cmd(v
0ad0: 6f 69 64 29 7b 0a 20 20 42 6c 6f 62 20 72 65 70  oid){.  Blob rep
0ae0: 6f 72 74 3b 0a 20 20 69 6e 74 20 76 69 64 3b 0a  ort;.  int vid;.
0af0: 20 20 64 62 5f 6d 75 73 74 5f 62 65 5f 77 69 74    db_must_be_wit
0b00: 68 69 6e 5f 74 72 65 65 28 29 3b 0a 20 20 62 6c  hin_tree();.  bl
0b10: 6f 62 5f 7a 65 72 6f 28 26 72 65 70 6f 72 74 29  ob_zero(&report)
0b20: 3b 0a 20 20 76 69 64 20 3d 20 64 62 5f 6c 67 65  ;.  vid = db_lge
0b30: 74 5f 69 6e 74 28 22 63 68 65 63 6b 6f 75 74 22  t_int("checkout"
0b40: 2c 20 30 29 3b 0a 20 20 76 66 69 6c 65 5f 63 68  , 0);.  vfile_ch
0b50: 65 63 6b 5f 73 69 67 6e 61 74 75 72 65 28 76 69  eck_signature(vi
0b60: 64 29 3b 0a 20 20 73 74 61 74 75 73 5f 72 65 70  d);.  status_rep
0b70: 6f 72 74 28 26 72 65 70 6f 72 74 2c 20 22 22 29  ort(&report, "")
0b80: 3b 0a 20 20 62 6c 6f 62 5f 77 72 69 74 65 5f 74  ;.  blob_write_t
0b90: 6f 5f 66 69 6c 65 28 26 72 65 70 6f 72 74 2c 20  o_file(&report, 
0ba0: 22 2d 22 29 3b 0a 7d 0a 0a 2f 2a 0a 2a 2a 20 43  "-");.}../*.** C
0bb0: 4f 4d 4d 41 4e 44 3a 20 73 74 61 74 75 73 0a 2a  OMMAND: status.*
0bc0: 2a 20 55 73 61 67 65 3a 20 25 66 6f 73 73 69 6c  * Usage: %fossil
0bd0: 20 73 74 61 74 75 73 0a 2a 2a 20 52 65 70 6f 72   status.** Repor
0be0: 74 20 6f 6e 20 74 68 65 20 73 74 61 74 75 73 20  t on the status 
0bf0: 6f 66 20 74 68 65 20 63 75 72 72 65 6e 74 20 63  of the current c
0c00: 68 65 63 6b 6f 75 74 2e 0a 2a 2f 0a 76 6f 69 64  heckout..*/.void
0c10: 20 73 74 61 74 75 73 5f 63 6d 64 28 76 6f 69 64   status_cmd(void
0c20: 29 7b 0a 20 20 69 6e 74 20 76 69 64 3b 0a 20 20  ){.  int vid;.  
0c30: 64 62 5f 6d 75 73 74 5f 62 65 5f 77 69 74 68 69  db_must_be_withi
0c40: 6e 5f 74 72 65 65 28 29 3b 0a 20 20 20 20 20 20  n_tree();.      
0c50: 20 2f 2a 20 30 31 32 33 34 35 36 37 38 39 30 31   /* 012345678901
0c60: 32 33 34 20 2a 2f 0a 20 20 70 72 69 6e 74 66 28  234 */.  printf(
0c70: 22 72 65 70 6f 73 69 74 6f 72 79 3a 20 20 20 25  "repository:   %
0c80: 73 5c 6e 22 2c 20 64 62 5f 6c 67 65 74 28 22 72  s\n", db_lget("r
0c90: 65 70 6f 73 69 74 6f 72 79 22 2c 22 22 29 29 3b  epository",""));
0ca0: 0a 20 20 70 72 69 6e 74 66 28 22 6c 6f 63 61 6c  .  printf("local
0cb0: 2d 72 6f 6f 74 3a 20 20 20 25 73 5c 6e 22 2c 20  -root:   %s\n", 
0cc0: 67 2e 7a 4c 6f 63 61 6c 52 6f 6f 74 29 3b 0a 20  g.zLocalRoot);. 
0cd0: 20 70 72 69 6e 74 66 28 22 73 65 72 76 65 72 2d   printf("server-
0ce0: 63 6f 64 65 3a 20 20 25 73 5c 6e 22 2c 20 64 62  code:  %s\n", db
0cf0: 5f 67 65 74 28 22 73 65 72 76 65 72 2d 63 6f 64  _get("server-cod
0d00: 65 22 2c 20 22 22 29 29 3b 0a 20 20 76 69 64 20  e", ""));.  vid 
0d10: 3d 20 64 62 5f 6c 67 65 74 5f 69 6e 74 28 22 63  = db_lget_int("c
0d20: 68 65 63 6b 6f 75 74 22 2c 20 30 29 3b 0a 20 20  heckout", 0);.  
0d30: 69 66 28 20 76 69 64 20 29 7b 0a 20 20 20 20 73  if( vid ){.    s
0d40: 68 6f 77 5f 63 6f 6d 6d 6f 6e 5f 69 6e 66 6f 28  how_common_info(
0d50: 76 69 64 2c 20 22 63 68 65 63 6b 6f 75 74 3a 22  vid, "checkout:"
0d60: 2c 20 30 29 3b 0a 20 20 7d 0a 20 20 63 68 61 6e  , 0);.  }.  chan
0d70: 67 65 73 5f 63 6d 64 28 29 3b 0a 7d 0a 0a 2f 2a  ges_cmd();.}../*
0d80: 0a 2a 2a 20 43 4f 4d 4d 41 4e 44 3a 20 6c 73 0a  .** COMMAND: ls.
0d90: 2a 2a 20 55 73 61 67 65 3a 20 25 66 6f 73 73 69  ** Usage: %fossi
0da0: 6c 20 6c 73 0a 2a 2a 20 53 68 6f 77 20 74 68 65  l ls.** Show the
0db0: 20 6e 61 6d 65 73 20 6f 66 20 61 6c 6c 20 66 69   names of all fi
0dc0: 6c 65 73 20 69 6e 20 74 68 65 20 63 75 72 72 65  les in the curre
0dd0: 6e 74 20 63 68 65 63 6b 6f 75 74 0a 2a 2f 0a 76  nt checkout.*/.v
0de0: 6f 69 64 20 6c 73 5f 63 6d 64 28 76 6f 69 64 29  oid ls_cmd(void)
0df0: 7b 0a 20 20 69 6e 74 20 76 69 64 3b 0a 20 20 53  {.  int vid;.  S
0e00: 74 6d 74 20 71 3b 0a 0a 20 20 64 62 5f 6d 75 73  tmt q;..  db_mus
0e10: 74 5f 62 65 5f 77 69 74 68 69 6e 5f 74 72 65 65  t_be_within_tree
0e20: 28 29 3b 0a 20 20 76 69 64 20 3d 20 64 62 5f 6c  ();.  vid = db_l
0e30: 67 65 74 5f 69 6e 74 28 22 63 68 65 63 6b 6f 75  get_int("checkou
0e40: 74 22 2c 20 30 29 3b 0a 20 20 76 66 69 6c 65 5f  t", 0);.  vfile_
0e50: 63 68 65 63 6b 5f 73 69 67 6e 61 74 75 72 65 28  check_signature(
0e60: 76 69 64 29 3b 0a 20 20 64 62 5f 70 72 65 70 61  vid);.  db_prepa
0e70: 72 65 28 26 71 2c 20 22 53 45 4c 45 43 54 20 70  re(&q, "SELECT p
0e80: 61 74 68 6e 61 6d 65 2c 20 64 65 6c 65 74 65 64  athname, deleted
0e90: 2c 20 72 69 64 2c 20 63 68 6e 67 65 64 20 46 52  , rid, chnged FR
0ea0: 4f 4d 20 76 66 69 6c 65 22 0a 20 20 20 20 20 20  OM vfile".      
0eb0: 20 20 20 20 20 20 20 20 20 20 20 22 20 4f 52 44             " ORD
0ec0: 45 52 20 42 59 20 31 22 29 3b 0a 20 20 77 68 69  ER BY 1");.  whi
0ed0: 6c 65 28 20 64 62 5f 73 74 65 70 28 26 71 29 3d  le( db_step(&q)=
0ee0: 3d 53 51 4c 49 54 45 5f 52 4f 57 20 29 7b 0a 20  =SQLITE_ROW ){. 
0ef0: 20 20 20 63 6f 6e 73 74 20 63 68 61 72 20 2a 7a     const char *z
0f00: 50 61 74 68 6e 61 6d 65 20 3d 20 64 62 5f 63 6f  Pathname = db_co
0f10: 6c 75 6d 6e 5f 74 65 78 74 28 26 71 2c 30 29 3b  lumn_text(&q,0);
0f20: 0a 20 20 20 20 69 6e 74 20 69 73 44 65 6c 65 74  .    int isDelet
0f30: 65 64 20 3d 20 64 62 5f 63 6f 6c 75 6d 6e 5f 69  ed = db_column_i
0f40: 6e 74 28 26 71 2c 20 31 29 3b 0a 20 20 20 20 69  nt(&q, 1);.    i
0f50: 6e 74 20 69 73 4e 65 77 20 3d 20 64 62 5f 63 6f  nt isNew = db_co
0f60: 6c 75 6d 6e 5f 69 6e 74 28 26 71 2c 32 29 3d 3d  lumn_int(&q,2)==
0f70: 30 3b 0a 20 20 20 20 69 6e 74 20 63 68 6e 67 65  0;.    int chnge
0f80: 64 20 3d 20 64 62 5f 63 6f 6c 75 6d 6e 5f 69 6e  d = db_column_in
0f90: 74 28 26 71 2c 33 29 3b 0a 20 20 20 20 69 66 28  t(&q,3);.    if(
0fa0: 20 69 73 4e 65 77 20 29 7b 0a 20 20 20 20 20 20   isNew ){.      
0fb0: 70 72 69 6e 74 66 28 22 41 44 44 45 44 20 20 20  printf("ADDED   
0fc0: 20 20 25 73 5c 6e 22 2c 20 7a 50 61 74 68 6e 61    %s\n", zPathna
0fd0: 6d 65 29 3b 0a 20 20 20 20 7d 65 6c 73 65 20 69  me);.    }else i
0fe0: 66 28 20 69 73 44 65 6c 65 74 65 64 20 29 7b 0a  f( isDeleted ){.
0ff0: 20 20 20 20 20 20 70 72 69 6e 74 66 28 22 44 45        printf("DE
1000: 4c 45 54 45 44 20 20 20 25 73 5c 6e 22 2c 20 7a  LETED   %s\n", z
1010: 50 61 74 68 6e 61 6d 65 29 3b 0a 20 20 20 20 7d  Pathname);.    }
1020: 65 6c 73 65 20 69 66 28 20 63 68 6e 67 65 64 20  else if( chnged 
1030: 29 7b 0a 20 20 20 20 20 20 70 72 69 6e 74 66 28  ){.      printf(
1040: 22 45 44 49 54 45 44 20 20 20 20 25 73 5c 6e 22  "EDITED    %s\n"
1050: 2c 20 7a 50 61 74 68 6e 61 6d 65 29 3b 0a 20 20  , zPathname);.  
1060: 20 20 7d 65 6c 73 65 7b 0a 20 20 20 20 20 20 70    }else{.      p
1070: 72 69 6e 74 66 28 22 55 4e 43 48 41 4e 47 45 44  rintf("UNCHANGED
1080: 20 25 73 5c 6e 22 2c 20 7a 50 61 74 68 6e 61 6d   %s\n", zPathnam
1090: 65 29 3b 0a 20 20 20 20 7d 0a 20 20 7d 0a 20 20  e);.    }.  }.  
10a0: 64 62 5f 66 69 6e 61 6c 69 7a 65 28 26 71 29 3b  db_finalize(&q);
10b0: 0a 7d 0a 0a 2f 2a 0a 2a 2a 20 43 4f 4d 4d 41 4e  .}../*.** COMMAN
10c0: 44 3a 20 65 78 74 72 61 0a 2a 2a 20 55 73 61 67  D: extra.** Usag
10d0: 65 3a 20 25 66 6f 73 73 69 6c 20 65 78 74 72 61  e: %fossil extra
10e0: 0a 2a 2a 20 50 72 69 6e 74 20 61 20 6c 69 73 74  .** Print a list
10f0: 20 6f 66 20 61 6c 6c 20 66 69 6c 65 73 20 69 6e   of all files in
1100: 20 74 68 65 20 73 6f 75 72 63 65 20 74 72 65 65   the source tree
1110: 20 74 68 61 74 20 61 72 65 20 6e 6f 74 20 70 61   that are not pa
1120: 72 74 20 6f 66 0a 2a 2a 20 74 68 65 20 63 75 72  rt of.** the cur
1130: 72 65 6e 74 20 63 68 65 63 6b 6f 75 74 2e 20 20  rent checkout.  
1140: 53 65 65 20 61 6c 73 6f 20 74 68 65 20 22 63 6c  See also the "cl
1150: 65 61 6e 22 20 63 6f 6d 6d 61 6e 64 2e 0a 2a 2f  ean" command..*/
1160: 0a 76 6f 69 64 20 65 78 74 72 61 5f 63 6d 64 28  .void extra_cmd(
1170: 76 6f 69 64 29 7b 0a 20 20 42 6c 6f 62 20 70 61  void){.  Blob pa
1180: 74 68 3b 0a 20 20 53 74 6d 74 20 71 3b 0a 20 20  th;.  Stmt q;.  
1190: 64 62 5f 6d 75 73 74 5f 62 65 5f 77 69 74 68 69  db_must_be_withi
11a0: 6e 5f 74 72 65 65 28 29 3b 0a 20 20 64 62 5f 6d  n_tree();.  db_m
11b0: 75 6c 74 69 5f 65 78 65 63 28 22 43 52 45 41 54  ulti_exec("CREAT
11c0: 45 20 54 45 4d 50 20 54 41 42 4c 45 20 73 66 69  E TEMP TABLE sfi
11d0: 6c 65 28 78 20 54 45 58 54 20 50 52 49 4d 41 52  le(x TEXT PRIMAR
11e0: 59 20 4b 45 59 29 22 29 3b 0a 20 20 63 68 64 69  Y KEY)");.  chdi
11f0: 72 28 67 2e 7a 4c 6f 63 61 6c 52 6f 6f 74 29 3b  r(g.zLocalRoot);
1200: 0a 20 20 62 6c 6f 62 5f 7a 65 72 6f 28 26 70 61  .  blob_zero(&pa
1210: 74 68 29 3b 0a 20 20 76 66 69 6c 65 5f 73 63 61  th);.  vfile_sca
1220: 6e 28 30 2c 20 26 70 61 74 68 29 3b 0a 20 20 64  n(0, &path);.  d
1230: 62 5f 70 72 65 70 61 72 65 28 26 71 2c 20 0a 20  b_prepare(&q, . 
1240: 20 20 20 20 20 22 53 45 4c 45 43 54 20 78 20 46       "SELECT x F
1250: 52 4f 4d 20 73 66 69 6c 65 22 0a 20 20 20 20 20  ROM sfile".     
1260: 20 22 20 57 48 45 52 45 20 78 20 4e 4f 54 20 49   " WHERE x NOT I
1270: 4e 20 28 27 6d 61 6e 69 66 65 73 74 27 2c 27 6d  N ('manifest','m
1280: 61 6e 69 66 65 73 74 2e 75 75 69 64 27 2c 27 5f  anifest.uuid','_
1290: 46 4f 53 53 49 4c 5f 27 29 22 0a 20 20 20 20 20  FOSSIL_')".     
12a0: 20 22 20 4f 52 44 45 52 20 42 59 20 31 22 29 3b   " ORDER BY 1");
12b0: 0a 20 20 77 68 69 6c 65 28 20 64 62 5f 73 74 65  .  while( db_ste
12c0: 70 28 26 71 29 3d 3d 53 51 4c 49 54 45 5f 52 4f  p(&q)==SQLITE_RO
12d0: 57 20 29 7b 0a 20 20 20 20 70 72 69 6e 74 66 28  W ){.    printf(
12e0: 22 25 73 5c 6e 22 2c 20 64 62 5f 63 6f 6c 75 6d  "%s\n", db_colum
12f0: 6e 5f 74 65 78 74 28 26 71 2c 20 30 29 29 3b 0a  n_text(&q, 0));.
1300: 20 20 7d 0a 20 20 64 62 5f 66 69 6e 61 6c 69 7a    }.  db_finaliz
1310: 65 28 26 71 29 3b 0a 7d 0a 0a 2f 2a 0a 2a 2a 20  e(&q);.}../*.** 
1320: 43 4f 4d 4d 41 4e 44 3a 20 63 6c 65 61 6e 0a 2a  COMMAND: clean.*
1330: 2a 20 55 73 61 67 65 3a 20 25 66 6f 73 73 69 6c  * Usage: %fossil
1340: 20 63 6c 65 61 6e 20 3f 2d 61 6c 6c 0a 2a 2a 20   clean ?-all.** 
1350: 44 65 6c 65 74 65 20 61 6c 6c 20 22 65 78 74 72  Delete all "extr
1360: 61 22 20 66 69 6c 65 73 20 69 6e 20 74 68 65 20  a" files in the 
1370: 73 6f 75 72 63 65 20 74 72 65 65 2e 20 20 22 45  source tree.  "E
1380: 78 74 72 61 22 20 66 69 6c 65 73 20 61 72 65 0a  xtra" files are.
1390: 2a 2a 20 66 69 6c 65 73 20 74 68 61 74 20 61 72  ** files that ar
13a0: 65 20 6e 6f 74 20 6f 66 66 69 63 69 61 6c 6c 79  e not officially
13b0: 20 70 61 72 74 20 6f 66 20 74 68 65 20 63 68 65   part of the che
13c0: 63 6b 6f 75 74 2e 20 20 53 65 65 20 61 6c 73 6f  ckout.  See also
13d0: 0a 2a 2a 20 74 68 65 20 22 65 78 74 72 61 22 20  .** the "extra" 
13e0: 63 6f 6d 6d 61 6e 64 2e 20 54 68 69 73 20 6f 70  command. This op
13f0: 65 72 61 74 69 6f 6e 20 63 61 6e 6e 6f 74 20 62  eration cannot b
1400: 65 20 75 6e 64 6f 6e 65 2e 20 0a 2a 2a 0a 2a 2a  e undone. .**.**
1410: 20 59 6f 75 20 77 69 6c 6c 20 62 65 20 70 72 6f   You will be pro
1420: 6d 70 74 65 64 20 62 65 66 6f 72 65 20 72 65 6d  mpted before rem
1430: 6f 76 69 6e 67 20 65 61 63 68 20 66 69 6c 65 2e  oving each file.
1440: 20 49 66 20 79 6f 75 20 61 72 65 0a 2a 2a 20 73   If you are.** s
1450: 75 72 65 20 79 6f 75 20 77 69 73 68 20 74 6f 20  ure you wish to 
1460: 72 65 6d 6f 76 65 20 61 6c 6c 20 22 65 78 74 72  remove all "extr
1470: 61 22 20 66 69 6c 65 73 20 79 6f 75 20 63 61 6e  a" files you can
1480: 20 73 70 65 63 69 66 79 20 74 68 65 0a 2a 2a 20   specify the.** 
1490: 6f 70 74 69 6f 6e 61 6c 20 2d 61 6c 6c 20 66 6c  optional -all fl
14a0: 61 67 2e 0a 2a 2f 0a 76 6f 69 64 20 63 6c 65 61  ag..*/.void clea
14b0: 6e 5f 63 6d 64 28 76 6f 69 64 29 7b 0a 20 20 69  n_cmd(void){.  i
14c0: 6e 74 20 61 6c 6c 46 6c 61 67 3b 0a 20 20 42 6c  nt allFlag;.  Bl
14d0: 6f 62 20 70 61 74 68 3b 0a 20 20 53 74 6d 74 20  ob path;.  Stmt 
14e0: 71 3b 0a 20 20 61 6c 6c 46 6c 61 67 20 3d 20 66  q;.  allFlag = f
14f0: 69 6e 64 5f 6f 70 74 69 6f 6e 28 22 61 6c 6c 22  ind_option("all"
1500: 2c 22 61 22 2c 30 29 21 3d 30 3b 0a 20 20 64 62  ,"a",0)!=0;.  db
1510: 5f 6d 75 73 74 5f 62 65 5f 77 69 74 68 69 6e 5f  _must_be_within_
1520: 74 72 65 65 28 29 3b 0a 20 20 64 62 5f 6d 75 6c  tree();.  db_mul
1530: 74 69 5f 65 78 65 63 28 22 43 52 45 41 54 45 20  ti_exec("CREATE 
1540: 54 45 4d 50 20 54 41 42 4c 45 20 73 66 69 6c 65  TEMP TABLE sfile
1550: 28 78 20 54 45 58 54 20 50 52 49 4d 41 52 59 20  (x TEXT PRIMARY 
1560: 4b 45 59 29 22 29 3b 0a 20 20 63 68 64 69 72 28  KEY)");.  chdir(
1570: 67 2e 7a 4c 6f 63 61 6c 52 6f 6f 74 29 3b 0a 20  g.zLocalRoot);. 
1580: 20 62 6c 6f 62 5f 7a 65 72 6f 28 26 70 61 74 68   blob_zero(&path
1590: 29 3b 0a 20 20 76 66 69 6c 65 5f 73 63 61 6e 28  );.  vfile_scan(
15a0: 30 2c 20 26 70 61 74 68 29 3b 0a 20 20 64 62 5f  0, &path);.  db_
15b0: 70 72 65 70 61 72 65 28 26 71 2c 20 0a 20 20 20  prepare(&q, .   
15c0: 20 20 20 22 53 45 4c 45 43 54 20 25 51 20 7c 7c     "SELECT %Q ||
15d0: 20 78 20 46 52 4f 4d 20 73 66 69 6c 65 22 0a 20   x FROM sfile". 
15e0: 20 20 20 20 20 22 20 57 48 45 52 45 20 78 20 4e       " WHERE x N
15f0: 4f 54 20 49 4e 20 28 27 6d 61 6e 69 66 65 73 74  OT IN ('manifest
1600: 27 2c 27 6d 61 6e 69 66 65 73 74 2e 75 75 69 64  ','manifest.uuid
1610: 27 2c 27 5f 46 4f 53 53 49 4c 5f 27 29 22 0a 20  ','_FOSSIL_')". 
1620: 20 20 20 20 20 22 20 4f 52 44 45 52 20 42 59 20       " ORDER BY 
1630: 31 22 2c 20 67 2e 7a 4c 6f 63 61 6c 52 6f 6f 74  1", g.zLocalRoot
1640: 29 3b 0a 20 20 77 68 69 6c 65 28 20 64 62 5f 73  );.  while( db_s
1650: 74 65 70 28 26 71 29 3d 3d 53 51 4c 49 54 45 5f  tep(&q)==SQLITE_
1660: 52 4f 57 20 29 7b 0a 20 20 20 20 69 66 28 20 61  ROW ){.    if( a
1670: 6c 6c 46 6c 61 67 20 29 7b 0a 20 20 20 20 20 20  llFlag ){.      
1680: 75 6e 6c 69 6e 6b 28 64 62 5f 63 6f 6c 75 6d 6e  unlink(db_column
1690: 5f 74 65 78 74 28 26 71 2c 20 30 29 29 3b 0a 20  _text(&q, 0));. 
16a0: 20 20 20 7d 65 6c 73 65 7b 0a 20 20 20 20 20 20     }else{.      
16b0: 42 6c 6f 62 20 61 6e 73 3b 0a 20 20 20 20 20 20  Blob ans;.      
16c0: 63 68 61 72 20 2a 70 72 6f 6d 70 74 20 3d 20 6d  char *prompt = m
16d0: 70 72 69 6e 74 66 28 22 72 65 6d 6f 76 65 20 75  printf("remove u
16e0: 6e 6d 61 6e 61 67 65 64 20 66 69 6c 65 20 5c 22  nmanaged file \"
16f0: 25 73 5c 22 20 5b 79 2f 4e 5d 3f 20 22 2c 0a 20  %s\" [y/N]? ",. 
1700: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1710: 20 20 20 20 20 20 20 20 20 20 20 20 20 64 62 5f               db_
1720: 63 6f 6c 75 6d 6e 5f 74 65 78 74 28 26 71 2c 20  column_text(&q, 
1730: 30 29 29 3b 0a 20 20 20 20 20 20 62 6c 6f 62 5f  0));.      blob_
1740: 7a 65 72 6f 28 26 61 6e 73 29 3b 0a 20 20 20 20  zero(&ans);.    
1750: 20 20 70 72 6f 6d 70 74 5f 75 73 65 72 28 70 72    prompt_user(pr
1760: 6f 6d 70 74 2c 20 26 61 6e 73 29 3b 0a 20 20 20  ompt, &ans);.   
1770: 20 20 20 69 66 28 20 62 6c 6f 62 5f 73 74 72 28     if( blob_str(
1780: 26 61 6e 73 29 5b 30 5d 3d 3d 27 79 27 20 29 7b  &ans)[0]=='y' ){
1790: 0a 20 20 20 20 20 20 20 20 75 6e 6c 69 6e 6b 28  .        unlink(
17a0: 64 62 5f 63 6f 6c 75 6d 6e 5f 74 65 78 74 28 26  db_column_text(&
17b0: 71 2c 20 30 29 29 3b 0a 20 20 20 20 20 20 7d 0a  q, 0));.      }.
17c0: 20 20 20 20 7d 0a 20 20 7d 0a 20 20 64 62 5f 66      }.  }.  db_f
17d0: 69 6e 61 6c 69 7a 65 28 26 71 29 3b 0a 7d 0a 0a  inalize(&q);.}..
17e0: 2f 2a 0a 2a 2a 20 50 72 65 70 61 72 65 20 61 20  /*.** Prepare a 
17f0: 63 6f 6d 6d 69 74 20 63 6f 6d 6d 65 6e 74 2e 20  commit comment. 
1800: 20 4c 65 74 20 74 68 65 20 75 73 65 72 20 6d 6f   Let the user mo
1810: 64 69 66 79 20 69 74 20 75 73 69 6e 67 20 74 68  dify it using th
1820: 65 0a 2a 2a 20 65 64 69 74 6f 72 20 73 70 65 63  e.** editor spec
1830: 69 66 69 65 64 20 69 6e 20 74 68 65 20 67 6c 6f  ified in the glo
1840: 62 61 6c 5f 63 6f 6e 66 69 67 20 74 61 62 6c 65  bal_config table
1850: 20 6f 72 20 65 69 74 68 65 72 0a 2a 2a 20 74 68   or either.** th
1860: 65 20 56 49 53 55 41 4c 20 6f 72 20 45 44 49 54  e VISUAL or EDIT
1870: 4f 52 20 65 6e 76 69 72 6f 6e 6d 65 6e 74 20 76  OR environment v
1880: 61 72 69 61 62 6c 65 2e 0a 2a 2a 0a 2a 2a 20 53  ariable..**.** S
1890: 74 6f 72 65 20 74 68 65 20 66 69 6e 61 6c 20 63  tore the final c
18a0: 6f 6d 6d 69 74 20 63 6f 6d 6d 65 6e 74 20 69 6e  ommit comment in
18b0: 20 70 43 6f 6d 6d 65 6e 74 2e 20 20 70 43 6f 6d   pComment.  pCom
18c0: 6d 65 6e 74 20 69 73 20 61 73 73 75 6d 65 64 0a  ment is assumed.
18d0: 2a 2a 20 74 6f 20 62 65 20 75 6e 69 6e 69 74 69  ** to be uniniti
18e0: 61 6c 69 7a 65 64 20 2d 20 61 6e 79 20 70 72 69  alized - any pri
18f0: 6f 72 20 63 6f 6e 74 65 6e 74 20 69 73 20 6f 76  or content is ov
1900: 65 72 77 72 69 74 74 65 6e 2e 0a 2a 2f 0a 73 74  erwritten..*/.st
1910: 61 74 69 63 20 76 6f 69 64 20 70 72 65 70 61 72  atic void prepar
1920: 65 5f 63 6f 6d 6d 69 74 5f 63 6f 6d 6d 65 6e 74  e_commit_comment
1930: 28 42 6c 6f 62 20 2a 70 43 6f 6d 6d 65 6e 74 29  (Blob *pComment)
1940: 7b 0a 20 20 63 6f 6e 73 74 20 63 68 61 72 20 2a  {.  const char *
1950: 7a 45 64 69 74 6f 72 3b 0a 20 20 63 68 61 72 20  zEditor;.  char 
1960: 2a 7a 43 6d 64 3b 0a 20 20 63 68 61 72 20 2a 7a  *zCmd;.  char *z
1970: 46 69 6c 65 3b 0a 20 20 42 6c 6f 62 20 74 65 78  File;.  Blob tex
1980: 74 2c 20 6c 69 6e 65 3b 0a 20 20 63 68 61 72 20  t, line;.  char 
1990: 2a 7a 43 6f 6d 6d 65 6e 74 3b 0a 20 20 69 6e 74  *zComment;.  int
19a0: 20 69 3b 0a 20 20 62 6c 6f 62 5f 73 65 74 28 26   i;.  blob_set(&
19b0: 74 65 78 74 2c 0a 20 20 20 20 22 5c 6e 23 20 45  text,.    "\n# E
19c0: 6e 74 65 72 20 63 6f 6d 6d 65 6e 74 73 20 6f 6e  nter comments on
19d0: 20 74 68 69 73 20 63 6f 6d 6d 69 74 2e 20 20 4c   this commit.  L
19e0: 69 6e 65 73 20 62 65 67 69 6e 6e 69 6e 67 20 77  ines beginning w
19f0: 69 74 68 20 23 20 61 72 65 20 69 67 6e 6f 72 65  ith # are ignore
1a00: 64 5c 6e 22 0a 20 20 20 20 22 23 5c 6e 22 0a 20  d\n".    "#\n". 
1a10: 20 29 3b 0a 20 20 73 74 61 74 75 73 5f 72 65 70   );.  status_rep
1a20: 6f 72 74 28 26 74 65 78 74 2c 20 22 23 20 22 29  ort(&text, "# ")
1a30: 3b 0a 20 20 7a 45 64 69 74 6f 72 20 3d 20 64 62  ;.  zEditor = db
1a40: 5f 67 65 74 28 22 65 64 69 74 6f 72 22 2c 20 30  _get("editor", 0
1a50: 29 3b 0a 20 20 69 66 28 20 7a 45 64 69 74 6f 72  );.  if( zEditor
1a60: 3d 3d 30 20 29 7b 0a 20 20 20 20 7a 45 64 69 74  ==0 ){.    zEdit
1a70: 6f 72 20 3d 20 67 65 74 65 6e 76 28 22 56 49 53  or = getenv("VIS
1a80: 55 41 4c 22 29 3b 0a 20 20 7d 0a 20 20 69 66 28  UAL");.  }.  if(
1a90: 20 7a 45 64 69 74 6f 72 3d 3d 30 20 29 7b 0a 20   zEditor==0 ){. 
1aa0: 20 20 20 7a 45 64 69 74 6f 72 20 3d 20 67 65 74     zEditor = get
1ab0: 65 6e 76 28 22 45 44 49 54 4f 52 22 29 3b 0a 20  env("EDITOR");. 
1ac0: 20 7d 0a 20 20 69 66 28 20 7a 45 64 69 74 6f 72   }.  if( zEditor
1ad0: 3d 3d 30 20 29 7b 0a 20 20 20 20 7a 45 64 69 74  ==0 ){.    zEdit
1ae0: 6f 72 20 3d 20 22 65 64 22 3b 0a 20 20 7d 0a 20  or = "ed";.  }. 
1af0: 20 7a 46 69 6c 65 20 3d 20 64 62 5f 74 65 78 74   zFile = db_text
1b00: 28 30 2c 20 22 53 45 4c 45 43 54 20 27 25 71 63  (0, "SELECT '%qc
1b10: 69 2d 63 6f 6d 6d 65 6e 74 2d 27 20 7c 7c 20 68  i-comment-' || h
1b20: 65 78 28 72 61 6e 64 6f 6d 62 6c 6f 62 28 36 29  ex(randomblob(6)
1b30: 29 20 7c 7c 20 27 2e 74 78 74 27 22 2c 0a 20 20  ) || '.txt'",.  
1b40: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1b50: 20 67 2e 7a 4c 6f 63 61 6c 52 6f 6f 74 29 3b 0a   g.zLocalRoot);.
1b60: 20 20 62 6c 6f 62 5f 77 72 69 74 65 5f 74 6f 5f    blob_write_to_
1b70: 66 69 6c 65 28 26 74 65 78 74 2c 20 7a 46 69 6c  file(&text, zFil
1b80: 65 29 3b 0a 20 20 7a 43 6d 64 20 3d 20 6d 70 72  e);.  zCmd = mpr
1b90: 69 6e 74 66 28 22 25 73 20 5c 22 25 73 5c 22 22  intf("%s \"%s\""
1ba0: 2c 20 7a 45 64 69 74 6f 72 2c 20 7a 46 69 6c 65  , zEditor, zFile
1bb0: 29 3b 0a 20 20 70 72 69 6e 74 66 28 22 25 73 5c  );.  printf("%s\
1bc0: 6e 22 2c 20 7a 43 6d 64 29 3b 0a 20 20 69 66 28  n", zCmd);.  if(
1bd0: 20 73 79 73 74 65 6d 28 7a 43 6d 64 29 20 29 7b   system(zCmd) ){
1be0: 0a 20 20 20 20 66 6f 73 73 69 6c 5f 70 61 6e 69  .    fossil_pani
1bf0: 63 28 22 65 64 69 74 6f 72 20 61 62 6f 72 74 65  c("editor aborte
1c00: 64 22 29 3b 0a 20 20 7d 0a 20 20 62 6c 6f 62 5f  d");.  }.  blob_
1c10: 72 65 73 65 74 28 26 74 65 78 74 29 3b 0a 20 20  reset(&text);.  
1c20: 62 6c 6f 62 5f 72 65 61 64 5f 66 72 6f 6d 5f 66  blob_read_from_f
1c30: 69 6c 65 28 26 74 65 78 74 2c 20 7a 46 69 6c 65  ile(&text, zFile
1c40: 29 3b 0a 20 20 75 6e 6c 69 6e 6b 28 7a 46 69 6c  );.  unlink(zFil
1c50: 65 29 3b 0a 20 20 66 72 65 65 28 7a 46 69 6c 65  e);.  free(zFile
1c60: 29 3b 0a 20 20 62 6c 6f 62 5f 7a 65 72 6f 28 70  );.  blob_zero(p
1c70: 43 6f 6d 6d 65 6e 74 29 3b 0a 20 20 77 68 69 6c  Comment);.  whil
1c80: 65 28 20 62 6c 6f 62 5f 6c 69 6e 65 28 26 74 65  e( blob_line(&te
1c90: 78 74 2c 20 26 6c 69 6e 65 29 20 29 7b 0a 20 20  xt, &line) ){.  
1ca0: 20 20 69 6e 74 20 69 2c 20 6e 3b 0a 20 20 20 20    int i, n;.    
1cb0: 63 68 61 72 20 2a 7a 3b 0a 20 20 20 20 6e 20 3d  char *z;.    n =
1cc0: 20 62 6c 6f 62 5f 73 69 7a 65 28 26 6c 69 6e 65   blob_size(&line
1cd0: 29 3b 0a 20 20 20 20 7a 20 3d 20 62 6c 6f 62 5f  );.    z = blob_
1ce0: 62 75 66 66 65 72 28 26 6c 69 6e 65 29 3b 0a 20  buffer(&line);. 
1cf0: 20 20 20 66 6f 72 28 69 3d 30 3b 20 69 3c 6e 20     for(i=0; i<n 
1d00: 26 26 20 69 73 73 70 61 63 65 28 7a 5b 69 5d 29  && isspace(z[i])
1d10: 3b 20 20 69 2b 2b 29 7b 7d 0a 20 20 20 20 69 66  ;  i++){}.    if
1d20: 28 20 69 3c 6e 20 26 26 20 7a 5b 69 5d 3d 3d 27  ( i<n && z[i]=='
1d30: 23 27 20 29 20 63 6f 6e 74 69 6e 75 65 3b 0a 20  #' ) continue;. 
1d40: 20 20 20 69 66 28 20 69 3c 6e 20 7c 7c 20 62 6c     if( i<n || bl
1d50: 6f 62 5f 73 69 7a 65 28 70 43 6f 6d 6d 65 6e 74  ob_size(pComment
1d60: 29 3e 30 20 29 7b 0a 20 20 20 20 20 20 62 6c 6f  )>0 ){.      blo
1d70: 62 5f 61 70 70 65 6e 64 66 28 70 43 6f 6d 6d 65  b_appendf(pComme
1d80: 6e 74 2c 20 22 25 62 22 2c 20 26 6c 69 6e 65 29  nt, "%b", &line)
1d90: 3b 0a 20 20 20 20 7d 0a 20 20 7d 0a 20 20 62 6c  ;.    }.  }.  bl
1da0: 6f 62 5f 72 65 73 65 74 28 26 74 65 78 74 29 3b  ob_reset(&text);
1db0: 0a 20 20 7a 43 6f 6d 6d 65 6e 74 20 3d 20 62 6c  .  zComment = bl
1dc0: 6f 62 5f 73 74 72 28 70 43 6f 6d 6d 65 6e 74 29  ob_str(pComment)
1dd0: 3b 0a 20 20 69 20 3d 20 73 74 72 6c 65 6e 28 7a  ;.  i = strlen(z
1de0: 43 6f 6d 6d 65 6e 74 29 3b 0a 20 20 77 68 69 6c  Comment);.  whil
1df0: 65 28 20 69 3e 30 20 26 26 20 69 73 73 70 61 63  e( i>0 && isspac
1e00: 65 28 7a 43 6f 6d 6d 65 6e 74 5b 69 2d 31 5d 29  e(zComment[i-1])
1e10: 20 29 7b 20 69 2d 2d 3b 20 7d 0a 20 20 62 6c 6f   ){ i--; }.  blo
1e20: 62 5f 72 65 73 69 7a 65 28 70 43 6f 6d 6d 65 6e  b_resize(pCommen
1e30: 74 2c 20 69 29 3b 0a 7d 0a 0a 2f 2a 0a 2a 2a 20  t, i);.}../*.** 
1e40: 50 6f 70 75 6c 61 74 65 20 74 68 65 20 47 6c 6f  Populate the Glo
1e50: 62 61 6c 2e 61 43 6f 6d 6d 69 74 46 69 6c 65 5b  bal.aCommitFile[
1e60: 5d 20 62 61 73 65 64 20 6f 6e 20 74 68 65 20 63  ] based on the c
1e70: 6f 6d 6d 61 6e 64 20 6c 69 6e 65 20 61 72 67 75  ommand line argu
1e80: 6d 65 6e 74 73 0a 2a 2a 20 74 6f 20 61 20 5b 63  ments.** to a [c
1e90: 6f 6d 6d 69 74 5d 20 63 6f 6d 6d 61 6e 64 2e 20  ommit] command. 
1ea0: 47 6c 6f 62 61 6c 2e 61 43 6f 6d 6d 69 74 46 69  Global.aCommitFi
1eb0: 6c 65 20 69 73 20 61 6e 20 61 72 72 61 79 20 6f  le is an array o
1ec0: 66 20 69 6e 74 65 67 65 72 73 0a 2a 2a 20 73 69  f integers.** si
1ed0: 7a 65 64 20 61 74 20 28 4e 2b 31 29 2c 20 77 68  zed at (N+1), wh
1ee0: 65 72 65 20 4e 20 69 73 20 74 68 65 20 6e 75 6d  ere N is the num
1ef0: 62 65 72 20 6f 66 20 61 72 67 75 6d 65 6e 74 73  ber of arguments
1f00: 20 70 61 73 73 65 64 20 74 6f 20 5b 63 6f 6d 6d   passed to [comm
1f10: 69 74 5d 2e 0a 2a 2a 20 54 68 65 20 63 6f 6e 74  it]..** The cont
1f20: 65 6e 74 73 20 61 72 65 20 74 68 65 20 5b 69 64  ents are the [id
1f30: 5d 20 76 61 6c 75 65 73 20 66 72 6f 6d 20 74 68  ] values from th
1f40: 65 20 76 66 69 6c 65 20 74 61 62 6c 65 20 63 6f  e vfile table co
1f50: 72 72 65 73 70 6f 6e 64 69 6e 67 0a 2a 2a 20 74  rresponding.** t
1f60: 6f 20 74 68 65 20 66 69 6c 65 6e 61 6d 65 73 20  o the filenames 
1f70: 70 61 73 73 65 64 20 61 73 20 61 72 67 75 6d 65  passed as argume
1f80: 6e 74 73 2e 0a 2a 2a 0a 2a 2a 20 54 68 65 20 6c  nts..**.** The l
1f90: 61 73 74 20 65 6c 65 6d 65 6e 74 20 6f 66 20 61  ast element of a
1fa0: 43 6f 6d 6d 69 74 46 69 6c 65 5b 5d 20 69 73 20  CommitFile[] is 
1fb0: 61 6c 77 61 79 73 20 30 20 2d 20 69 6e 64 69 63  always 0 - indic
1fc0: 61 74 69 6e 67 20 74 68 65 20 65 6e 64 0a 2a 2a  ating the end.**
1fd0: 20 6f 66 20 74 68 65 20 61 72 72 61 79 2e 0a 2a   of the array..*
1fe0: 2a 0a 2a 2a 20 49 66 20 74 68 65 72 65 20 77 65  *.** If there we
1ff0: 72 65 20 6e 6f 20 61 72 67 75 6d 65 6e 74 73 20  re no arguments 
2000: 70 61 73 73 65 64 20 74 6f 20 5b 63 6f 6d 6d 69  passed to [commi
2010: 74 5d 2c 20 61 43 6f 6d 6d 69 74 46 69 6c 65 20  t], aCommitFile 
2020: 69 73 20 6e 6f 74 0a 2a 2a 20 61 6c 6c 6f 63 61  is not.** alloca
2030: 74 65 64 20 61 6e 64 20 72 65 6d 61 69 6e 73 20  ted and remains 
2040: 4e 55 4c 4c 2e 20 4f 74 68 65 72 20 70 61 72 74  NULL. Other part
2050: 73 20 6f 66 20 74 68 65 20 63 6f 64 65 20 69 6e  s of the code in
2060: 74 65 72 70 72 65 74 20 74 68 69 73 0a 2a 2a 20  terpret this.** 
2070: 74 6f 20 6d 65 61 6e 20 22 61 6c 6c 20 66 69 6c  to mean "all fil
2080: 65 73 22 2e 0a 2a 2f 0a 76 6f 69 64 20 73 65 6c  es"..*/.void sel
2090: 65 63 74 5f 63 6f 6d 6d 69 74 5f 66 69 6c 65 73  ect_commit_files
20a0: 28 76 6f 69 64 29 7b 0a 20 20 69 66 28 20 67 2e  (void){.  if( g.
20b0: 61 72 67 63 3e 32 20 29 7b 0a 20 20 20 20 69 6e  argc>2 ){.    in
20c0: 74 20 69 69 3b 0a 20 20 20 20 42 6c 6f 62 20 62  t ii;.    Blob b
20d0: 3b 0a 20 20 20 20 62 6c 6f 62 5f 7a 65 72 6f 28  ;.    blob_zero(
20e0: 26 62 29 3b 0a 20 20 20 20 67 2e 61 43 6f 6d 6d  &b);.    g.aComm
20f0: 69 74 46 69 6c 65 20 3d 20 6d 61 6c 6c 6f 63 28  itFile = malloc(
2100: 73 69 7a 65 6f 66 28 69 6e 74 29 2a 28 67 2e 61  sizeof(int)*(g.a
2110: 72 67 63 2d 31 29 29 3b 0a 0a 20 20 20 20 66 6f  rgc-1));..    fo
2120: 72 28 69 69 3d 32 3b 20 69 69 3c 67 2e 61 72 67  r(ii=2; ii<g.arg
2130: 63 3b 20 69 69 2b 2b 29 7b 0a 20 20 20 20 20 20  c; ii++){.      
2140: 69 6e 74 20 69 49 64 3b 0a 20 20 20 20 20 20 69  int iId;.      i
2150: 66 28 20 21 66 69 6c 65 5f 74 72 65 65 5f 6e 61  f( !file_tree_na
2160: 6d 65 28 67 2e 61 72 67 76 5b 69 69 5d 2c 20 26  me(g.argv[ii], &
2170: 62 29 20 29 7b 0a 20 20 20 20 20 20 20 20 66 6f  b) ){.        fo
2180: 73 73 69 6c 5f 66 61 74 61 6c 28 22 66 69 6c 65  ssil_fatal("file
2190: 20 69 73 20 6e 6f 74 20 69 6e 20 74 72 65 65 3a   is not in tree:
21a0: 20 25 73 22 2c 20 67 2e 61 72 67 76 5b 69 69 5d   %s", g.argv[ii]
21b0: 29 3b 0a 20 20 20 20 20 20 7d 0a 20 20 20 20 20  );.      }.     
21c0: 20 69 49 64 20 3d 20 64 62 5f 69 6e 74 28 2d 31   iId = db_int(-1
21d0: 2c 20 22 53 45 4c 45 43 54 20 69 64 20 46 52 4f  , "SELECT id FRO
21e0: 4d 20 76 66 69 6c 65 20 57 48 45 52 45 20 70 61  M vfile WHERE pa
21f0: 74 68 6e 61 6d 65 3d 25 51 22 2c 20 62 6c 6f 62  thname=%Q", blob
2200: 5f 73 74 72 28 26 62 29 29 3b 0a 20 20 20 20 20  _str(&b));.     
2210: 20 69 66 28 20 69 49 64 3c 30 20 29 7b 0a 20 20   if( iId<0 ){.  
2220: 20 20 20 20 20 20 66 6f 73 73 69 6c 5f 66 61 74        fossil_fat
2230: 61 6c 28 22 66 6f 73 73 69 6c 20 6b 6e 6f 77 73  al("fossil knows
2240: 20 6e 6f 74 68 69 6e 67 20 61 62 6f 75 74 3a 20   nothing about: 
2250: 25 73 22 2c 20 67 2e 61 72 67 76 5b 69 69 5d 29  %s", g.argv[ii])
2260: 3b 0a 20 20 20 20 20 20 7d 0a 20 20 20 20 20 20  ;.      }.      
2270: 67 2e 61 43 6f 6d 6d 69 74 46 69 6c 65 5b 69 69  g.aCommitFile[ii
2280: 2d 32 5d 20 3d 20 69 49 64 3b 0a 20 20 20 20 20  -2] = iId;.     
2290: 20 62 6c 6f 62 5f 72 65 73 65 74 28 26 62 29 3b   blob_reset(&b);
22a0: 0a 20 20 20 20 7d 0a 20 20 20 20 67 2e 61 43 6f  .    }.    g.aCo
22b0: 6d 6d 69 74 46 69 6c 65 5b 69 69 2d 32 5d 20 3d  mmitFile[ii-2] =
22c0: 20 30 3b 0a 20 20 7d 0a 7d 0a 0a 2f 2a 0a 2a 2a   0;.  }.}../*.**
22d0: 20 43 4f 4d 4d 41 4e 44 3a 20 63 6f 6d 6d 69 74   COMMAND: commit
22e0: 0a 2a 2a 0a 2a 2a 20 55 73 61 67 65 3a 20 25 66  .**.** Usage: %f
22f0: 6f 73 73 69 6c 20 63 6f 6d 6d 69 74 20 3f 2d 6d  ossil commit ?-m
2300: 20 43 4f 4d 4d 45 4e 54 3f 20 3f 2d 2d 6e 6f 73   COMMENT? ?--nos
2310: 69 67 6e 3f 20 3f 46 49 4c 45 2e 2e 2e 3f 0a 2a  ign? ?FILE...?.*
2320: 2a 0a 2a 2a 20 43 72 65 61 74 65 20 61 20 6e 65  *.** Create a ne
2330: 77 20 76 65 72 73 69 6f 6e 20 63 6f 6e 74 61 69  w version contai
2340: 6e 69 6e 67 20 61 6c 6c 20 6f 66 20 74 68 65 20  ning all of the 
2350: 63 68 61 6e 67 65 73 20 69 6e 20 74 68 65 20 63  changes in the c
2360: 75 72 72 65 6e 74 0a 2a 2a 20 63 68 65 63 6b 6f  urrent.** checko
2370: 75 74 2e 20 20 59 6f 75 20 77 69 6c 6c 20 62 65  ut.  You will be
2380: 20 70 72 6f 6d 70 74 65 64 20 74 6f 20 65 6e 74   prompted to ent
2390: 65 72 20 61 20 63 68 65 63 6b 2d 69 6e 20 63 6f  er a check-in co
23a0: 6d 6d 65 6e 74 20 75 6e 6c 65 73 73 0a 2a 2a 20  mment unless.** 
23b0: 74 68 65 20 22 2d 6d 22 20 6f 70 74 69 6f 6e 20  the "-m" option 
23c0: 69 73 20 75 73 65 64 20 74 6f 20 73 70 65 63 69  is used to speci
23d0: 66 79 20 61 20 63 6f 6d 6d 61 6e 64 20 6c 69 6e  fy a command lin
23e0: 65 2e 20 20 59 6f 75 20 77 69 6c 6c 20 62 65 0a  e.  You will be.
23f0: 2a 2a 20 70 72 6f 6d 70 74 65 64 20 66 6f 72 20  ** prompted for 
2400: 79 6f 75 72 20 47 50 47 20 70 61 73 73 70 68 72  your GPG passphr
2410: 61 73 65 20 69 6e 20 6f 72 64 65 72 20 74 6f 20  ase in order to 
2420: 73 69 67 6e 20 74 68 65 20 6e 65 77 20 6d 61 6e  sign the new man
2430: 69 66 65 73 74 0a 2a 2a 20 75 6e 6c 65 73 73 20  ifest.** unless 
2440: 74 68 65 20 22 2d 2d 6e 6f 73 69 67 6e 22 20 6f  the "--nosign" o
2450: 70 74 69 6f 6e 73 20 69 73 20 75 73 65 64 2e 20  ptions is used. 
2460: 20 41 6c 6c 20 66 69 6c 65 73 20 74 68 61 74 20   All files that 
2470: 68 61 76 65 0a 2a 2a 20 63 68 61 6e 67 65 64 20  have.** changed 
2480: 77 69 6c 6c 20 62 65 20 63 6f 6d 6d 69 74 74 65  will be committe
2490: 64 20 75 6e 6c 65 73 73 20 73 6f 6d 65 20 73 75  d unless some su
24a0: 62 73 65 74 20 6f 66 20 66 69 6c 65 73 20 69 73  bset of files is
24b0: 20 73 70 65 63 69 66 69 65 64 0a 2a 2a 20 6f 6e   specified.** on
24c0: 20 74 68 65 20 63 6f 6d 6d 61 6e 64 20 6c 69 6e   the command lin
24d0: 65 2e 0a 2a 2f 0a 76 6f 69 64 20 63 6f 6d 6d 69  e..*/.void commi
24e0: 74 5f 63 6d 64 28 76 6f 69 64 29 7b 0a 20 20 69  t_cmd(void){.  i
24f0: 6e 74 20 72 63 3b 0a 20 20 69 6e 74 20 76 69 64  nt rc;.  int vid
2500: 2c 20 6e 72 69 64 2c 20 6e 76 69 64 2c 20 77 6f  , nrid, nvid, wo
2510: 75 6c 64 46 6f 72 6b 3d 30 3b 0a 20 20 42 6c 6f  uldFork=0;.  Blo
2520: 62 20 63 6f 6d 6d 65 6e 74 3b 0a 20 20 63 6f 6e  b comment;.  con
2530: 73 74 20 63 68 61 72 20 2a 7a 43 6f 6d 6d 65 6e  st char *zCommen
2540: 74 3b 0a 20 20 53 74 6d 74 20 71 3b 0a 20 20 53  t;.  Stmt q;.  S
2550: 74 6d 74 20 71 32 3b 0a 20 20 63 68 61 72 20 2a  tmt q2;.  char *
2560: 7a 55 75 69 64 2c 20 2a 7a 44 61 74 65 3b 0a 20  zUuid, *zDate;. 
2570: 20 69 6e 74 20 6e 6f 53 69 67 6e 20 3d 20 30 3b   int noSign = 0;
2580: 20 20 20 20 20 20 20 20 2f 2a 20 54 72 75 65 20          /* True 
2590: 74 6f 20 6f 6d 69 74 20 73 69 67 6e 69 6e 67 20  to omit signing 
25a0: 74 68 65 20 6d 61 6e 69 66 65 73 74 20 75 73 69  the manifest usi
25b0: 6e 67 20 47 50 47 20 2a 2f 0a 20 20 69 6e 74 20  ng GPG */.  int 
25c0: 69 73 41 4d 65 72 67 65 20 3d 20 30 3b 20 20 20  isAMerge = 0;   
25d0: 20 20 20 2f 2a 20 54 72 75 65 20 69 66 20 63 68     /* True if ch
25e0: 65 63 6b 69 6e 67 20 69 6e 20 61 20 6d 65 72 67  ecking in a merg
25f0: 65 20 2a 2f 0a 20 20 69 6e 74 20 66 6f 72 63 65  e */.  int force
2600: 46 6c 61 67 20 3d 20 30 3b 20 20 20 20 20 2f 2a  Flag = 0;     /*
2610: 20 46 6f 72 63 65 20 61 20 66 6f 72 6b 20 2a 2f   Force a fork */
2620: 0a 20 20 63 68 61 72 20 2a 7a 4d 61 6e 69 66 65  .  char *zManife
2630: 73 74 46 69 6c 65 3b 20 20 20 2f 2a 20 4e 61 6d  stFile;   /* Nam
2640: 65 20 6f 66 20 74 68 65 20 6d 61 6e 69 66 65 73  e of the manifes
2650: 74 20 66 69 6c 65 20 2a 2f 0a 20 20 42 6c 6f 62  t file */.  Blob
2660: 20 6d 61 6e 69 66 65 73 74 3b 0a 20 20 42 6c 6f   manifest;.  Blo
2670: 62 20 6d 75 75 69 64 3b 20 20 20 20 20 20 20 20  b muuid;        
2680: 20 20 20 20 2f 2a 20 4d 61 6e 69 66 65 73 74 20      /* Manifest 
2690: 75 75 69 64 20 2a 2f 0a 20 20 42 6c 6f 62 20 6d  uuid */.  Blob m
26a0: 63 6b 73 75 6d 3b 20 20 20 20 20 20 20 20 20 20  cksum;          
26b0: 20 2f 2a 20 53 65 6c 66 2d 63 68 65 63 6b 73 75   /* Self-checksu
26c0: 6d 20 6f 6e 20 74 68 65 20 6d 61 6e 69 66 65 73  m on the manifes
26d0: 74 20 2a 2f 0a 20 20 42 6c 6f 62 20 63 6b 73 75  t */.  Blob cksu
26e0: 6d 31 2c 20 63 6b 73 75 6d 32 3b 20 20 20 2f 2a  m1, cksum2;   /*
26f0: 20 42 65 66 6f 72 65 20 61 6e 64 20 61 66 74 65   Before and afte
2700: 72 20 63 6f 6d 6d 69 74 20 63 68 65 63 6b 73 75  r commit checksu
2710: 6d 73 20 2a 2f 0a 20 20 42 6c 6f 62 20 63 6b 73  ms */.  Blob cks
2720: 75 6d 31 62 3b 20 20 20 20 20 20 20 20 20 20 2f  um1b;          /
2730: 2a 20 43 68 65 63 6b 73 75 6d 20 72 65 63 6f 72  * Checksum recor
2740: 64 65 64 20 69 6e 20 74 68 65 20 6d 61 6e 69 66  ded in the manif
2750: 65 73 74 20 2a 2f 0a 20 0a 20 20 6e 6f 53 69 67  est */. .  noSig
2760: 6e 20 3d 20 66 69 6e 64 5f 6f 70 74 69 6f 6e 28  n = find_option(
2770: 22 6e 6f 73 69 67 6e 22 2c 22 22 2c 30 29 21 3d  "nosign","",0)!=
2780: 30 3b 0a 20 20 7a 43 6f 6d 6d 65 6e 74 20 3d 20  0;.  zComment = 
2790: 66 69 6e 64 5f 6f 70 74 69 6f 6e 28 22 63 6f 6d  find_option("com
27a0: 6d 65 6e 74 22 2c 22 6d 22 2c 31 29 3b 0a 20 20  ment","m",1);.  
27b0: 66 6f 72 63 65 46 6c 61 67 20 3d 20 66 69 6e 64  forceFlag = find
27c0: 5f 6f 70 74 69 6f 6e 28 22 66 6f 72 63 65 22 2c  _option("force",
27d0: 20 22 72 22 2c 20 30 29 21 3d 30 3b 0a 20 20 64   "r", 0)!=0;.  d
27e0: 62 5f 6d 75 73 74 5f 62 65 5f 77 69 74 68 69 6e  b_must_be_within
27f0: 5f 74 72 65 65 28 29 3b 0a 20 20 6e 6f 53 69 67  _tree();.  noSig
2800: 6e 20 3d 20 64 62 5f 67 65 74 5f 69 6e 74 28 22  n = db_get_int("
2810: 6f 6d 69 74 73 69 67 6e 22 2c 20 30 29 7c 6e 6f  omitsign", 0)|no
2820: 53 69 67 6e 3b 0a 20 20 76 65 72 69 66 79 5f 61  Sign;.  verify_a
2830: 6c 6c 5f 6f 70 74 69 6f 6e 73 28 29 3b 0a 0a 20  ll_options();.. 
2840: 20 2f 2a 0a 20 20 2a 2a 20 41 75 74 6f 73 79 6e   /*.  ** Autosyn
2850: 63 20 69 66 20 72 65 71 75 65 73 74 65 64 2e 0a  c if requested..
2860: 20 20 2a 2f 0a 20 20 61 75 74 6f 73 79 6e 63 28    */.  autosync(
2870: 31 29 3b 0a 20 20 0a 20 20 2f 2a 20 54 68 65 72  1);.  .  /* Ther
2880: 65 20 61 72 65 20 74 77 6f 20 77 61 79 73 20 74  e are two ways t
2890: 68 69 73 20 63 6f 6d 6d 61 6e 64 20 6d 61 79 20  his command may 
28a0: 62 65 20 65 78 65 63 75 74 65 64 2e 20 49 66 20  be executed. If 
28b0: 74 68 65 72 65 20 61 72 65 0a 20 20 2a 2a 20 6e  there are.  ** n
28c0: 6f 20 61 72 67 75 6d 65 6e 74 73 20 66 6f 6c 6c  o arguments foll
28d0: 6f 77 69 6e 67 20 74 68 65 20 77 6f 72 64 20 22  owing the word "
28e0: 63 6f 6d 6d 69 74 22 2c 20 74 68 65 6e 20 61 6c  commit", then al
28f0: 6c 20 6d 6f 64 69 66 69 65 64 20 66 69 6c 65 73  l modified files
2900: 0a 20 20 2a 2a 20 69 6e 20 74 68 65 20 63 68 65  .  ** in the che
2910: 63 6b 65 64 20 6f 75 74 20 64 69 72 65 63 74 6f  cked out directo
2920: 72 79 20 61 72 65 20 63 6f 6d 6d 69 74 74 65 64  ry are committed
2930: 2e 20 49 66 20 6f 6e 65 20 6f 72 20 6d 6f 72 65  . If one or more
2940: 20 61 72 67 75 6d 65 6e 74 73 0a 20 20 2a 2a 20   arguments.  ** 
2950: 66 6f 6c 6c 6f 77 73 20 22 63 6f 6d 6d 69 74 22  follows "commit"
2960: 2c 20 74 68 65 6e 20 6f 6e 6c 79 20 74 68 6f 73  , then only thos
2970: 65 20 66 69 6c 65 73 20 61 72 65 20 63 6f 6d 6d  e files are comm
2980: 69 74 74 65 64 2e 0a 20 20 2a 2a 0a 20 20 2a 2a  itted..  **.  **
2990: 20 41 66 74 65 72 20 74 68 65 20 66 6f 6c 6c 6f   After the follo
29a0: 77 69 6e 67 20 66 75 6e 63 74 69 6f 6e 20 63 61  wing function ca
29b0: 6c 6c 20 68 61 73 20 72 65 74 75 72 6e 65 64 2c  ll has returned,
29c0: 20 74 68 65 20 47 6c 6f 62 61 6c 2e 61 43 6f 6d   the Global.aCom
29d0: 6d 69 74 46 69 6c 65 5b 5d 0a 20 20 2a 2a 20 61  mitFile[].  ** a
29e0: 72 72 61 79 20 69 73 20 61 6c 6c 6f 63 61 74 65  rray is allocate
29f0: 64 20 74 6f 20 63 6f 6e 74 61 69 6e 20 74 68 65  d to contain the
2a00: 20 22 69 64 22 20 66 69 65 6c 64 20 66 72 6f 6d   "id" field from
2a10: 20 74 68 65 20 76 66 69 6c 65 20 74 61 62 6c 65   the vfile table
2a20: 0a 20 20 2a 2a 20 66 6f 72 20 65 61 63 68 20 66  .  ** for each f
2a30: 69 6c 65 20 74 6f 20 62 65 20 63 6f 6d 6d 69 74  ile to be commit
2a40: 74 65 64 2e 20 4f 72 2c 20 69 66 20 61 43 6f 6d  ted. Or, if aCom
2a50: 6d 69 74 46 69 6c 65 20 69 73 20 4e 55 4c 4c 2c  mitFile is NULL,
2a60: 20 61 6c 6c 20 66 69 6c 65 73 0a 20 20 2a 2a 20   all files.  ** 
2a70: 73 68 6f 75 6c 64 20 62 65 20 63 6f 6d 6d 69 74  should be commit
2a80: 74 65 64 2e 0a 20 20 2a 2f 0a 20 20 73 65 6c 65  ted..  */.  sele
2a90: 63 74 5f 63 6f 6d 6d 69 74 5f 66 69 6c 65 73 28  ct_commit_files(
2aa0: 29 3b 0a 20 20 69 73 41 4d 65 72 67 65 20 3d 20  );.  isAMerge = 
2ab0: 64 62 5f 65 78 69 73 74 73 28 22 53 45 4c 45 43  db_exists("SELEC
2ac0: 54 20 31 20 46 52 4f 4d 20 76 6d 65 72 67 65 22  T 1 FROM vmerge"
2ad0: 29 3b 0a 20 20 69 66 28 20 67 2e 61 43 6f 6d 6d  );.  if( g.aComm
2ae0: 69 74 46 69 6c 65 20 26 26 20 69 73 41 4d 65 72  itFile && isAMer
2af0: 67 65 20 29 7b 0a 20 20 20 20 66 6f 73 73 69 6c  ge ){.    fossil
2b00: 5f 66 61 74 61 6c 28 22 63 61 6e 6e 6f 74 20 64  _fatal("cannot d
2b10: 6f 20 61 20 70 61 72 74 69 61 6c 20 63 6f 6d 6d  o a partial comm
2b20: 69 74 20 6f 66 20 61 20 6d 65 72 67 65 22 29 3b  it of a merge");
2b30: 0a 20 20 7d 0a 0a 20 20 75 73 65 72 5f 73 65 6c  .  }..  user_sel
2b40: 65 63 74 28 29 3b 0a 20 20 2f 2a 0a 20 20 2a 2a  ect();.  /*.  **
2b50: 20 43 68 65 63 6b 20 74 68 61 74 20 74 68 65 20   Check that the 
2b60: 75 73 65 72 20 65 78 69 73 74 73 2e 0a 20 20 2a  user exists..  *
2b70: 2f 0a 20 20 69 66 28 20 21 64 62 5f 65 78 69 73  /.  if( !db_exis
2b80: 74 73 28 22 53 45 4c 45 43 54 20 31 20 46 52 4f  ts("SELECT 1 FRO
2b90: 4d 20 75 73 65 72 20 57 48 45 52 45 20 6c 6f 67  M user WHERE log
2ba0: 69 6e 3d 25 51 22 2c 20 67 2e 7a 4c 6f 67 69 6e  in=%Q", g.zLogin
2bb0: 29 20 29 7b 0a 20 20 20 20 66 6f 73 73 69 6c 5f  ) ){.    fossil_
2bc0: 66 61 74 61 6c 28 22 6e 6f 20 73 75 63 68 20 75  fatal("no such u
2bd0: 73 65 72 3a 20 25 73 22 2c 20 67 2e 7a 4c 6f 67  ser: %s", g.zLog
2be0: 69 6e 29 3b 0a 20 20 7d 0a 20 20 0a 20 20 64 62  in);.  }.  .  db
2bf0: 5f 62 65 67 69 6e 5f 74 72 61 6e 73 61 63 74 69  _begin_transacti
2c00: 6f 6e 28 29 3b 0a 20 20 72 63 20 3d 20 75 6e 73  on();.  rc = uns
2c10: 61 76 65 64 5f 63 68 61 6e 67 65 73 28 29 3b 0a  aved_changes();.
2c20: 20 20 69 66 28 20 72 63 3d 3d 30 20 26 26 20 21    if( rc==0 && !
2c30: 69 73 41 4d 65 72 67 65 20 26 26 20 21 66 6f 72  isAMerge && !for
2c40: 63 65 46 6c 61 67 20 29 7b 0a 20 20 20 20 66 6f  ceFlag ){.    fo
2c50: 73 73 69 6c 5f 70 61 6e 69 63 28 22 6e 6f 74 68  ssil_panic("noth
2c60: 69 6e 67 20 68 61 73 20 63 68 61 6e 67 65 64 22  ing has changed"
2c70: 29 3b 0a 20 20 7d 0a 0a 20 20 2f 2a 20 49 66 20  );.  }..  /* If 
2c80: 6f 6e 65 20 6f 72 20 6d 6f 72 65 20 66 69 6c 65  one or more file
2c90: 73 20 74 68 61 74 20 77 65 72 65 20 6e 61 6d 65  s that were name
2ca0: 64 20 6f 6e 20 74 68 65 20 63 6f 6d 6d 61 6e 64  d on the command
2cb0: 20 6c 69 6e 65 20 68 61 76 65 20 6e 6f 74 0a 20   line have not. 
2cc0: 20 2a 2a 20 62 65 65 6e 20 6d 6f 64 69 66 69 65   ** been modifie
2cd0: 64 2c 20 62 61 69 6c 20 6f 75 74 20 6e 6f 77 2e  d, bail out now.
2ce0: 0a 20 20 2a 2f 0a 20 20 69 66 28 20 67 2e 61 43  .  */.  if( g.aC
2cf0: 6f 6d 6d 69 74 46 69 6c 65 20 29 7b 0a 20 20 20  ommitFile ){.   
2d00: 20 42 6c 6f 62 20 75 6e 6d 6f 64 69 66 69 65 64   Blob unmodified
2d10: 3b 0a 20 20 20 20 6d 65 6d 73 65 74 28 26 75 6e  ;.    memset(&un
2d20: 6d 6f 64 69 66 69 65 64 2c 20 30 2c 20 73 69 7a  modified, 0, siz
2d30: 65 6f 66 28 42 6c 6f 62 29 29 3b 0a 20 20 20 20  eof(Blob));.    
2d40: 62 6c 6f 62 5f 69 6e 69 74 28 26 75 6e 6d 6f 64  blob_init(&unmod
2d50: 69 66 69 65 64 2c 20 30 2c 20 30 29 3b 0a 20 20  ified, 0, 0);.  
2d60: 20 20 64 62 5f 62 6c 6f 62 28 26 75 6e 6d 6f 64    db_blob(&unmod
2d70: 69 66 69 65 64 2c 20 0a 20 20 20 20 20 20 22 53  ified, .      "S
2d80: 45 4c 45 43 54 20 70 61 74 68 6e 61 6d 65 20 46  ELECT pathname F
2d90: 52 4f 4d 20 76 66 69 6c 65 20 57 48 45 52 45 20  ROM vfile WHERE 
2da0: 63 68 6e 67 65 64 20 3d 20 30 20 41 4e 44 20 66  chnged = 0 AND f
2db0: 69 6c 65 5f 69 73 5f 73 65 6c 65 63 74 65 64 28  ile_is_selected(
2dc0: 69 64 29 22 0a 20 20 20 20 29 3b 0a 20 20 20 20  id)".    );.    
2dd0: 69 66 28 20 73 74 72 6c 65 6e 28 62 6c 6f 62 5f  if( strlen(blob_
2de0: 73 74 72 28 26 75 6e 6d 6f 64 69 66 69 65 64 29  str(&unmodified)
2df0: 29 20 29 7b 0a 20 20 20 20 20 20 66 6f 73 73 69  ) ){.      fossi
2e00: 6c 5f 70 61 6e 69 63 28 22 66 69 6c 65 20 25 73  l_panic("file %s
2e10: 20 68 61 73 20 6e 6f 74 20 63 68 61 6e 67 65 64   has not changed
2e20: 22 2c 20 62 6c 6f 62 5f 73 74 72 28 26 75 6e 6d  ", blob_str(&unm
2e30: 6f 64 69 66 69 65 64 29 29 3b 0a 20 20 20 20 7d  odified));.    }
2e40: 0a 20 20 7d 0a 0a 20 20 76 69 64 20 3d 20 64 62  .  }..  vid = db
2e50: 5f 6c 67 65 74 5f 69 6e 74 28 22 63 68 65 63 6b  _lget_int("check
2e60: 6f 75 74 22 2c 20 30 29 3b 0a 20 20 69 66 28 20  out", 0);.  if( 
2e70: 64 62 5f 65 78 69 73 74 73 28 22 53 45 4c 45 43  db_exists("SELEC
2e80: 54 20 31 20 46 52 4f 4d 20 70 6c 69 6e 6b 20 57  T 1 FROM plink W
2e90: 48 45 52 45 20 70 69 64 3d 25 64 22 2c 20 76 69  HERE pid=%d", vi
2ea0: 64 29 20 29 7b 0a 20 20 20 20 77 6f 75 6c 64 46  d) ){.    wouldF
2eb0: 6f 72 6b 3d 31 3b 0a 20 20 20 20 69 66 28 20 66  ork=1;.    if( f
2ec0: 6f 72 63 65 46 6c 61 67 3d 3d 30 20 26 26 20 64  orceFlag==0 && d
2ed0: 62 5f 67 65 74 5f 69 6e 74 28 22 73 61 66 65 6d  b_get_int("safem
2ee0: 65 72 67 65 22 2c 20 30 29 3d 3d 30 20 29 7b 0a  erge", 0)==0 ){.
2ef0: 20 20 20 20 20 20 66 6f 73 73 69 6c 5f 66 61 74        fossil_fat
2f00: 61 6c 28 22 77 6f 75 6c 64 20 66 6f 72 6b 2e 20  al("would fork. 
2f10: 20 75 73 65 20 2d 66 20 6f 72 20 2d 2d 66 6f 72   use -f or --for
2f20: 63 65 22 29 3b 0a 20 20 20 20 7d 0a 20 20 7d 0a  ce");.    }.  }.
2f30: 20 20 76 66 69 6c 65 5f 61 67 67 72 65 67 61 74    vfile_aggregat
2f40: 65 5f 63 68 65 63 6b 73 75 6d 5f 64 69 73 6b 28  e_checksum_disk(
2f50: 76 69 64 2c 20 26 63 6b 73 75 6d 31 29 3b 0a 20  vid, &cksum1);. 
2f60: 20 69 66 28 20 7a 43 6f 6d 6d 65 6e 74 20 29 7b   if( zComment ){
2f70: 0a 20 20 20 20 62 6c 6f 62 5f 7a 65 72 6f 28 26  .    blob_zero(&
2f80: 63 6f 6d 6d 65 6e 74 29 3b 0a 20 20 20 20 62 6c  comment);.    bl
2f90: 6f 62 5f 61 70 70 65 6e 64 28 26 63 6f 6d 6d 65  ob_append(&comme
2fa0: 6e 74 2c 20 7a 43 6f 6d 6d 65 6e 74 2c 20 2d 31  nt, zComment, -1
2fb0: 29 3b 0a 20 20 7d 65 6c 73 65 7b 0a 20 20 20 20  );.  }else{.    
2fc0: 70 72 65 70 61 72 65 5f 63 6f 6d 6d 69 74 5f 63  prepare_commit_c
2fd0: 6f 6d 6d 65 6e 74 28 26 63 6f 6d 6d 65 6e 74 29  omment(&comment)
2fe0: 3b 0a 20 20 7d 0a 0a 20 20 2f 2a 20 53 74 65 70  ;.  }..  /* Step
2ff0: 20 31 3a 20 49 6e 73 65 72 74 20 72 65 63 6f 72   1: Insert recor
3000: 64 73 20 66 6f 72 20 61 6c 6c 20 6d 6f 64 69 66  ds for all modif
3010: 69 65 64 20 66 69 6c 65 73 20 69 6e 74 6f 20 74  ied files into t
3020: 68 65 20 62 6c 6f 62 20 0a 20 20 2a 2a 20 74 61  he blob .  ** ta
3030: 62 6c 65 2e 20 49 66 20 74 68 65 72 65 20 77 65  ble. If there we
3040: 72 65 20 61 72 67 75 6d 65 6e 74 73 20 70 61 73  re arguments pas
3050: 73 65 64 20 74 6f 20 74 68 69 73 20 63 6f 6d 6d  sed to this comm
3060: 61 6e 64 2c 20 6f 6e 6c 79 0a 20 20 2a 2a 20 74  and, only.  ** t
3070: 68 65 20 69 64 65 6e 74 69 66 69 65 64 20 66 69  he identified fi
3080: 6c 73 20 61 72 65 20 69 6e 73 65 72 74 65 64 20  ls are inserted 
3090: 28 69 66 20 74 68 65 79 20 68 61 76 65 20 62 65  (if they have be
30a0: 65 6e 20 6d 6f 64 69 66 69 65 64 29 2e 0a 20 20  en modified)..  
30b0: 2a 2f 0a 20 20 64 62 5f 70 72 65 70 61 72 65 28  */.  db_prepare(
30c0: 26 71 2c 0a 20 20 20 20 22 53 45 4c 45 43 54 20  &q,.    "SELECT 
30d0: 69 64 2c 20 25 51 20 7c 7c 20 70 61 74 68 6e 61  id, %Q || pathna
30e0: 6d 65 2c 20 6d 72 69 64 20 46 52 4f 4d 20 76 66  me, mrid FROM vf
30f0: 69 6c 65 20 22 0a 20 20 20 20 22 57 48 45 52 45  ile ".    "WHERE
3100: 20 63 68 6e 67 65 64 3d 3d 31 20 41 4e 44 20 4e   chnged==1 AND N
3110: 4f 54 20 64 65 6c 65 74 65 64 20 41 4e 44 20 66  OT deleted AND f
3120: 69 6c 65 5f 69 73 5f 73 65 6c 65 63 74 65 64 28  ile_is_selected(
3130: 69 64 29 22 0a 20 20 20 20 2c 20 67 2e 7a 4c 6f  id)".    , g.zLo
3140: 63 61 6c 52 6f 6f 74 0a 20 20 29 3b 0a 20 20 77  calRoot.  );.  w
3150: 68 69 6c 65 28 20 64 62 5f 73 74 65 70 28 26 71  hile( db_step(&q
3160: 29 3d 3d 53 51 4c 49 54 45 5f 52 4f 57 20 29 7b  )==SQLITE_ROW ){
3170: 0a 20 20 20 20 69 6e 74 20 69 64 2c 20 72 69 64  .    int id, rid
3180: 3b 0a 20 20 20 20 63 6f 6e 73 74 20 63 68 61 72  ;.    const char
3190: 20 2a 7a 46 75 6c 6c 6e 61 6d 65 3b 0a 20 20 20   *zFullname;.   
31a0: 20 42 6c 6f 62 20 63 6f 6e 74 65 6e 74 3b 0a 0a   Blob content;..
31b0: 20 20 20 20 69 64 20 3d 20 64 62 5f 63 6f 6c 75      id = db_colu
31c0: 6d 6e 5f 69 6e 74 28 26 71 2c 20 30 29 3b 0a 20  mn_int(&q, 0);. 
31d0: 20 20 20 7a 46 75 6c 6c 6e 61 6d 65 20 3d 20 64     zFullname = d
31e0: 62 5f 63 6f 6c 75 6d 6e 5f 74 65 78 74 28 26 71  b_column_text(&q
31f0: 2c 20 31 29 3b 0a 20 20 20 20 72 69 64 20 3d 20  , 1);.    rid = 
3200: 64 62 5f 63 6f 6c 75 6d 6e 5f 69 6e 74 28 26 71  db_column_int(&q
3210: 2c 20 32 29 3b 0a 0a 20 20 20 20 62 6c 6f 62 5f  , 2);..    blob_
3220: 7a 65 72 6f 28 26 63 6f 6e 74 65 6e 74 29 3b 0a  zero(&content);.
3230: 20 20 20 20 62 6c 6f 62 5f 72 65 61 64 5f 66 72      blob_read_fr
3240: 6f 6d 5f 66 69 6c 65 28 26 63 6f 6e 74 65 6e 74  om_file(&content
3250: 2c 20 7a 46 75 6c 6c 6e 61 6d 65 29 3b 0a 20 20  , zFullname);.  
3260: 20 20 6e 72 69 64 20 3d 20 63 6f 6e 74 65 6e 74    nrid = content
3270: 5f 70 75 74 28 26 63 6f 6e 74 65 6e 74 2c 20 30  _put(&content, 0
3280: 2c 20 30 29 3b 0a 20 20 20 20 69 66 28 20 72 69  , 0);.    if( ri
3290: 64 3e 30 20 29 7b 0a 20 20 20 20 20 20 63 6f 6e  d>0 ){.      con
32a0: 74 65 6e 74 5f 64 65 6c 74 69 66 79 28 72 69 64  tent_deltify(rid
32b0: 2c 20 6e 72 69 64 2c 20 30 29 3b 0a 20 20 20 20  , nrid, 0);.    
32c0: 7d 0a 20 20 20 20 64 62 5f 6d 75 6c 74 69 5f 65  }.    db_multi_e
32d0: 78 65 63 28 22 55 50 44 41 54 45 20 76 66 69 6c  xec("UPDATE vfil
32e0: 65 20 53 45 54 20 6d 72 69 64 3d 25 64 2c 20 72  e SET mrid=%d, r
32f0: 69 64 3d 25 64 20 57 48 45 52 45 20 69 64 3d 25  id=%d WHERE id=%
3300: 64 22 2c 20 6e 72 69 64 2c 6e 72 69 64 2c 69 64  d", nrid,nrid,id
3310: 29 3b 0a 20 20 20 20 64 62 5f 6d 75 6c 74 69 5f  );.    db_multi_
3320: 65 78 65 63 28 22 49 4e 53 45 52 54 20 4f 52 20  exec("INSERT OR 
3330: 49 47 4e 4f 52 45 20 49 4e 54 4f 20 75 6e 73 65  IGNORE INTO unse
3340: 6e 74 20 56 41 4c 55 45 53 28 25 64 29 22 2c 20  nt VALUES(%d)", 
3350: 6e 72 69 64 29 3b 0a 20 20 7d 0a 20 20 64 62 5f  nrid);.  }.  db_
3360: 66 69 6e 61 6c 69 7a 65 28 26 71 29 3b 0a 0a 20  finalize(&q);.. 
3370: 20 2f 2a 20 43 72 65 61 74 65 20 74 68 65 20 6d   /* Create the m
3380: 61 6e 69 66 65 73 74 20 2a 2f 0a 20 20 62 6c 6f  anifest */.  blo
3390: 62 5f 7a 65 72 6f 28 26 6d 61 6e 69 66 65 73 74  b_zero(&manifest
33a0: 29 3b 0a 20 20 69 66 28 20 62 6c 6f 62 5f 73 69  );.  if( blob_si
33b0: 7a 65 28 26 63 6f 6d 6d 65 6e 74 29 3d 3d 30 20  ze(&comment)==0 
33c0: 29 7b 0a 20 20 20 20 62 6c 6f 62 5f 61 70 70 65  ){.    blob_appe
33d0: 6e 64 28 26 63 6f 6d 6d 65 6e 74 2c 20 22 28 6e  nd(&comment, "(n
33e0: 6f 20 63 6f 6d 6d 65 6e 74 29 22 2c 20 2d 31 29  o comment)", -1)
33f0: 3b 0a 20 20 7d 0a 20 20 62 6c 6f 62 5f 61 70 70  ;.  }.  blob_app
3400: 65 6e 64 66 28 26 6d 61 6e 69 66 65 73 74 2c 20  endf(&manifest, 
3410: 22 43 20 25 46 5c 6e 22 2c 20 62 6c 6f 62 5f 73  "C %F\n", blob_s
3420: 74 72 28 26 63 6f 6d 6d 65 6e 74 29 29 3b 0a 20  tr(&comment));. 
3430: 20 7a 44 61 74 65 20 3d 20 64 62 5f 74 65 78 74   zDate = db_text
3440: 28 30 2c 20 22 53 45 4c 45 43 54 20 64 61 74 65  (0, "SELECT date
3450: 74 69 6d 65 28 27 6e 6f 77 27 29 22 29 3b 0a 20  time('now')");. 
3460: 20 7a 44 61 74 65 5b 31 30 5d 20 3d 20 27 54 27   zDate[10] = 'T'
3470: 3b 0a 20 20 62 6c 6f 62 5f 61 70 70 65 6e 64 66  ;.  blob_appendf
3480: 28 26 6d 61 6e 69 66 65 73 74 2c 20 22 44 20 25  (&manifest, "D %
3490: 73 5c 6e 22 2c 20 7a 44 61 74 65 29 3b 0a 20 20  s\n", zDate);.  
34a0: 64 62 5f 70 72 65 70 61 72 65 28 26 71 2c 0a 20  db_prepare(&q,. 
34b0: 20 20 20 22 53 45 4c 45 43 54 20 70 61 74 68 6e     "SELECT pathn
34c0: 61 6d 65 2c 20 75 75 69 64 20 46 52 4f 4d 20 76  ame, uuid FROM v
34d0: 66 69 6c 65 20 4a 4f 49 4e 20 62 6c 6f 62 20 4f  file JOIN blob O
34e0: 4e 20 76 66 69 6c 65 2e 6d 72 69 64 3d 62 6c 6f  N vfile.mrid=blo
34f0: 62 2e 72 69 64 22 0a 20 20 20 20 22 20 57 48 45  b.rid".    " WHE
3500: 52 45 20 4e 4f 54 20 64 65 6c 65 74 65 64 20 41  RE NOT deleted A
3510: 4e 44 20 76 66 69 6c 65 2e 76 69 64 3d 25 64 22  ND vfile.vid=%d"
3520: 0a 20 20 20 20 22 20 4f 52 44 45 52 20 42 59 20  .    " ORDER BY 
3530: 31 22 2c 20 76 69 64 29 3b 0a 20 20 77 68 69 6c  1", vid);.  whil
3540: 65 28 20 64 62 5f 73 74 65 70 28 26 71 29 3d 3d  e( db_step(&q)==
3550: 53 51 4c 49 54 45 5f 52 4f 57 20 29 7b 0a 20 20  SQLITE_ROW ){.  
3560: 20 20 63 6f 6e 73 74 20 63 68 61 72 20 2a 7a 4e    const char *zN
3570: 61 6d 65 20 3d 20 64 62 5f 63 6f 6c 75 6d 6e 5f  ame = db_column_
3580: 74 65 78 74 28 26 71 2c 20 30 29 3b 0a 20 20 20  text(&q, 0);.   
3590: 20 63 6f 6e 73 74 20 63 68 61 72 20 2a 7a 55 75   const char *zUu
35a0: 69 64 20 3d 20 64 62 5f 63 6f 6c 75 6d 6e 5f 74  id = db_column_t
35b0: 65 78 74 28 26 71 2c 20 31 29 3b 0a 20 20 20 20  ext(&q, 1);.    
35c0: 62 6c 6f 62 5f 61 70 70 65 6e 64 66 28 26 6d 61  blob_appendf(&ma
35d0: 6e 69 66 65 73 74 2c 20 22 46 20 25 46 20 25 73  nifest, "F %F %s
35e0: 5c 6e 22 2c 20 7a 4e 61 6d 65 2c 20 7a 55 75 69  \n", zName, zUui
35f0: 64 29 3b 0a 20 20 7d 0a 20 20 64 62 5f 66 69 6e  d);.  }.  db_fin
3600: 61 6c 69 7a 65 28 26 71 29 3b 0a 20 20 7a 55 75  alize(&q);.  zUu
3610: 69 64 20 3d 20 64 62 5f 74 65 78 74 28 30 2c 20  id = db_text(0, 
3620: 22 53 45 4c 45 43 54 20 75 75 69 64 20 46 52 4f  "SELECT uuid FRO
3630: 4d 20 62 6c 6f 62 20 57 48 45 52 45 20 72 69 64  M blob WHERE rid
3640: 3d 25 64 22 2c 20 76 69 64 29 3b 0a 20 20 62 6c  =%d", vid);.  bl
3650: 6f 62 5f 61 70 70 65 6e 64 66 28 26 6d 61 6e 69  ob_appendf(&mani
3660: 66 65 73 74 2c 20 22 50 20 25 73 22 2c 20 7a 55  fest, "P %s", zU
3670: 75 69 64 29 3b 0a 0a 20 20 64 62 5f 70 72 65 70  uid);..  db_prep
3680: 61 72 65 28 26 71 32 2c 20 22 53 45 4c 45 43 54  are(&q2, "SELECT
3690: 20 6d 65 72 67 65 20 46 52 4f 4d 20 76 6d 65 72   merge FROM vmer
36a0: 67 65 20 57 48 45 52 45 20 69 64 3d 3a 69 64 22  ge WHERE id=:id"
36b0: 29 3b 0a 20 20 64 62 5f 62 69 6e 64 5f 69 6e 74  );.  db_bind_int
36c0: 28 26 71 32 2c 20 22 3a 69 64 22 2c 20 30 29 3b  (&q2, ":id", 0);
36d0: 0a 20 20 77 68 69 6c 65 28 20 64 62 5f 73 74 65  .  while( db_ste
36e0: 70 28 26 71 32 29 3d 3d 53 51 4c 49 54 45 5f 52  p(&q2)==SQLITE_R
36f0: 4f 57 20 29 7b 0a 20 20 20 20 69 6e 74 20 6d 69  OW ){.    int mi
3700: 64 20 3d 20 64 62 5f 63 6f 6c 75 6d 6e 5f 69 6e  d = db_column_in
3710: 74 28 26 71 32 2c 20 30 29 3b 0a 20 20 20 20 7a  t(&q2, 0);.    z
3720: 55 75 69 64 20 3d 20 64 62 5f 74 65 78 74 28 30  Uuid = db_text(0
3730: 2c 20 22 53 45 4c 45 43 54 20 75 75 69 64 20 46  , "SELECT uuid F
3740: 52 4f 4d 20 62 6c 6f 62 20 57 48 45 52 45 20 72  ROM blob WHERE r
3750: 69 64 3d 25 64 22 2c 20 6d 69 64 29 3b 0a 20 20  id=%d", mid);.  
3760: 20 20 69 66 28 20 7a 55 75 69 64 20 29 7b 0a 20    if( zUuid ){. 
3770: 20 20 20 20 20 62 6c 6f 62 5f 61 70 70 65 6e 64       blob_append
3780: 66 28 26 6d 61 6e 69 66 65 73 74 2c 20 22 20 25  f(&manifest, " %
3790: 73 22 2c 20 7a 55 75 69 64 29 3b 0a 20 20 20 20  s", zUuid);.    
37a0: 20 20 66 72 65 65 28 7a 55 75 69 64 29 3b 0a 20    free(zUuid);. 
37b0: 20 20 20 7d 0a 20 20 7d 0a 20 20 64 62 5f 72 65     }.  }.  db_re
37c0: 73 65 74 28 26 71 32 29 3b 0a 0a 20 20 62 6c 6f  set(&q2);..  blo
37d0: 62 5f 61 70 70 65 6e 64 66 28 26 6d 61 6e 69 66  b_appendf(&manif
37e0: 65 73 74 2c 20 22 5c 6e 22 29 3b 0a 20 20 62 6c  est, "\n");.  bl
37f0: 6f 62 5f 61 70 70 65 6e 64 66 28 26 6d 61 6e 69  ob_appendf(&mani
3800: 66 65 73 74 2c 20 22 52 20 25 62 5c 6e 22 2c 20  fest, "R %b\n", 
3810: 26 63 6b 73 75 6d 31 29 3b 0a 20 20 62 6c 6f 62  &cksum1);.  blob
3820: 5f 61 70 70 65 6e 64 66 28 26 6d 61 6e 69 66 65  _appendf(&manife
3830: 73 74 2c 20 22 55 20 25 46 5c 6e 22 2c 20 67 2e  st, "U %F\n", g.
3840: 7a 4c 6f 67 69 6e 29 3b 0a 20 20 6d 64 35 73 75  zLogin);.  md5su
3850: 6d 5f 62 6c 6f 62 28 26 6d 61 6e 69 66 65 73 74  m_blob(&manifest
3860: 2c 20 26 6d 63 6b 73 75 6d 29 3b 0a 20 20 62 6c  , &mcksum);.  bl
3870: 6f 62 5f 61 70 70 65 6e 64 66 28 26 6d 61 6e 69  ob_appendf(&mani
3880: 66 65 73 74 2c 20 22 5a 20 25 62 5c 6e 22 2c 20  fest, "Z %b\n", 
3890: 26 6d 63 6b 73 75 6d 29 3b 0a 20 20 7a 4d 61 6e  &mcksum);.  zMan
38a0: 69 66 65 73 74 46 69 6c 65 20 3d 20 6d 70 72 69  ifestFile = mpri
38b0: 6e 74 66 28 22 25 73 6d 61 6e 69 66 65 73 74 22  ntf("%smanifest"
38c0: 2c 20 67 2e 7a 4c 6f 63 61 6c 52 6f 6f 74 29 3b  , g.zLocalRoot);
38d0: 0a 20 20 69 66 28 20 21 6e 6f 53 69 67 6e 20 26  .  if( !noSign &
38e0: 26 20 63 6c 65 61 72 73 69 67 6e 28 26 6d 61 6e  & clearsign(&man
38f0: 69 66 65 73 74 2c 20 26 6d 61 6e 69 66 65 73 74  ifest, &manifest
3900: 29 20 29 7b 0a 20 20 20 20 42 6c 6f 62 20 61 6e  ) ){.    Blob an
3910: 73 3b 0a 20 20 20 20 62 6c 6f 62 5f 7a 65 72 6f  s;.    blob_zero
3920: 28 26 61 6e 73 29 3b 0a 20 20 20 20 70 72 6f 6d  (&ans);.    prom
3930: 70 74 5f 75 73 65 72 28 22 75 6e 61 62 6c 65 20  pt_user("unable 
3940: 74 6f 20 73 69 67 6e 20 6d 61 6e 69 66 65 73 74  to sign manifest
3950: 2e 20 20 63 6f 6e 74 69 6e 75 65 20 5b 79 2f 4e  .  continue [y/N
3960: 5d 3f 20 22 2c 20 26 61 6e 73 29 3b 0a 20 20 20  ]? ", &ans);.   
3970: 20 69 66 28 20 62 6c 6f 62 5f 73 74 72 28 26 61   if( blob_str(&a
3980: 6e 73 29 5b 30 5d 21 3d 27 79 27 20 29 7b 0a 20  ns)[0]!='y' ){. 
3990: 20 20 20 20 20 64 62 5f 65 6e 64 5f 74 72 61 6e       db_end_tran
39a0: 73 61 63 74 69 6f 6e 28 31 29 3b 0a 20 20 20 20  saction(1);.    
39b0: 20 20 65 78 69 74 28 31 29 3b 0a 20 20 20 20 7d    exit(1);.    }
39c0: 0a 20 20 7d 0a 20 20 62 6c 6f 62 5f 77 72 69 74  .  }.  blob_writ
39d0: 65 5f 74 6f 5f 66 69 6c 65 28 26 6d 61 6e 69 66  e_to_file(&manif
39e0: 65 73 74 2c 20 7a 4d 61 6e 69 66 65 73 74 46 69  est, zManifestFi
39f0: 6c 65 29 3b 0a 20 20 62 6c 6f 62 5f 72 65 73 65  le);.  blob_rese
3a00: 74 28 26 6d 61 6e 69 66 65 73 74 29 3b 0a 20 20  t(&manifest);.  
3a10: 62 6c 6f 62 5f 72 65 61 64 5f 66 72 6f 6d 5f 66  blob_read_from_f
3a20: 69 6c 65 28 26 6d 61 6e 69 66 65 73 74 2c 20 7a  ile(&manifest, z
3a30: 4d 61 6e 69 66 65 73 74 46 69 6c 65 29 3b 0a 20  ManifestFile);. 
3a40: 20 66 72 65 65 28 7a 4d 61 6e 69 66 65 73 74 46   free(zManifestF
3a50: 69 6c 65 29 3b 0a 20 20 6e 76 69 64 20 3d 20 63  ile);.  nvid = c
3a60: 6f 6e 74 65 6e 74 5f 70 75 74 28 26 6d 61 6e 69  ontent_put(&mani
3a70: 66 65 73 74 2c 20 30 2c 20 30 29 3b 0a 20 20 69  fest, 0, 0);.  i
3a80: 66 28 20 6e 76 69 64 3d 3d 30 20 29 7b 0a 20 20  f( nvid==0 ){.  
3a90: 20 20 66 6f 73 73 69 6c 5f 70 61 6e 69 63 28 22    fossil_panic("
3aa0: 74 72 6f 75 62 6c 65 20 63 6f 6d 6d 69 74 74 69  trouble committi
3ab0: 6e 67 20 6d 61 6e 69 66 65 73 74 3a 20 25 73 22  ng manifest: %s"
3ac0: 2c 20 67 2e 7a 45 72 72 4d 73 67 29 3b 0a 20 20  , g.zErrMsg);.  
3ad0: 7d 0a 20 20 64 62 5f 6d 75 6c 74 69 5f 65 78 65  }.  db_multi_exe
3ae0: 63 28 22 49 4e 53 45 52 54 20 4f 52 20 49 47 4e  c("INSERT OR IGN
3af0: 4f 52 45 20 49 4e 54 4f 20 75 6e 73 65 6e 74 20  ORE INTO unsent 
3b00: 56 41 4c 55 45 53 28 25 64 29 22 2c 20 6e 76 69  VALUES(%d)", nvi
3b10: 64 29 3b 0a 20 20 6d 61 6e 69 66 65 73 74 5f 63  d);.  manifest_c
3b20: 72 6f 73 73 6c 69 6e 6b 28 6e 76 69 64 2c 20 26  rosslink(nvid, &
3b30: 6d 61 6e 69 66 65 73 74 29 3b 0a 20 20 63 6f 6e  manifest);.  con
3b40: 74 65 6e 74 5f 64 65 6c 74 69 66 79 28 76 69 64  tent_deltify(vid
3b50: 2c 20 6e 76 69 64 2c 20 30 29 3b 0a 20 20 7a 55  , nvid, 0);.  zU
3b60: 75 69 64 20 3d 20 64 62 5f 74 65 78 74 28 30 2c  uid = db_text(0,
3b70: 20 22 53 45 4c 45 43 54 20 75 75 69 64 20 46 52   "SELECT uuid FR
3b80: 4f 4d 20 62 6c 6f 62 20 57 48 45 52 45 20 72 69  OM blob WHERE ri
3b90: 64 3d 25 64 22 2c 20 6e 76 69 64 29 3b 0a 20 20  d=%d", nvid);.  
3ba0: 70 72 69 6e 74 66 28 22 4e 65 77 5f 56 65 72 73  printf("New_Vers
3bb0: 69 6f 6e 3a 20 25 73 5c 6e 22 2c 20 7a 55 75 69  ion: %s\n", zUui
3bc0: 64 29 3b 0a 20 20 7a 4d 61 6e 69 66 65 73 74 46  d);.  zManifestF
3bd0: 69 6c 65 20 3d 20 6d 70 72 69 6e 74 66 28 22 25  ile = mprintf("%
3be0: 73 6d 61 6e 69 66 65 73 74 2e 75 75 69 64 22 2c  smanifest.uuid",
3bf0: 20 67 2e 7a 4c 6f 63 61 6c 52 6f 6f 74 29 3b 0a   g.zLocalRoot);.
3c00: 20 20 62 6c 6f 62 5f 7a 65 72 6f 28 26 6d 75 75    blob_zero(&muu
3c10: 69 64 29 3b 0a 20 20 62 6c 6f 62 5f 61 70 70 65  id);.  blob_appe
3c20: 6e 64 66 28 26 6d 75 75 69 64 2c 20 22 25 73 5c  ndf(&muuid, "%s\
3c30: 6e 22 2c 20 7a 55 75 69 64 29 3b 0a 20 20 62 6c  n", zUuid);.  bl
3c40: 6f 62 5f 77 72 69 74 65 5f 74 6f 5f 66 69 6c 65  ob_write_to_file
3c50: 28 26 6d 75 75 69 64 2c 20 7a 4d 61 6e 69 66 65  (&muuid, zManife
3c60: 73 74 46 69 6c 65 29 3b 0a 20 20 66 72 65 65 28  stFile);.  free(
3c70: 7a 4d 61 6e 69 66 65 73 74 46 69 6c 65 29 3b 0a  zManifestFile);.
3c80: 20 20 62 6c 6f 62 5f 72 65 73 65 74 28 26 6d 75    blob_reset(&mu
3c90: 75 69 64 29 3b 0a 0a 20 20 0a 20 20 2f 2a 20 55  uid);..  .  /* U
3ca0: 70 64 61 74 65 20 74 68 65 20 76 66 69 6c 65 20  pdate the vfile 
3cb0: 61 6e 64 20 76 6d 65 72 67 65 20 74 61 62 6c 65  and vmerge table
3cc0: 73 20 2a 2f 0a 20 20 64 62 5f 6d 75 6c 74 69 5f  s */.  db_multi_
3cd0: 65 78 65 63 28 0a 20 20 20 20 22 44 45 4c 45 54  exec(.    "DELET
3ce0: 45 20 46 52 4f 4d 20 76 66 69 6c 65 20 57 48 45  E FROM vfile WHE
3cf0: 52 45 20 28 76 69 64 21 3d 25 64 20 4f 52 20 64  RE (vid!=%d OR d
3d00: 65 6c 65 74 65 64 29 20 41 4e 44 20 66 69 6c 65  eleted) AND file
3d10: 5f 69 73 5f 73 65 6c 65 63 74 65 64 28 69 64 29  _is_selected(id)
3d20: 3b 22 0a 20 20 20 20 22 44 45 4c 45 54 45 20 46  ;".    "DELETE F
3d30: 52 4f 4d 20 76 6d 65 72 67 65 20 57 48 45 52 45  ROM vmerge WHERE
3d40: 20 66 69 6c 65 5f 69 73 5f 73 65 6c 65 63 74 65   file_is_selecte
3d50: 64 28 69 64 29 20 4f 52 20 69 64 3d 30 3b 22 0a  d(id) OR id=0;".
3d60: 20 20 20 20 22 55 50 44 41 54 45 20 76 66 69 6c      "UPDATE vfil
3d70: 65 20 53 45 54 20 76 69 64 3d 25 64 3b 22 0a 20  e SET vid=%d;". 
3d80: 20 20 20 22 55 50 44 41 54 45 20 76 66 69 6c 65     "UPDATE vfile
3d90: 20 53 45 54 20 72 69 64 3d 6d 72 69 64 2c 20 63   SET rid=mrid, c
3da0: 68 6e 67 65 64 3d 30 2c 20 64 65 6c 65 74 65 64  hnged=0, deleted
3db0: 3d 30 20 57 48 45 52 45 20 66 69 6c 65 5f 69 73  =0 WHERE file_is
3dc0: 5f 73 65 6c 65 63 74 65 64 28 69 64 29 3b 22 0a  _selected(id);".
3dd0: 20 20 20 20 2c 20 76 69 64 2c 20 6e 76 69 64 0a      , vid, nvid.
3de0: 20 20 29 3b 0a 20 20 64 62 5f 6c 73 65 74 5f 69    );.  db_lset_i
3df0: 6e 74 28 22 63 68 65 63 6b 6f 75 74 22 2c 20 6e  nt("checkout", n
3e00: 76 69 64 29 3b 0a 0a 20 20 2f 2a 20 56 65 72 69  vid);..  /* Veri
3e10: 66 79 20 74 68 61 74 20 74 68 65 20 72 65 70 6f  fy that the repo
3e20: 73 69 74 6f 72 79 20 63 68 65 63 6b 73 75 6d 20  sitory checksum 
3e30: 6d 61 74 63 68 65 73 20 74 68 65 20 65 78 70 65  matches the expe
3e40: 63 74 65 64 20 63 68 65 63 6b 73 75 6d 0a 20 20  cted checksum.  
3e50: 2a 2a 20 63 61 6c 63 75 6c 61 74 65 64 20 62 65  ** calculated be
3e60: 66 6f 72 65 20 74 68 65 20 63 68 65 63 6b 69 6e  fore the checkin
3e70: 20 73 74 61 72 74 65 64 20 28 61 6e 64 20 73 74   started (and st
3e80: 6f 72 65 64 20 61 73 20 74 68 65 20 52 20 72 65  ored as the R re
3e90: 63 6f 72 64 0a 20 20 2a 2a 20 6f 66 20 74 68 65  cord.  ** of the
3ea0: 20 6d 61 6e 69 66 65 73 74 20 66 69 6c 65 29 2e   manifest file).
3eb0: 0a 20 20 2a 2f 0a 20 20 76 66 69 6c 65 5f 61 67  .  */.  vfile_ag
3ec0: 67 72 65 67 61 74 65 5f 63 68 65 63 6b 73 75 6d  gregate_checksum
3ed0: 5f 72 65 70 6f 73 69 74 6f 72 79 28 6e 76 69 64  _repository(nvid
3ee0: 2c 20 26 63 6b 73 75 6d 32 29 3b 0a 20 20 69 66  , &cksum2);.  if
3ef0: 28 20 62 6c 6f 62 5f 63 6f 6d 70 61 72 65 28 26  ( blob_compare(&
3f00: 63 6b 73 75 6d 31 2c 20 26 63 6b 73 75 6d 32 29  cksum1, &cksum2)
3f10: 20 29 7b 0a 20 20 20 20 66 6f 73 73 69 6c 5f 70   ){.    fossil_p
3f20: 61 6e 69 63 28 22 74 72 65 65 20 63 68 65 63 6b  anic("tree check
3f30: 73 75 6d 20 64 6f 65 73 20 6e 6f 74 20 6d 61 74  sum does not mat
3f40: 63 68 20 72 65 70 6f 73 69 74 6f 72 79 20 61 66  ch repository af
3f50: 74 65 72 20 63 6f 6d 6d 69 74 22 29 3b 0a 20 20  ter commit");.  
3f60: 7d 0a 0a 20 20 2f 2a 20 56 65 72 69 66 79 20 74  }..  /* Verify t
3f70: 68 61 74 20 74 68 65 20 6d 61 6e 69 66 65 73 74  hat the manifest
3f80: 20 63 68 65 63 6b 73 75 6d 20 6d 61 74 63 68 65   checksum matche
3f90: 73 20 74 68 65 20 65 78 70 65 63 74 65 64 20 63  s the expected c
3fa0: 68 65 63 6b 73 75 6d 20 2a 2f 0a 20 20 76 66 69  hecksum */.  vfi
3fb0: 6c 65 5f 61 67 67 72 65 67 61 74 65 5f 63 68 65  le_aggregate_che
3fc0: 63 6b 73 75 6d 5f 6d 61 6e 69 66 65 73 74 28 6e  cksum_manifest(n
3fd0: 76 69 64 2c 20 26 63 6b 73 75 6d 32 2c 20 26 63  vid, &cksum2, &c
3fe0: 6b 73 75 6d 31 62 29 3b 0a 20 20 69 66 28 20 62  ksum1b);.  if( b
3ff0: 6c 6f 62 5f 63 6f 6d 70 61 72 65 28 26 63 6b 73  lob_compare(&cks
4000: 75 6d 31 2c 20 26 63 6b 73 75 6d 31 62 29 20 29  um1, &cksum1b) )
4010: 7b 0a 20 20 20 20 66 6f 73 73 69 6c 5f 70 61 6e  {.    fossil_pan
4020: 69 63 28 22 6d 61 6e 69 66 65 73 74 20 63 68 65  ic("manifest che
4030: 63 6b 73 75 6d 20 64 6f 65 73 20 6e 6f 74 20 61  cksum does not a
4040: 67 72 65 65 20 77 69 74 68 20 6d 61 6e 69 66 65  gree with manife
4050: 73 74 3a 20 22 0a 20 20 20 20 20 20 20 20 20 20  st: ".          
4060: 20 20 20 20 20 20 20 22 25 62 20 76 65 72 73 75         "%b versu
4070: 73 20 25 62 22 2c 20 26 63 6b 73 75 6d 31 2c 20  s %b", &cksum1, 
4080: 26 63 6b 73 75 6d 31 62 29 3b 0a 20 20 7d 0a 20  &cksum1b);.  }. 
4090: 20 69 66 28 20 62 6c 6f 62 5f 63 6f 6d 70 61 72   if( blob_compar
40a0: 65 28 26 63 6b 73 75 6d 31 2c 20 26 63 6b 73 75  e(&cksum1, &cksu
40b0: 6d 32 29 20 29 7b 0a 20 20 20 20 66 6f 73 73 69  m2) ){.    fossi
40c0: 6c 5f 70 61 6e 69 63 28 22 74 72 65 65 20 63 68  l_panic("tree ch
40d0: 65 63 6b 73 75 6d 20 64 6f 65 73 20 6e 6f 74 20  ecksum does not 
40e0: 6d 61 74 63 68 20 6d 61 6e 69 66 65 73 74 20 61  match manifest a
40f0: 66 74 65 72 20 63 6f 6d 6d 69 74 3a 20 22 0a 20  fter commit: ". 
4100: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
4110: 22 25 62 20 76 65 72 73 75 73 20 25 62 22 2c 20  "%b versus %b", 
4120: 26 63 6b 73 75 6d 31 2c 20 26 63 6b 73 75 6d 32  &cksum1, &cksum2
4130: 29 3b 0a 20 20 7d 0a 0a 20 20 2f 2a 20 56 65 72  );.  }..  /* Ver
4140: 69 66 79 20 74 68 61 74 20 74 68 65 20 63 6f 6d  ify that the com
4150: 6d 69 74 20 64 69 64 20 6e 6f 74 20 6d 6f 64 69  mit did not modi
4160: 66 79 20 61 6e 79 20 64 69 73 6b 20 69 6d 61 67  fy any disk imag
4170: 65 73 2e 20 2a 2f 0a 20 20 76 66 69 6c 65 5f 61  es. */.  vfile_a
4180: 67 67 72 65 67 61 74 65 5f 63 68 65 63 6b 73 75  ggregate_checksu
4190: 6d 5f 64 69 73 6b 28 6e 76 69 64 2c 20 26 63 6b  m_disk(nvid, &ck
41a0: 73 75 6d 32 29 3b 0a 20 20 69 66 28 20 62 6c 6f  sum2);.  if( blo
41b0: 62 5f 63 6f 6d 70 61 72 65 28 26 63 6b 73 75 6d  b_compare(&cksum
41c0: 31 2c 20 26 63 6b 73 75 6d 32 29 20 29 7b 0a 20  1, &cksum2) ){. 
41d0: 20 20 20 66 6f 73 73 69 6c 5f 70 61 6e 69 63 28     fossil_panic(
41e0: 22 74 72 65 65 20 63 68 65 63 6b 73 75 6d 73 20  "tree checksums 
41f0: 62 65 66 6f 72 65 20 61 6e 64 20 61 66 74 65 72  before and after
4200: 20 63 6f 6d 6d 69 74 20 64 6f 20 6e 6f 74 20 6d   commit do not m
4210: 61 74 63 68 22 29 3b 0a 20 20 7d 0a 0a 20 20 2f  atch");.  }..  /
4220: 2a 20 43 6c 65 61 72 20 74 68 65 20 75 6e 64 6f  * Clear the undo
4230: 2f 72 65 64 6f 20 73 74 61 63 6b 20 2a 2f 0a 20  /redo stack */. 
4240: 20 75 6e 64 6f 5f 72 65 73 65 74 28 29 3b 0a 0a   undo_reset();..
4250: 20 20 2f 2a 20 43 6f 6d 6d 69 74 20 2a 2f 0a 20    /* Commit */. 
4260: 20 64 62 5f 65 6e 64 5f 74 72 61 6e 73 61 63 74   db_end_transact
4270: 69 6f 6e 28 30 29 3b 0a 20 20 0a 20 20 69 66 28  ion(0);.  .  if(
4280: 20 77 6f 75 6c 64 46 6f 72 6b 3d 3d 30 20 29 7b   wouldFork==0 ){
4290: 0a 20 20 20 20 2f 2a 20 44 6f 20 61 6e 20 61 75  .    /* Do an au
42a0: 74 6f 73 79 6e 63 20 70 75 73 68 20 69 66 20 72  tosync push if r
42b0: 65 71 75 65 73 74 65 64 2e 20 49 66 20 77 6f 75  equested. If wou
42c0: 6c 64 46 6f 72 6b 20 3d 3d 20 31 2c 20 74 68 65  ldFork == 1, the
42d0: 6e 20 74 68 65 79 20 65 69 74 68 65 72 0a 20 20  n they either.  
42e0: 20 20 2a 2a 20 66 6f 72 63 65 64 20 74 68 69 73    ** forced this
42f0: 20 63 6f 6d 6d 69 74 20 6f 72 20 73 61 66 65 20   commit or safe 
4300: 6d 65 72 67 65 20 69 73 20 6f 6e 2c 20 61 6e 64  merge is on, and
4310: 20 74 68 69 73 20 63 6f 6d 6d 69 74 20 64 69 64   this commit did
4320: 20 69 6e 64 65 65 64 0a 20 20 20 20 2a 2a 20 63   indeed.    ** c
4330: 72 65 61 74 65 20 61 20 66 6f 72 6b 2e 20 49 6e  reate a fork. In
4340: 20 74 68 69 73 20 63 61 73 65 2c 20 77 65 20 77   this case, we w
4350: 61 6e 74 20 74 68 65 20 75 73 65 72 20 74 6f 20  ant the user to 
4360: 6d 65 72 67 65 20 62 65 66 6f 72 65 20 73 65 6e  merge before sen
4370: 64 69 6e 67 0a 20 20 20 20 2a 2a 20 74 68 65 69  ding.    ** thei
4380: 72 20 6e 65 77 20 63 6f 6d 6d 69 74 20 62 61 63  r new commit bac
4390: 6b 20 74 6f 20 74 68 65 20 72 65 73 74 20 6f 66  k to the rest of
43a0: 20 74 68 65 20 77 6f 72 6c 64 2c 20 73 6f 20 64   the world, so d
43b0: 6f 20 6e 6f 74 20 61 75 74 6f 2d 70 75 73 68 2e  o not auto-push.
43c0: 0a 20 20 20 20 2a 2f 0a 20 20 20 20 61 75 74 6f  .    */.    auto
43d0: 73 79 6e 63 28 30 29 3b 0a 20 20 7d 65 6c 73 65  sync(0);.  }else
43e0: 7b 0a 20 20 20 20 70 72 69 6e 74 66 28 22 57 61  {.    printf("Wa
43f0: 72 6e 69 6e 67 3a 20 63 6f 6d 6d 69 74 20 63 61  rning: commit ca
4400: 75 73 65 64 20 61 20 66 6f 72 6b 20 74 6f 20 6f  used a fork to o
4410: 63 63 75 72 2e 20 50 6c 65 61 73 65 20 6d 65 72  ccur. Please mer
4420: 67 65 20 61 6e 64 20 70 75 73 68 5c 6e 22 29 3b  ge and push\n");
4430: 0a 20 20 20 20 70 72 69 6e 74 66 28 22 20 20 20  .    printf("   
4440: 20 20 20 20 20 20 79 6f 75 72 20 63 68 61 6e 67        your chang
4450: 65 73 20 61 73 20 73 6f 6f 6e 20 61 73 20 70 6f  es as soon as po
4460: 73 73 69 62 6c 65 2e 5c 6e 22 29 3b 0a 20 20 7d  ssible.\n");.  }
4470: 0a 7d 0a                                         .}.