Hex Artifact Content
Not logged in

Artifact 45c26e70ac8cda8014dc29d8ed1fe66078650002:

File src/checkin.c part of check-in [0431f14edf] - Once a successful commit is made, if autosync is on, a push is now done. This commit will be the first test of that new functionality :-) by jnc on 2007-09-25 07:11:57.

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 62 6c 6f 62 5f 61 70 70 65 6e 64  .    blob_append
0680: 28 72 65 70 6f 72 74 2c 20 7a 50 72 65 66 69 78  (report, zPrefix
0690: 2c 20 6e 50 72 65 66 69 78 29 3b 0a 20 20 20 20  , nPrefix);.    
06a0: 69 66 28 20 69 73 4e 65 77 20 29 7b 0a 20 20 20  if( isNew ){.   
06b0: 20 20 20 62 6c 6f 62 5f 61 70 70 65 6e 64 66 28     blob_appendf(
06c0: 72 65 70 6f 72 74 2c 20 22 41 44 44 45 44 20 20  report, "ADDED  
06d0: 20 20 25 73 5c 6e 22 2c 20 7a 50 61 74 68 6e 61    %s\n", zPathna
06e0: 6d 65 29 3b 0a 20 20 20 20 7d 65 6c 73 65 20 69  me);.    }else i
06f0: 66 28 20 69 73 44 65 6c 65 74 65 64 20 29 7b 0a  f( isDeleted ){.
0700: 20 20 20 20 20 20 62 6c 6f 62 5f 61 70 70 65 6e        blob_appen
0710: 64 66 28 72 65 70 6f 72 74 2c 20 22 44 45 4c 45  df(report, "DELE
0720: 54 45 44 20 20 25 73 5c 6e 22 2c 20 7a 50 61 74  TED  %s\n", zPat
0730: 68 6e 61 6d 65 29 3b 0a 20 20 20 20 7d 65 6c 73  hname);.    }els
0740: 65 20 69 66 28 20 69 73 43 68 6e 67 65 64 3d 3d  e if( isChnged==
0750: 32 20 29 7b 0a 20 20 20 20 20 20 62 6c 6f 62 5f  2 ){.      blob_
0760: 61 70 70 65 6e 64 66 28 72 65 70 6f 72 74 2c 20  appendf(report, 
0770: 22 55 50 44 41 54 45 44 5f 42 59 5f 4d 45 52 47  "UPDATED_BY_MERG
0780: 45 20 25 73 5c 6e 22 2c 20 7a 50 61 74 68 6e 61  E %s\n", zPathna
0790: 6d 65 29 3b 0a 20 20 20 20 7d 65 6c 73 65 20 69  me);.    }else i
07a0: 66 28 20 69 73 43 68 6e 67 65 64 3d 3d 33 20 29  f( isChnged==3 )
07b0: 7b 0a 20 20 20 20 20 20 62 6c 6f 62 5f 61 70 70  {.      blob_app
07c0: 65 6e 64 66 28 72 65 70 6f 72 74 2c 20 22 41 44  endf(report, "AD
07d0: 44 45 44 5f 42 59 5f 4d 45 52 47 45 20 25 73 5c  DED_BY_MERGE %s\
07e0: 6e 22 2c 20 7a 50 61 74 68 6e 61 6d 65 29 3b 0a  n", zPathname);.
07f0: 20 20 20 20 7d 65 6c 73 65 7b 0a 20 20 20 20 20      }else{.     
0800: 20 62 6c 6f 62 5f 61 70 70 65 6e 64 66 28 72 65   blob_appendf(re
0810: 70 6f 72 74 2c 20 22 45 44 49 54 45 44 20 20 20  port, "EDITED   
0820: 25 73 5c 6e 22 2c 20 7a 50 61 74 68 6e 61 6d 65  %s\n", zPathname
0830: 29 3b 0a 20 20 20 20 7d 0a 20 20 7d 0a 20 20 64  );.    }.  }.  d
0840: 62 5f 66 69 6e 61 6c 69 7a 65 28 26 71 29 3b 0a  b_finalize(&q);.
0850: 20 20 64 62 5f 70 72 65 70 61 72 65 28 26 71 2c    db_prepare(&q,
0860: 20 22 53 45 4c 45 43 54 20 75 75 69 64 20 46 52   "SELECT uuid FR
0870: 4f 4d 20 76 6d 65 72 67 65 20 4a 4f 49 4e 20 62  OM vmerge JOIN b
0880: 6c 6f 62 20 4f 4e 20 6d 65 72 67 65 3d 72 69 64  lob ON merge=rid
0890: 22 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20  ".              
08a0: 20 20 20 22 20 57 48 45 52 45 20 69 64 3d 30 22     " WHERE id=0"
08b0: 29 3b 0a 20 20 77 68 69 6c 65 28 20 64 62 5f 73  );.  while( db_s
08c0: 74 65 70 28 26 71 29 3d 3d 53 51 4c 49 54 45 5f  tep(&q)==SQLITE_
08d0: 52 4f 57 20 29 7b 0a 20 20 20 20 62 6c 6f 62 5f  ROW ){.    blob_
08e0: 61 70 70 65 6e 64 28 72 65 70 6f 72 74 2c 20 7a  append(report, z
08f0: 50 72 65 66 69 78 2c 20 6e 50 72 65 66 69 78 29  Prefix, nPrefix)
0900: 3b 0a 20 20 20 20 62 6c 6f 62 5f 61 70 70 65 6e  ;.    blob_appen
0910: 64 66 28 72 65 70 6f 72 74 2c 20 22 4d 45 52 47  df(report, "MERG
0920: 45 44 5f 57 49 54 48 20 25 73 5c 6e 22 2c 20 64  ED_WITH %s\n", d
0930: 62 5f 63 6f 6c 75 6d 6e 5f 74 65 78 74 28 26 71  b_column_text(&q
0940: 2c 20 30 29 29 3b 0a 20 20 7d 0a 20 20 64 62 5f  , 0));.  }.  db_
0950: 66 69 6e 61 6c 69 7a 65 28 26 71 29 3b 0a 7d 0a  finalize(&q);.}.
0960: 0a 2f 2a 0a 2a 2a 20 43 4f 4d 4d 41 4e 44 3a 20  ./*.** COMMAND: 
0970: 63 68 61 6e 67 65 73 0a 2a 2a 0a 2a 2a 20 55 73  changes.**.** Us
0980: 61 67 65 3a 20 25 66 6f 73 73 69 6c 20 63 68 61  age: %fossil cha
0990: 6e 67 65 73 0a 2a 2a 20 52 65 70 6f 72 74 20 6f  nges.** Report o
09a0: 6e 20 74 68 65 20 65 64 69 74 20 73 74 61 74 75  n the edit statu
09b0: 73 20 6f 66 20 61 6c 6c 20 66 69 6c 65 73 20 69  s of all files i
09c0: 6e 20 74 68 65 20 63 75 72 72 65 6e 74 20 63 68  n the current ch
09d0: 65 63 6b 6f 75 74 2e 0a 2a 2a 20 53 65 65 20 61  eckout..** See a
09e0: 6c 73 6f 20 74 68 65 20 22 73 74 61 74 75 73 22  lso the "status"
09f0: 20 61 6e 64 20 22 65 78 74 72 61 22 20 63 6f 6d   and "extra" com
0a00: 6d 61 6e 64 73 2e 0a 2a 2f 0a 76 6f 69 64 20 63  mands..*/.void c
0a10: 68 61 6e 67 65 73 5f 63 6d 64 28 76 6f 69 64 29  hanges_cmd(void)
0a20: 7b 0a 20 20 42 6c 6f 62 20 72 65 70 6f 72 74 3b  {.  Blob report;
0a30: 0a 20 20 69 6e 74 20 76 69 64 3b 0a 20 20 64 62  .  int vid;.  db
0a40: 5f 6d 75 73 74 5f 62 65 5f 77 69 74 68 69 6e 5f  _must_be_within_
0a50: 74 72 65 65 28 29 3b 0a 20 20 62 6c 6f 62 5f 7a  tree();.  blob_z
0a60: 65 72 6f 28 26 72 65 70 6f 72 74 29 3b 0a 20 20  ero(&report);.  
0a70: 76 69 64 20 3d 20 64 62 5f 6c 67 65 74 5f 69 6e  vid = db_lget_in
0a80: 74 28 22 63 68 65 63 6b 6f 75 74 22 2c 20 30 29  t("checkout", 0)
0a90: 3b 0a 20 20 76 66 69 6c 65 5f 63 68 65 63 6b 5f  ;.  vfile_check_
0aa0: 73 69 67 6e 61 74 75 72 65 28 76 69 64 29 3b 0a  signature(vid);.
0ab0: 20 20 73 74 61 74 75 73 5f 72 65 70 6f 72 74 28    status_report(
0ac0: 26 72 65 70 6f 72 74 2c 20 22 22 29 3b 0a 20 20  &report, "");.  
0ad0: 62 6c 6f 62 5f 77 72 69 74 65 5f 74 6f 5f 66 69  blob_write_to_fi
0ae0: 6c 65 28 26 72 65 70 6f 72 74 2c 20 22 2d 22 29  le(&report, "-")
0af0: 3b 0a 7d 0a 0a 2f 2a 0a 2a 2a 20 43 4f 4d 4d 41  ;.}../*.** COMMA
0b00: 4e 44 3a 20 73 74 61 74 75 73 0a 2a 2a 20 55 73  ND: status.** Us
0b10: 61 67 65 3a 20 25 66 6f 73 73 69 6c 20 73 74 61  age: %fossil sta
0b20: 74 75 73 0a 2a 2a 20 52 65 70 6f 72 74 20 6f 6e  tus.** Report on
0b30: 20 74 68 65 20 73 74 61 74 75 73 20 6f 66 20 74   the status of t
0b40: 68 65 20 63 75 72 72 65 6e 74 20 63 68 65 63 6b  he current check
0b50: 6f 75 74 2e 0a 2a 2f 0a 76 6f 69 64 20 73 74 61  out..*/.void sta
0b60: 74 75 73 5f 63 6d 64 28 76 6f 69 64 29 7b 0a 20  tus_cmd(void){. 
0b70: 20 69 6e 74 20 76 69 64 3b 0a 20 20 64 62 5f 6d   int vid;.  db_m
0b80: 75 73 74 5f 62 65 5f 77 69 74 68 69 6e 5f 74 72  ust_be_within_tr
0b90: 65 65 28 29 3b 0a 20 20 20 20 20 20 20 2f 2a 20  ee();.       /* 
0ba0: 30 31 32 33 34 35 36 37 38 39 30 31 32 33 34 20  012345678901234 
0bb0: 2a 2f 0a 20 20 70 72 69 6e 74 66 28 22 72 65 70  */.  printf("rep
0bc0: 6f 73 69 74 6f 72 79 3a 20 20 20 25 73 5c 6e 22  ository:   %s\n"
0bd0: 2c 20 64 62 5f 6c 67 65 74 28 22 72 65 70 6f 73  , db_lget("repos
0be0: 69 74 6f 72 79 22 2c 22 22 29 29 3b 0a 20 20 70  itory",""));.  p
0bf0: 72 69 6e 74 66 28 22 6c 6f 63 61 6c 2d 72 6f 6f  rintf("local-roo
0c00: 74 3a 20 20 20 25 73 5c 6e 22 2c 20 67 2e 7a 4c  t:   %s\n", g.zL
0c10: 6f 63 61 6c 52 6f 6f 74 29 3b 0a 20 20 70 72 69  ocalRoot);.  pri
0c20: 6e 74 66 28 22 73 65 72 76 65 72 2d 63 6f 64 65  ntf("server-code
0c30: 3a 20 20 25 73 5c 6e 22 2c 20 64 62 5f 67 65 74  :  %s\n", db_get
0c40: 28 22 73 65 72 76 65 72 2d 63 6f 64 65 22 2c 20  ("server-code", 
0c50: 22 22 29 29 3b 0a 20 20 76 69 64 20 3d 20 64 62  ""));.  vid = db
0c60: 5f 6c 67 65 74 5f 69 6e 74 28 22 63 68 65 63 6b  _lget_int("check
0c70: 6f 75 74 22 2c 20 30 29 3b 0a 20 20 69 66 28 20  out", 0);.  if( 
0c80: 76 69 64 20 29 7b 0a 20 20 20 20 73 68 6f 77 5f  vid ){.    show_
0c90: 63 6f 6d 6d 6f 6e 5f 69 6e 66 6f 28 76 69 64 2c  common_info(vid,
0ca0: 20 22 63 68 65 63 6b 6f 75 74 3a 22 2c 20 30 29   "checkout:", 0)
0cb0: 3b 0a 20 20 7d 0a 20 20 63 68 61 6e 67 65 73 5f  ;.  }.  changes_
0cc0: 63 6d 64 28 29 3b 0a 7d 0a 0a 2f 2a 0a 2a 2a 20  cmd();.}../*.** 
0cd0: 43 4f 4d 4d 41 4e 44 3a 20 6c 73 0a 2a 2a 20 55  COMMAND: ls.** U
0ce0: 73 61 67 65 3a 20 25 66 6f 73 73 69 6c 20 6c 73  sage: %fossil ls
0cf0: 0a 2a 2a 20 53 68 6f 77 20 74 68 65 20 6e 61 6d  .** Show the nam
0d00: 65 73 20 6f 66 20 61 6c 6c 20 66 69 6c 65 73 20  es of all files 
0d10: 69 6e 20 74 68 65 20 63 75 72 72 65 6e 74 20 63  in the current c
0d20: 68 65 63 6b 6f 75 74 0a 2a 2f 0a 76 6f 69 64 20  heckout.*/.void 
0d30: 6c 73 5f 63 6d 64 28 76 6f 69 64 29 7b 0a 20 20  ls_cmd(void){.  
0d40: 69 6e 74 20 76 69 64 3b 0a 20 20 53 74 6d 74 20  int vid;.  Stmt 
0d50: 71 3b 0a 0a 20 20 64 62 5f 6d 75 73 74 5f 62 65  q;..  db_must_be
0d60: 5f 77 69 74 68 69 6e 5f 74 72 65 65 28 29 3b 0a  _within_tree();.
0d70: 20 20 76 69 64 20 3d 20 64 62 5f 6c 67 65 74 5f    vid = db_lget_
0d80: 69 6e 74 28 22 63 68 65 63 6b 6f 75 74 22 2c 20  int("checkout", 
0d90: 30 29 3b 0a 20 20 76 66 69 6c 65 5f 63 68 65 63  0);.  vfile_chec
0da0: 6b 5f 73 69 67 6e 61 74 75 72 65 28 76 69 64 29  k_signature(vid)
0db0: 3b 0a 20 20 64 62 5f 70 72 65 70 61 72 65 28 26  ;.  db_prepare(&
0dc0: 71 2c 20 22 53 45 4c 45 43 54 20 70 61 74 68 6e  q, "SELECT pathn
0dd0: 61 6d 65 2c 20 64 65 6c 65 74 65 64 2c 20 72 69  ame, deleted, ri
0de0: 64 2c 20 63 68 6e 67 65 64 20 46 52 4f 4d 20 76  d, chnged FROM v
0df0: 66 69 6c 65 22 0a 20 20 20 20 20 20 20 20 20 20  file".          
0e00: 20 20 20 20 20 20 20 22 20 4f 52 44 45 52 20 42         " ORDER B
0e10: 59 20 31 22 29 3b 0a 20 20 77 68 69 6c 65 28 20  Y 1");.  while( 
0e20: 64 62 5f 73 74 65 70 28 26 71 29 3d 3d 53 51 4c  db_step(&q)==SQL
0e30: 49 54 45 5f 52 4f 57 20 29 7b 0a 20 20 20 20 63  ITE_ROW ){.    c
0e40: 6f 6e 73 74 20 63 68 61 72 20 2a 7a 50 61 74 68  onst char *zPath
0e50: 6e 61 6d 65 20 3d 20 64 62 5f 63 6f 6c 75 6d 6e  name = db_column
0e60: 5f 74 65 78 74 28 26 71 2c 30 29 3b 0a 20 20 20  _text(&q,0);.   
0e70: 20 69 6e 74 20 69 73 44 65 6c 65 74 65 64 20 3d   int isDeleted =
0e80: 20 64 62 5f 63 6f 6c 75 6d 6e 5f 69 6e 74 28 26   db_column_int(&
0e90: 71 2c 20 31 29 3b 0a 20 20 20 20 69 6e 74 20 69  q, 1);.    int i
0ea0: 73 4e 65 77 20 3d 20 64 62 5f 63 6f 6c 75 6d 6e  sNew = db_column
0eb0: 5f 69 6e 74 28 26 71 2c 32 29 3d 3d 30 3b 0a 20  _int(&q,2)==0;. 
0ec0: 20 20 20 69 6e 74 20 63 68 6e 67 65 64 20 3d 20     int chnged = 
0ed0: 64 62 5f 63 6f 6c 75 6d 6e 5f 69 6e 74 28 26 71  db_column_int(&q
0ee0: 2c 33 29 3b 0a 20 20 20 20 69 66 28 20 69 73 4e  ,3);.    if( isN
0ef0: 65 77 20 29 7b 0a 20 20 20 20 20 20 70 72 69 6e  ew ){.      prin
0f00: 74 66 28 22 41 44 44 45 44 20 20 20 20 20 25 73  tf("ADDED     %s
0f10: 5c 6e 22 2c 20 7a 50 61 74 68 6e 61 6d 65 29 3b  \n", zPathname);
0f20: 0a 20 20 20 20 7d 65 6c 73 65 20 69 66 28 20 69  .    }else if( i
0f30: 73 44 65 6c 65 74 65 64 20 29 7b 0a 20 20 20 20  sDeleted ){.    
0f40: 20 20 70 72 69 6e 74 66 28 22 44 45 4c 45 54 45    printf("DELETE
0f50: 44 20 20 20 25 73 5c 6e 22 2c 20 7a 50 61 74 68  D   %s\n", zPath
0f60: 6e 61 6d 65 29 3b 0a 20 20 20 20 7d 65 6c 73 65  name);.    }else
0f70: 20 69 66 28 20 63 68 6e 67 65 64 20 29 7b 0a 20   if( chnged ){. 
0f80: 20 20 20 20 20 70 72 69 6e 74 66 28 22 45 44 49       printf("EDI
0f90: 54 45 44 20 20 20 20 25 73 5c 6e 22 2c 20 7a 50  TED    %s\n", zP
0fa0: 61 74 68 6e 61 6d 65 29 3b 0a 20 20 20 20 7d 65  athname);.    }e
0fb0: 6c 73 65 7b 0a 20 20 20 20 20 20 70 72 69 6e 74  lse{.      print
0fc0: 66 28 22 55 4e 43 48 41 4e 47 45 44 20 25 73 5c  f("UNCHANGED %s\
0fd0: 6e 22 2c 20 7a 50 61 74 68 6e 61 6d 65 29 3b 0a  n", zPathname);.
0fe0: 20 20 20 20 7d 0a 20 20 7d 0a 20 20 64 62 5f 66      }.  }.  db_f
0ff0: 69 6e 61 6c 69 7a 65 28 26 71 29 3b 0a 7d 0a 0a  inalize(&q);.}..
1000: 2f 2a 0a 2a 2a 20 43 4f 4d 4d 41 4e 44 3a 20 65  /*.** COMMAND: e
1010: 78 74 72 61 0a 2a 2a 20 55 73 61 67 65 3a 20 25  xtra.** Usage: %
1020: 66 6f 73 73 69 6c 20 65 78 74 72 61 0a 2a 2a 20  fossil extra.** 
1030: 50 72 69 6e 74 20 61 20 6c 69 73 74 20 6f 66 20  Print a list of 
1040: 61 6c 6c 20 66 69 6c 65 73 20 69 6e 20 74 68 65  all files in the
1050: 20 73 6f 75 72 63 65 20 74 72 65 65 20 74 68 61   source tree tha
1060: 74 20 61 72 65 20 6e 6f 74 20 70 61 72 74 20 6f  t are not part o
1070: 66 0a 2a 2a 20 74 68 65 20 63 75 72 72 65 6e 74  f.** the current
1080: 20 63 68 65 63 6b 6f 75 74 2e 20 20 53 65 65 20   checkout.  See 
1090: 61 6c 73 6f 20 74 68 65 20 22 63 6c 65 61 6e 22  also the "clean"
10a0: 20 63 6f 6d 6d 61 6e 64 2e 0a 2a 2f 0a 76 6f 69   command..*/.voi
10b0: 64 20 65 78 74 72 61 5f 63 6d 64 28 76 6f 69 64  d extra_cmd(void
10c0: 29 7b 0a 20 20 42 6c 6f 62 20 70 61 74 68 3b 0a  ){.  Blob path;.
10d0: 20 20 53 74 6d 74 20 71 3b 0a 20 20 64 62 5f 6d    Stmt q;.  db_m
10e0: 75 73 74 5f 62 65 5f 77 69 74 68 69 6e 5f 74 72  ust_be_within_tr
10f0: 65 65 28 29 3b 0a 20 20 64 62 5f 6d 75 6c 74 69  ee();.  db_multi
1100: 5f 65 78 65 63 28 22 43 52 45 41 54 45 20 54 45  _exec("CREATE TE
1110: 4d 50 20 54 41 42 4c 45 20 73 66 69 6c 65 28 78  MP TABLE sfile(x
1120: 20 54 45 58 54 20 50 52 49 4d 41 52 59 20 4b 45   TEXT PRIMARY KE
1130: 59 29 22 29 3b 0a 20 20 63 68 64 69 72 28 67 2e  Y)");.  chdir(g.
1140: 7a 4c 6f 63 61 6c 52 6f 6f 74 29 3b 0a 20 20 62  zLocalRoot);.  b
1150: 6c 6f 62 5f 7a 65 72 6f 28 26 70 61 74 68 29 3b  lob_zero(&path);
1160: 0a 20 20 76 66 69 6c 65 5f 73 63 61 6e 28 30 2c  .  vfile_scan(0,
1170: 20 26 70 61 74 68 29 3b 0a 20 20 64 62 5f 70 72   &path);.  db_pr
1180: 65 70 61 72 65 28 26 71 2c 20 0a 20 20 20 20 20  epare(&q, .     
1190: 20 22 53 45 4c 45 43 54 20 78 20 46 52 4f 4d 20   "SELECT x FROM 
11a0: 73 66 69 6c 65 22 0a 20 20 20 20 20 20 22 20 57  sfile".      " W
11b0: 48 45 52 45 20 78 20 4e 4f 54 20 49 4e 20 28 27  HERE x NOT IN ('
11c0: 6d 61 6e 69 66 65 73 74 27 2c 27 6d 61 6e 69 66  manifest','manif
11d0: 65 73 74 2e 75 75 69 64 27 2c 27 5f 46 4f 53 53  est.uuid','_FOSS
11e0: 49 4c 5f 27 29 22 0a 20 20 20 20 20 20 22 20 4f  IL_')".      " O
11f0: 52 44 45 52 20 42 59 20 31 22 29 3b 0a 20 20 77  RDER BY 1");.  w
1200: 68 69 6c 65 28 20 64 62 5f 73 74 65 70 28 26 71  hile( db_step(&q
1210: 29 3d 3d 53 51 4c 49 54 45 5f 52 4f 57 20 29 7b  )==SQLITE_ROW ){
1220: 0a 20 20 20 20 70 72 69 6e 74 66 28 22 25 73 5c  .    printf("%s\
1230: 6e 22 2c 20 64 62 5f 63 6f 6c 75 6d 6e 5f 74 65  n", db_column_te
1240: 78 74 28 26 71 2c 20 30 29 29 3b 0a 20 20 7d 0a  xt(&q, 0));.  }.
1250: 20 20 64 62 5f 66 69 6e 61 6c 69 7a 65 28 26 71    db_finalize(&q
1260: 29 3b 0a 7d 0a 0a 2f 2a 0a 2a 2a 20 43 4f 4d 4d  );.}../*.** COMM
1270: 41 4e 44 3a 20 63 6c 65 61 6e 0a 2a 2a 20 55 73  AND: clean.** Us
1280: 61 67 65 3a 20 25 66 6f 73 73 69 6c 20 63 6c 65  age: %fossil cle
1290: 61 6e 20 3f 2d 61 6c 6c 0a 2a 2a 20 44 65 6c 65  an ?-all.** Dele
12a0: 74 65 20 61 6c 6c 20 22 65 78 74 72 61 22 20 66  te all "extra" f
12b0: 69 6c 65 73 20 69 6e 20 74 68 65 20 73 6f 75 72  iles in the sour
12c0: 63 65 20 74 72 65 65 2e 20 20 22 45 78 74 72 61  ce tree.  "Extra
12d0: 22 20 66 69 6c 65 73 20 61 72 65 0a 2a 2a 20 66  " files are.** f
12e0: 69 6c 65 73 20 74 68 61 74 20 61 72 65 20 6e 6f  iles that are no
12f0: 74 20 6f 66 66 69 63 69 61 6c 6c 79 20 70 61 72  t officially par
1300: 74 20 6f 66 20 74 68 65 20 63 68 65 63 6b 6f 75  t of the checkou
1310: 74 2e 20 20 53 65 65 20 61 6c 73 6f 0a 2a 2a 20  t.  See also.** 
1320: 74 68 65 20 22 65 78 74 72 61 22 20 63 6f 6d 6d  the "extra" comm
1330: 61 6e 64 2e 20 54 68 69 73 20 6f 70 65 72 61 74  and. This operat
1340: 69 6f 6e 20 63 61 6e 6e 6f 74 20 62 65 20 75 6e  ion cannot be un
1350: 64 6f 6e 65 2e 20 0a 2a 2a 0a 2a 2a 20 59 6f 75  done. .**.** You
1360: 20 77 69 6c 6c 20 62 65 20 70 72 6f 6d 70 74 65   will be prompte
1370: 64 20 62 65 66 6f 72 65 20 72 65 6d 6f 76 69 6e  d before removin
1380: 67 20 65 61 63 68 20 66 69 6c 65 2e 20 49 66 20  g each file. If 
1390: 79 6f 75 20 61 72 65 0a 2a 2a 20 73 75 72 65 20  you are.** sure 
13a0: 79 6f 75 20 77 69 73 68 20 74 6f 20 72 65 6d 6f  you wish to remo
13b0: 76 65 20 61 6c 6c 20 22 65 78 74 72 61 22 20 66  ve all "extra" f
13c0: 69 6c 65 73 20 79 6f 75 20 63 61 6e 20 73 70 65  iles you can spe
13d0: 63 69 66 79 20 74 68 65 0a 2a 2a 20 6f 70 74 69  cify the.** opti
13e0: 6f 6e 61 6c 20 2d 61 6c 6c 20 66 6c 61 67 2e 0a  onal -all flag..
13f0: 2a 2f 0a 76 6f 69 64 20 63 6c 65 61 6e 5f 63 6d  */.void clean_cm
1400: 64 28 76 6f 69 64 29 7b 0a 20 20 69 6e 74 20 61  d(void){.  int a
1410: 6c 6c 46 6c 61 67 3b 0a 20 20 42 6c 6f 62 20 70  llFlag;.  Blob p
1420: 61 74 68 3b 0a 20 20 53 74 6d 74 20 71 3b 0a 20  ath;.  Stmt q;. 
1430: 20 61 6c 6c 46 6c 61 67 20 3d 20 66 69 6e 64 5f   allFlag = find_
1440: 6f 70 74 69 6f 6e 28 22 61 6c 6c 22 2c 22 61 22  option("all","a"
1450: 2c 30 29 21 3d 30 3b 0a 20 20 64 62 5f 6d 75 73  ,0)!=0;.  db_mus
1460: 74 5f 62 65 5f 77 69 74 68 69 6e 5f 74 72 65 65  t_be_within_tree
1470: 28 29 3b 0a 20 20 64 62 5f 6d 75 6c 74 69 5f 65  ();.  db_multi_e
1480: 78 65 63 28 22 43 52 45 41 54 45 20 54 45 4d 50  xec("CREATE TEMP
1490: 20 54 41 42 4c 45 20 73 66 69 6c 65 28 78 20 54   TABLE sfile(x T
14a0: 45 58 54 20 50 52 49 4d 41 52 59 20 4b 45 59 29  EXT PRIMARY KEY)
14b0: 22 29 3b 0a 20 20 63 68 64 69 72 28 67 2e 7a 4c  ");.  chdir(g.zL
14c0: 6f 63 61 6c 52 6f 6f 74 29 3b 0a 20 20 62 6c 6f  ocalRoot);.  blo
14d0: 62 5f 7a 65 72 6f 28 26 70 61 74 68 29 3b 0a 20  b_zero(&path);. 
14e0: 20 76 66 69 6c 65 5f 73 63 61 6e 28 30 2c 20 26   vfile_scan(0, &
14f0: 70 61 74 68 29 3b 0a 20 20 64 62 5f 70 72 65 70  path);.  db_prep
1500: 61 72 65 28 26 71 2c 20 0a 20 20 20 20 20 20 22  are(&q, .      "
1510: 53 45 4c 45 43 54 20 25 51 20 7c 7c 20 78 20 46  SELECT %Q || x F
1520: 52 4f 4d 20 73 66 69 6c 65 22 0a 20 20 20 20 20  ROM sfile".     
1530: 20 22 20 57 48 45 52 45 20 78 20 4e 4f 54 20 49   " WHERE x NOT I
1540: 4e 20 28 27 6d 61 6e 69 66 65 73 74 27 2c 27 6d  N ('manifest','m
1550: 61 6e 69 66 65 73 74 2e 75 75 69 64 27 2c 27 5f  anifest.uuid','_
1560: 46 4f 53 53 49 4c 5f 27 29 22 0a 20 20 20 20 20  FOSSIL_')".     
1570: 20 22 20 4f 52 44 45 52 20 42 59 20 31 22 2c 20   " ORDER BY 1", 
1580: 67 2e 7a 4c 6f 63 61 6c 52 6f 6f 74 29 3b 0a 20  g.zLocalRoot);. 
1590: 20 77 68 69 6c 65 28 20 64 62 5f 73 74 65 70 28   while( db_step(
15a0: 26 71 29 3d 3d 53 51 4c 49 54 45 5f 52 4f 57 20  &q)==SQLITE_ROW 
15b0: 29 7b 0a 20 20 20 20 69 66 28 20 61 6c 6c 46 6c  ){.    if( allFl
15c0: 61 67 20 29 7b 0a 20 20 20 20 20 20 75 6e 6c 69  ag ){.      unli
15d0: 6e 6b 28 64 62 5f 63 6f 6c 75 6d 6e 5f 74 65 78  nk(db_column_tex
15e0: 74 28 26 71 2c 20 30 29 29 3b 0a 20 20 20 20 7d  t(&q, 0));.    }
15f0: 65 6c 73 65 7b 0a 20 20 20 20 20 20 42 6c 6f 62  else{.      Blob
1600: 20 61 6e 73 3b 0a 20 20 20 20 20 20 63 68 61 72   ans;.      char
1610: 20 2a 70 72 6f 6d 70 74 20 3d 20 6d 70 72 69 6e   *prompt = mprin
1620: 74 66 28 22 72 65 6d 6f 76 65 20 75 6e 6d 61 6e  tf("remove unman
1630: 61 67 65 64 20 66 69 6c 65 20 5c 22 25 73 5c 22  aged file \"%s\"
1640: 20 5b 79 2f 4e 5d 3f 20 22 2c 0a 20 20 20 20 20   [y/N]? ",.     
1650: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1660: 20 20 20 20 20 20 20 20 20 64 62 5f 63 6f 6c 75           db_colu
1670: 6d 6e 5f 74 65 78 74 28 26 71 2c 20 30 29 29 3b  mn_text(&q, 0));
1680: 0a 20 20 20 20 20 20 62 6c 6f 62 5f 7a 65 72 6f  .      blob_zero
1690: 28 26 61 6e 73 29 3b 0a 20 20 20 20 20 20 70 72  (&ans);.      pr
16a0: 6f 6d 70 74 5f 75 73 65 72 28 70 72 6f 6d 70 74  ompt_user(prompt
16b0: 2c 20 26 61 6e 73 29 3b 0a 20 20 20 20 20 20 69  , &ans);.      i
16c0: 66 28 20 62 6c 6f 62 5f 73 74 72 28 26 61 6e 73  f( blob_str(&ans
16d0: 29 5b 30 5d 3d 3d 27 79 27 20 29 7b 0a 20 20 20  )[0]=='y' ){.   
16e0: 20 20 20 20 20 75 6e 6c 69 6e 6b 28 64 62 5f 63       unlink(db_c
16f0: 6f 6c 75 6d 6e 5f 74 65 78 74 28 26 71 2c 20 30  olumn_text(&q, 0
1700: 29 29 3b 0a 20 20 20 20 20 20 7d 0a 20 20 20 20  ));.      }.    
1710: 7d 0a 20 20 7d 0a 20 20 64 62 5f 66 69 6e 61 6c  }.  }.  db_final
1720: 69 7a 65 28 26 71 29 3b 0a 7d 0a 0a 2f 2a 0a 2a  ize(&q);.}../*.*
1730: 2a 20 50 72 65 70 61 72 65 20 61 20 63 6f 6d 6d  * Prepare a comm
1740: 69 74 20 63 6f 6d 6d 65 6e 74 2e 20 20 4c 65 74  it comment.  Let
1750: 20 74 68 65 20 75 73 65 72 20 6d 6f 64 69 66 79   the user modify
1760: 20 69 74 20 75 73 69 6e 67 20 74 68 65 0a 2a 2a   it using the.**
1770: 20 65 64 69 74 6f 72 20 73 70 65 63 69 66 69 65   editor specifie
1780: 64 20 69 6e 20 74 68 65 20 67 6c 6f 62 61 6c 5f  d in the global_
1790: 63 6f 6e 66 69 67 20 74 61 62 6c 65 20 6f 72 20  config table or 
17a0: 65 69 74 68 65 72 0a 2a 2a 20 74 68 65 20 56 49  either.** the VI
17b0: 53 55 41 4c 20 6f 72 20 45 44 49 54 4f 52 20 65  SUAL or EDITOR e
17c0: 6e 76 69 72 6f 6e 6d 65 6e 74 20 76 61 72 69 61  nvironment varia
17d0: 62 6c 65 2e 0a 2a 2a 0a 2a 2a 20 53 74 6f 72 65  ble..**.** Store
17e0: 20 74 68 65 20 66 69 6e 61 6c 20 63 6f 6d 6d 69   the final commi
17f0: 74 20 63 6f 6d 6d 65 6e 74 20 69 6e 20 70 43 6f  t comment in pCo
1800: 6d 6d 65 6e 74 2e 20 20 70 43 6f 6d 6d 65 6e 74  mment.  pComment
1810: 20 69 73 20 61 73 73 75 6d 65 64 0a 2a 2a 20 74   is assumed.** t
1820: 6f 20 62 65 20 75 6e 69 6e 69 74 69 61 6c 69 7a  o be uninitializ
1830: 65 64 20 2d 20 61 6e 79 20 70 72 69 6f 72 20 63  ed - any prior c
1840: 6f 6e 74 65 6e 74 20 69 73 20 6f 76 65 72 77 72  ontent is overwr
1850: 69 74 74 65 6e 2e 0a 2a 2f 0a 73 74 61 74 69 63  itten..*/.static
1860: 20 76 6f 69 64 20 70 72 65 70 61 72 65 5f 63 6f   void prepare_co
1870: 6d 6d 69 74 5f 63 6f 6d 6d 65 6e 74 28 42 6c 6f  mmit_comment(Blo
1880: 62 20 2a 70 43 6f 6d 6d 65 6e 74 29 7b 0a 20 20  b *pComment){.  
1890: 63 6f 6e 73 74 20 63 68 61 72 20 2a 7a 45 64 69  const char *zEdi
18a0: 74 6f 72 3b 0a 20 20 63 68 61 72 20 2a 7a 43 6d  tor;.  char *zCm
18b0: 64 3b 0a 20 20 63 68 61 72 20 2a 7a 46 69 6c 65  d;.  char *zFile
18c0: 3b 0a 20 20 42 6c 6f 62 20 74 65 78 74 2c 20 6c  ;.  Blob text, l
18d0: 69 6e 65 3b 0a 20 20 63 68 61 72 20 2a 7a 43 6f  ine;.  char *zCo
18e0: 6d 6d 65 6e 74 3b 0a 20 20 69 6e 74 20 69 3b 0a  mment;.  int i;.
18f0: 20 20 62 6c 6f 62 5f 73 65 74 28 26 74 65 78 74    blob_set(&text
1900: 2c 0a 20 20 20 20 22 5c 6e 23 20 45 6e 74 65 72  ,.    "\n# Enter
1910: 20 63 6f 6d 6d 65 6e 74 73 20 6f 6e 20 74 68 69   comments on thi
1920: 73 20 63 6f 6d 6d 69 74 2e 20 20 4c 69 6e 65 73  s commit.  Lines
1930: 20 62 65 67 69 6e 6e 69 6e 67 20 77 69 74 68 20   beginning with 
1940: 23 20 61 72 65 20 69 67 6e 6f 72 65 64 5c 6e 22  # are ignored\n"
1950: 0a 20 20 20 20 22 23 5c 6e 22 0a 20 20 29 3b 0a  .    "#\n".  );.
1960: 20 20 73 74 61 74 75 73 5f 72 65 70 6f 72 74 28    status_report(
1970: 26 74 65 78 74 2c 20 22 23 20 22 29 3b 0a 20 20  &text, "# ");.  
1980: 7a 45 64 69 74 6f 72 20 3d 20 64 62 5f 67 6c 6f  zEditor = db_glo
1990: 62 61 6c 5f 67 65 74 28 22 65 64 69 74 6f 72 22  bal_get("editor"
19a0: 2c 20 30 29 3b 0a 20 20 69 66 28 20 7a 45 64 69  , 0);.  if( zEdi
19b0: 74 6f 72 3d 3d 30 20 29 7b 0a 20 20 20 20 7a 45  tor==0 ){.    zE
19c0: 64 69 74 6f 72 20 3d 20 67 65 74 65 6e 76 28 22  ditor = getenv("
19d0: 56 49 53 55 41 4c 22 29 3b 0a 20 20 7d 0a 20 20  VISUAL");.  }.  
19e0: 69 66 28 20 7a 45 64 69 74 6f 72 3d 3d 30 20 29  if( zEditor==0 )
19f0: 7b 0a 20 20 20 20 7a 45 64 69 74 6f 72 20 3d 20  {.    zEditor = 
1a00: 67 65 74 65 6e 76 28 22 45 44 49 54 4f 52 22 29  getenv("EDITOR")
1a10: 3b 0a 20 20 7d 0a 20 20 69 66 28 20 7a 45 64 69  ;.  }.  if( zEdi
1a20: 74 6f 72 3d 3d 30 20 29 7b 0a 20 20 20 20 7a 45  tor==0 ){.    zE
1a30: 64 69 74 6f 72 20 3d 20 22 65 64 22 3b 0a 20 20  ditor = "ed";.  
1a40: 7d 0a 20 20 7a 46 69 6c 65 20 3d 20 64 62 5f 74  }.  zFile = db_t
1a50: 65 78 74 28 30 2c 20 22 53 45 4c 45 43 54 20 27  ext(0, "SELECT '
1a60: 25 71 63 69 2d 63 6f 6d 6d 65 6e 74 2d 27 20 7c  %qci-comment-' |
1a70: 7c 20 68 65 78 28 72 61 6e 64 6f 6d 62 6c 6f 62  | hex(randomblob
1a80: 28 36 29 29 20 7c 7c 20 27 2e 74 78 74 27 22 2c  (6)) || '.txt'",
1a90: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  .               
1aa0: 20 20 20 20 67 2e 7a 4c 6f 63 61 6c 52 6f 6f 74      g.zLocalRoot
1ab0: 29 3b 0a 20 20 62 6c 6f 62 5f 77 72 69 74 65 5f  );.  blob_write_
1ac0: 74 6f 5f 66 69 6c 65 28 26 74 65 78 74 2c 20 7a  to_file(&text, z
1ad0: 46 69 6c 65 29 3b 0a 20 20 7a 43 6d 64 20 3d 20  File);.  zCmd = 
1ae0: 6d 70 72 69 6e 74 66 28 22 25 73 20 5c 22 25 73  mprintf("%s \"%s
1af0: 5c 22 22 2c 20 7a 45 64 69 74 6f 72 2c 20 7a 46  \"", zEditor, zF
1b00: 69 6c 65 29 3b 0a 20 20 70 72 69 6e 74 66 28 22  ile);.  printf("
1b10: 25 73 5c 6e 22 2c 20 7a 43 6d 64 29 3b 0a 20 20  %s\n", zCmd);.  
1b20: 69 66 28 20 73 79 73 74 65 6d 28 7a 43 6d 64 29  if( system(zCmd)
1b30: 20 29 7b 0a 20 20 20 20 66 6f 73 73 69 6c 5f 70   ){.    fossil_p
1b40: 61 6e 69 63 28 22 65 64 69 74 6f 72 20 61 62 6f  anic("editor abo
1b50: 72 74 65 64 22 29 3b 0a 20 20 7d 0a 20 20 62 6c  rted");.  }.  bl
1b60: 6f 62 5f 72 65 73 65 74 28 26 74 65 78 74 29 3b  ob_reset(&text);
1b70: 0a 20 20 62 6c 6f 62 5f 72 65 61 64 5f 66 72 6f  .  blob_read_fro
1b80: 6d 5f 66 69 6c 65 28 26 74 65 78 74 2c 20 7a 46  m_file(&text, zF
1b90: 69 6c 65 29 3b 0a 20 20 75 6e 6c 69 6e 6b 28 7a  ile);.  unlink(z
1ba0: 46 69 6c 65 29 3b 0a 20 20 66 72 65 65 28 7a 46  File);.  free(zF
1bb0: 69 6c 65 29 3b 0a 20 20 62 6c 6f 62 5f 7a 65 72  ile);.  blob_zer
1bc0: 6f 28 70 43 6f 6d 6d 65 6e 74 29 3b 0a 20 20 77  o(pComment);.  w
1bd0: 68 69 6c 65 28 20 62 6c 6f 62 5f 6c 69 6e 65 28  hile( blob_line(
1be0: 26 74 65 78 74 2c 20 26 6c 69 6e 65 29 20 29 7b  &text, &line) ){
1bf0: 0a 20 20 20 20 69 6e 74 20 69 2c 20 6e 3b 0a 20  .    int i, n;. 
1c00: 20 20 20 63 68 61 72 20 2a 7a 3b 0a 20 20 20 20     char *z;.    
1c10: 6e 20 3d 20 62 6c 6f 62 5f 73 69 7a 65 28 26 6c  n = blob_size(&l
1c20: 69 6e 65 29 3b 0a 20 20 20 20 7a 20 3d 20 62 6c  ine);.    z = bl
1c30: 6f 62 5f 62 75 66 66 65 72 28 26 6c 69 6e 65 29  ob_buffer(&line)
1c40: 3b 0a 20 20 20 20 66 6f 72 28 69 3d 30 3b 20 69  ;.    for(i=0; i
1c50: 3c 6e 20 26 26 20 69 73 73 70 61 63 65 28 7a 5b  <n && isspace(z[
1c60: 69 5d 29 3b 20 20 69 2b 2b 29 7b 7d 0a 20 20 20  i]);  i++){}.   
1c70: 20 69 66 28 20 69 3c 6e 20 26 26 20 7a 5b 69 5d   if( i<n && z[i]
1c80: 3d 3d 27 23 27 20 29 20 63 6f 6e 74 69 6e 75 65  =='#' ) continue
1c90: 3b 0a 20 20 20 20 69 66 28 20 69 3c 6e 20 7c 7c  ;.    if( i<n ||
1ca0: 20 62 6c 6f 62 5f 73 69 7a 65 28 70 43 6f 6d 6d   blob_size(pComm
1cb0: 65 6e 74 29 3e 30 20 29 7b 0a 20 20 20 20 20 20  ent)>0 ){.      
1cc0: 62 6c 6f 62 5f 61 70 70 65 6e 64 66 28 70 43 6f  blob_appendf(pCo
1cd0: 6d 6d 65 6e 74 2c 20 22 25 62 22 2c 20 26 6c 69  mment, "%b", &li
1ce0: 6e 65 29 3b 0a 20 20 20 20 7d 0a 20 20 7d 0a 20  ne);.    }.  }. 
1cf0: 20 62 6c 6f 62 5f 72 65 73 65 74 28 26 74 65 78   blob_reset(&tex
1d00: 74 29 3b 0a 20 20 7a 43 6f 6d 6d 65 6e 74 20 3d  t);.  zComment =
1d10: 20 62 6c 6f 62 5f 73 74 72 28 70 43 6f 6d 6d 65   blob_str(pComme
1d20: 6e 74 29 3b 0a 20 20 69 20 3d 20 73 74 72 6c 65  nt);.  i = strle
1d30: 6e 28 7a 43 6f 6d 6d 65 6e 74 29 3b 0a 20 20 77  n(zComment);.  w
1d40: 68 69 6c 65 28 20 69 3e 30 20 26 26 20 69 73 73  hile( i>0 && iss
1d50: 70 61 63 65 28 7a 43 6f 6d 6d 65 6e 74 5b 69 2d  pace(zComment[i-
1d60: 31 5d 29 20 29 7b 20 69 2d 2d 3b 20 7d 0a 20 20  1]) ){ i--; }.  
1d70: 62 6c 6f 62 5f 72 65 73 69 7a 65 28 70 43 6f 6d  blob_resize(pCom
1d80: 6d 65 6e 74 2c 20 69 29 3b 0a 7d 0a 0a 2f 2a 0a  ment, i);.}../*.
1d90: 2a 2a 20 50 6f 70 75 6c 61 74 65 20 74 68 65 20  ** Populate the 
1da0: 47 6c 6f 62 61 6c 2e 61 43 6f 6d 6d 69 74 46 69  Global.aCommitFi
1db0: 6c 65 5b 5d 20 62 61 73 65 64 20 6f 6e 20 74 68  le[] based on th
1dc0: 65 20 63 6f 6d 6d 61 6e 64 20 6c 69 6e 65 20 61  e command line a
1dd0: 72 67 75 6d 65 6e 74 73 0a 2a 2a 20 74 6f 20 61  rguments.** to a
1de0: 20 5b 63 6f 6d 6d 69 74 5d 20 63 6f 6d 6d 61 6e   [commit] comman
1df0: 64 2e 20 47 6c 6f 62 61 6c 2e 61 43 6f 6d 6d 69  d. Global.aCommi
1e00: 74 46 69 6c 65 20 69 73 20 61 6e 20 61 72 72 61  tFile is an arra
1e10: 79 20 6f 66 20 69 6e 74 65 67 65 72 73 0a 2a 2a  y of integers.**
1e20: 20 73 69 7a 65 64 20 61 74 20 28 4e 2b 31 29 2c   sized at (N+1),
1e30: 20 77 68 65 72 65 20 4e 20 69 73 20 74 68 65 20   where N is the 
1e40: 6e 75 6d 62 65 72 20 6f 66 20 61 72 67 75 6d 65  number of argume
1e50: 6e 74 73 20 70 61 73 73 65 64 20 74 6f 20 5b 63  nts passed to [c
1e60: 6f 6d 6d 69 74 5d 2e 0a 2a 2a 20 54 68 65 20 63  ommit]..** The c
1e70: 6f 6e 74 65 6e 74 73 20 61 72 65 20 74 68 65 20  ontents are the 
1e80: 5b 69 64 5d 20 76 61 6c 75 65 73 20 66 72 6f 6d  [id] values from
1e90: 20 74 68 65 20 76 66 69 6c 65 20 74 61 62 6c 65   the vfile table
1ea0: 20 63 6f 72 72 65 73 70 6f 6e 64 69 6e 67 0a 2a   corresponding.*
1eb0: 2a 20 74 6f 20 74 68 65 20 66 69 6c 65 6e 61 6d  * to the filenam
1ec0: 65 73 20 70 61 73 73 65 64 20 61 73 20 61 72 67  es passed as arg
1ed0: 75 6d 65 6e 74 73 2e 0a 2a 2a 0a 2a 2a 20 54 68  uments..**.** Th
1ee0: 65 20 6c 61 73 74 20 65 6c 65 6d 65 6e 74 20 6f  e last element o
1ef0: 66 20 61 43 6f 6d 6d 69 74 46 69 6c 65 5b 5d 20  f aCommitFile[] 
1f00: 69 73 20 61 6c 77 61 79 73 20 30 20 2d 20 69 6e  is always 0 - in
1f10: 64 69 63 61 74 69 6e 67 20 74 68 65 20 65 6e 64  dicating the end
1f20: 0a 2a 2a 20 6f 66 20 74 68 65 20 61 72 72 61 79  .** of the array
1f30: 2e 0a 2a 2a 0a 2a 2a 20 49 66 20 74 68 65 72 65  ..**.** If there
1f40: 20 77 65 72 65 20 6e 6f 20 61 72 67 75 6d 65 6e   were no argumen
1f50: 74 73 20 70 61 73 73 65 64 20 74 6f 20 5b 63 6f  ts passed to [co
1f60: 6d 6d 69 74 5d 2c 20 61 43 6f 6d 6d 69 74 46 69  mmit], aCommitFi
1f70: 6c 65 20 69 73 20 6e 6f 74 0a 2a 2a 20 61 6c 6c  le is not.** all
1f80: 6f 63 61 74 65 64 20 61 6e 64 20 72 65 6d 61 69  ocated and remai
1f90: 6e 73 20 4e 55 4c 4c 2e 20 4f 74 68 65 72 20 70  ns NULL. Other p
1fa0: 61 72 74 73 20 6f 66 20 74 68 65 20 63 6f 64 65  arts of the code
1fb0: 20 69 6e 74 65 72 70 72 65 74 20 74 68 69 73 0a   interpret this.
1fc0: 2a 2a 20 74 6f 20 6d 65 61 6e 20 22 61 6c 6c 20  ** to mean "all 
1fd0: 66 69 6c 65 73 22 2e 0a 2a 2f 0a 76 6f 69 64 20  files"..*/.void 
1fe0: 73 65 6c 65 63 74 5f 63 6f 6d 6d 69 74 5f 66 69  select_commit_fi
1ff0: 6c 65 73 28 76 6f 69 64 29 7b 0a 20 20 69 66 28  les(void){.  if(
2000: 20 67 2e 61 72 67 63 3e 32 20 29 7b 0a 20 20 20   g.argc>2 ){.   
2010: 20 69 6e 74 20 69 69 3b 0a 20 20 20 20 42 6c 6f   int ii;.    Blo
2020: 62 20 62 3b 0a 20 20 20 20 62 6c 6f 62 5f 7a 65  b b;.    blob_ze
2030: 72 6f 28 26 62 29 3b 0a 20 20 20 20 67 2e 61 43  ro(&b);.    g.aC
2040: 6f 6d 6d 69 74 46 69 6c 65 20 3d 20 6d 61 6c 6c  ommitFile = mall
2050: 6f 63 28 73 69 7a 65 6f 66 28 69 6e 74 29 2a 28  oc(sizeof(int)*(
2060: 67 2e 61 72 67 63 2d 31 29 29 3b 0a 0a 20 20 20  g.argc-1));..   
2070: 20 66 6f 72 28 69 69 3d 32 3b 20 69 69 3c 67 2e   for(ii=2; ii<g.
2080: 61 72 67 63 3b 20 69 69 2b 2b 29 7b 0a 20 20 20  argc; ii++){.   
2090: 20 20 20 69 6e 74 20 69 49 64 3b 0a 20 20 20 20     int iId;.    
20a0: 20 20 69 66 28 20 21 66 69 6c 65 5f 74 72 65 65    if( !file_tree
20b0: 5f 6e 61 6d 65 28 67 2e 61 72 67 76 5b 69 69 5d  _name(g.argv[ii]
20c0: 2c 20 26 62 29 20 29 7b 0a 20 20 20 20 20 20 20  , &b) ){.       
20d0: 20 66 6f 73 73 69 6c 5f 66 61 74 61 6c 28 22 66   fossil_fatal("f
20e0: 69 6c 65 20 69 73 20 6e 6f 74 20 69 6e 20 74 72  ile is not in tr
20f0: 65 65 3a 20 25 73 22 2c 20 67 2e 61 72 67 76 5b  ee: %s", g.argv[
2100: 69 69 5d 29 3b 0a 20 20 20 20 20 20 7d 0a 20 20  ii]);.      }.  
2110: 20 20 20 20 69 49 64 20 3d 20 64 62 5f 69 6e 74      iId = db_int
2120: 28 2d 31 2c 20 22 53 45 4c 45 43 54 20 69 64 20  (-1, "SELECT id 
2130: 46 52 4f 4d 20 76 66 69 6c 65 20 57 48 45 52 45  FROM vfile WHERE
2140: 20 70 61 74 68 6e 61 6d 65 3d 25 51 22 2c 20 62   pathname=%Q", b
2150: 6c 6f 62 5f 73 74 72 28 26 62 29 29 3b 0a 20 20  lob_str(&b));.  
2160: 20 20 20 20 69 66 28 20 69 49 64 3c 30 20 29 7b      if( iId<0 ){
2170: 0a 20 20 20 20 20 20 20 20 66 6f 73 73 69 6c 5f  .        fossil_
2180: 66 61 74 61 6c 28 22 66 6f 73 73 69 6c 20 6b 6e  fatal("fossil kn
2190: 6f 77 73 20 6e 6f 74 68 69 6e 67 20 61 62 6f 75  ows nothing abou
21a0: 74 3a 20 25 73 22 2c 20 67 2e 61 72 67 76 5b 69  t: %s", g.argv[i
21b0: 69 5d 29 3b 0a 20 20 20 20 20 20 7d 0a 20 20 20  i]);.      }.   
21c0: 20 20 20 67 2e 61 43 6f 6d 6d 69 74 46 69 6c 65     g.aCommitFile
21d0: 5b 69 69 2d 32 5d 20 3d 20 69 49 64 3b 0a 20 20  [ii-2] = iId;.  
21e0: 20 20 20 20 62 6c 6f 62 5f 72 65 73 65 74 28 26      blob_reset(&
21f0: 62 29 3b 0a 20 20 20 20 7d 0a 20 20 20 20 67 2e  b);.    }.    g.
2200: 61 43 6f 6d 6d 69 74 46 69 6c 65 5b 69 69 2d 32  aCommitFile[ii-2
2210: 5d 20 3d 20 30 3b 0a 20 20 7d 0a 7d 0a 0a 2f 2a  ] = 0;.  }.}../*
2220: 0a 2a 2a 20 43 4f 4d 4d 41 4e 44 3a 20 63 6f 6d  .** COMMAND: com
2230: 6d 69 74 0a 2a 2a 0a 2a 2a 20 55 73 61 67 65 3a  mit.**.** Usage:
2240: 20 25 66 6f 73 73 69 6c 20 63 6f 6d 6d 69 74 20   %fossil commit 
2250: 3f 2d 6d 20 43 4f 4d 4d 45 4e 54 3f 20 3f 2d 2d  ?-m COMMENT? ?--
2260: 6e 6f 73 69 67 6e 3f 20 3f 46 49 4c 45 2e 2e 2e  nosign? ?FILE...
2270: 3f 0a 2a 2a 0a 2a 2a 20 43 72 65 61 74 65 20 61  ?.**.** Create a
2280: 20 6e 65 77 20 76 65 72 73 69 6f 6e 20 63 6f 6e   new version con
2290: 74 61 69 6e 69 6e 67 20 61 6c 6c 20 6f 66 20 74  taining all of t
22a0: 68 65 20 63 68 61 6e 67 65 73 20 69 6e 20 74 68  he changes in th
22b0: 65 20 63 75 72 72 65 6e 74 0a 2a 2a 20 63 68 65  e current.** che
22c0: 63 6b 6f 75 74 2e 20 20 59 6f 75 20 77 69 6c 6c  ckout.  You will
22d0: 20 62 65 20 70 72 6f 6d 70 74 65 64 20 74 6f 20   be prompted to 
22e0: 65 6e 74 65 72 20 61 20 63 68 65 63 6b 2d 69 6e  enter a check-in
22f0: 20 63 6f 6d 6d 65 6e 74 20 75 6e 6c 65 73 73 0a   comment unless.
2300: 2a 2a 20 74 68 65 20 22 2d 6d 22 20 6f 70 74 69  ** the "-m" opti
2310: 6f 6e 20 69 73 20 75 73 65 64 20 74 6f 20 73 70  on is used to sp
2320: 65 63 69 66 79 20 61 20 63 6f 6d 6d 61 6e 64 20  ecify a command 
2330: 6c 69 6e 65 2e 20 20 59 6f 75 20 77 69 6c 6c 20  line.  You will 
2340: 62 65 0a 2a 2a 20 70 72 6f 6d 70 74 65 64 20 66  be.** prompted f
2350: 6f 72 20 79 6f 75 72 20 47 50 47 20 70 61 73 73  or your GPG pass
2360: 70 68 72 61 73 65 20 69 6e 20 6f 72 64 65 72 20  phrase in order 
2370: 74 6f 20 73 69 67 6e 20 74 68 65 20 6e 65 77 20  to sign the new 
2380: 6d 61 6e 69 66 65 73 74 0a 2a 2a 20 75 6e 6c 65  manifest.** unle
2390: 73 73 20 74 68 65 20 22 2d 2d 6e 6f 73 69 67 6e  ss the "--nosign
23a0: 22 20 6f 70 74 69 6f 6e 73 20 69 73 20 75 73 65  " options is use
23b0: 64 2e 20 20 41 6c 6c 20 66 69 6c 65 73 20 74 68  d.  All files th
23c0: 61 74 20 68 61 76 65 0a 2a 2a 20 63 68 61 6e 67  at have.** chang
23d0: 65 64 20 77 69 6c 6c 20 62 65 20 63 6f 6d 6d 69  ed will be commi
23e0: 74 74 65 64 20 75 6e 6c 65 73 73 20 73 6f 6d 65  tted unless some
23f0: 20 73 75 62 73 65 74 20 6f 66 20 66 69 6c 65 73   subset of files
2400: 20 69 73 20 73 70 65 63 69 66 69 65 64 0a 2a 2a   is specified.**
2410: 20 6f 6e 20 74 68 65 20 63 6f 6d 6d 61 6e 64 20   on the command 
2420: 6c 69 6e 65 2e 0a 2a 2f 0a 76 6f 69 64 20 63 6f  line..*/.void co
2430: 6d 6d 69 74 5f 63 6d 64 28 76 6f 69 64 29 7b 0a  mmit_cmd(void){.
2440: 20 20 69 6e 74 20 72 63 3b 0a 20 20 69 6e 74 20    int rc;.  int 
2450: 76 69 64 2c 20 6e 72 69 64 2c 20 6e 76 69 64 3b  vid, nrid, nvid;
2460: 0a 20 20 42 6c 6f 62 20 63 6f 6d 6d 65 6e 74 3b  .  Blob comment;
2470: 0a 20 20 63 6f 6e 73 74 20 63 68 61 72 20 2a 7a  .  const char *z
2480: 43 6f 6d 6d 65 6e 74 3b 0a 20 20 53 74 6d 74 20  Comment;.  Stmt 
2490: 71 3b 0a 20 20 53 74 6d 74 20 71 32 3b 0a 20 20  q;.  Stmt q2;.  
24a0: 63 68 61 72 20 2a 7a 55 75 69 64 2c 20 2a 7a 44  char *zUuid, *zD
24b0: 61 74 65 3b 0a 20 20 69 6e 74 20 6e 6f 53 69 67  ate;.  int noSig
24c0: 6e 20 3d 20 30 3b 20 20 20 20 20 20 20 20 2f 2a  n = 0;        /*
24d0: 20 54 72 75 65 20 74 6f 20 6f 6d 69 74 20 73 69   True to omit si
24e0: 67 6e 69 6e 67 20 74 68 65 20 6d 61 6e 69 66 65  gning the manife
24f0: 73 74 20 75 73 69 6e 67 20 47 50 47 20 2a 2f 0a  st using GPG */.
2500: 20 20 69 6e 74 20 69 73 41 4d 65 72 67 65 20 3d    int isAMerge =
2510: 20 30 3b 20 20 20 20 20 20 2f 2a 20 54 72 75 65   0;      /* True
2520: 20 69 66 20 63 68 65 63 6b 69 6e 67 20 69 6e 20   if checking in 
2530: 61 20 6d 65 72 67 65 20 2a 2f 0a 20 20 63 68 61  a merge */.  cha
2540: 72 20 2a 7a 4d 61 6e 69 66 65 73 74 46 69 6c 65  r *zManifestFile
2550: 3b 20 20 20 2f 2a 20 4e 61 6d 65 20 6f 66 20 74  ;   /* Name of t
2560: 68 65 20 6d 61 6e 69 66 65 73 74 20 66 69 6c 65  he manifest file
2570: 20 2a 2f 0a 20 20 42 6c 6f 62 20 6d 61 6e 69 66   */.  Blob manif
2580: 65 73 74 3b 0a 20 20 42 6c 6f 62 20 6d 75 75 69  est;.  Blob muui
2590: 64 3b 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a  d;            /*
25a0: 20 4d 61 6e 69 66 65 73 74 20 75 75 69 64 20 2a   Manifest uuid *
25b0: 2f 0a 20 20 42 6c 6f 62 20 6d 63 6b 73 75 6d 3b  /.  Blob mcksum;
25c0: 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 53 65             /* Se
25d0: 6c 66 2d 63 68 65 63 6b 73 75 6d 20 6f 6e 20 74  lf-checksum on t
25e0: 68 65 20 6d 61 6e 69 66 65 73 74 20 2a 2f 0a 20  he manifest */. 
25f0: 20 42 6c 6f 62 20 63 6b 73 75 6d 31 2c 20 63 6b   Blob cksum1, ck
2600: 73 75 6d 32 3b 20 20 20 2f 2a 20 42 65 66 6f 72  sum2;   /* Befor
2610: 65 20 61 6e 64 20 61 66 74 65 72 20 63 6f 6d 6d  e and after comm
2620: 69 74 20 63 68 65 63 6b 73 75 6d 73 20 2a 2f 0a  it checksums */.
2630: 20 20 42 6c 6f 62 20 63 6b 73 75 6d 31 62 3b 20    Blob cksum1b; 
2640: 20 20 20 20 20 20 20 20 20 2f 2a 20 43 68 65 63           /* Chec
2650: 6b 73 75 6d 20 72 65 63 6f 72 64 65 64 20 69 6e  ksum recorded in
2660: 20 74 68 65 20 6d 61 6e 69 66 65 73 74 20 2a 2f   the manifest */
2670: 0a 20 0a 20 20 6e 6f 53 69 67 6e 20 3d 20 66 69  . .  noSign = fi
2680: 6e 64 5f 6f 70 74 69 6f 6e 28 22 6e 6f 73 69 67  nd_option("nosig
2690: 6e 22 2c 22 22 2c 30 29 21 3d 30 3b 0a 20 20 7a  n","",0)!=0;.  z
26a0: 43 6f 6d 6d 65 6e 74 20 3d 20 66 69 6e 64 5f 6f  Comment = find_o
26b0: 70 74 69 6f 6e 28 22 63 6f 6d 6d 65 6e 74 22 2c  ption("comment",
26c0: 22 6d 22 2c 31 29 3b 0a 20 20 64 62 5f 6d 75 73  "m",1);.  db_mus
26d0: 74 5f 62 65 5f 77 69 74 68 69 6e 5f 74 72 65 65  t_be_within_tree
26e0: 28 29 3b 0a 20 20 6e 6f 53 69 67 6e 20 3d 20 64  ();.  noSign = d
26f0: 62 5f 67 65 74 5f 69 6e 74 28 22 6f 6d 69 74 2d  b_get_int("omit-
2700: 63 69 2d 73 69 67 22 2c 20 30 29 7c 6e 6f 53 69  ci-sig", 0)|noSi
2710: 67 6e 3b 0a 20 20 76 65 72 69 66 79 5f 61 6c 6c  gn;.  verify_all
2720: 5f 6f 70 74 69 6f 6e 73 28 29 3b 0a 0a 20 20 2f  _options();..  /
2730: 2a 20 54 68 65 72 65 20 61 72 65 20 74 77 6f 20  * There are two 
2740: 77 61 79 73 20 74 68 69 73 20 63 6f 6d 6d 61 6e  ways this comman
2750: 64 20 6d 61 79 20 62 65 20 65 78 65 63 75 74 65  d may be execute
2760: 64 2e 20 49 66 20 74 68 65 72 65 20 61 72 65 0a  d. If there are.
2770: 20 20 2a 2a 20 6e 6f 20 61 72 67 75 6d 65 6e 74    ** no argument
2780: 73 20 66 6f 6c 6c 6f 77 69 6e 67 20 74 68 65 20  s following the 
2790: 77 6f 72 64 20 22 63 6f 6d 6d 69 74 22 2c 20 74  word "commit", t
27a0: 68 65 6e 20 61 6c 6c 20 6d 6f 64 69 66 69 65 64  hen all modified
27b0: 20 66 69 6c 65 73 0a 20 20 2a 2a 20 69 6e 20 74   files.  ** in t
27c0: 68 65 20 63 68 65 63 6b 65 64 20 6f 75 74 20 64  he checked out d
27d0: 69 72 65 63 74 6f 72 79 20 61 72 65 20 63 6f 6d  irectory are com
27e0: 6d 69 74 74 65 64 2e 20 49 66 20 6f 6e 65 20 6f  mitted. If one o
27f0: 72 20 6d 6f 72 65 20 61 72 67 75 6d 65 6e 74 73  r more arguments
2800: 0a 20 20 2a 2a 20 66 6f 6c 6c 6f 77 73 20 22 63  .  ** follows "c
2810: 6f 6d 6d 69 74 22 2c 20 74 68 65 6e 20 6f 6e 6c  ommit", then onl
2820: 79 20 74 68 6f 73 65 20 66 69 6c 65 73 20 61 72  y those files ar
2830: 65 20 63 6f 6d 6d 69 74 74 65 64 2e 0a 20 20 2a  e committed..  *
2840: 2a 0a 20 20 2a 2a 20 41 66 74 65 72 20 74 68 65  *.  ** After the
2850: 20 66 6f 6c 6c 6f 77 69 6e 67 20 66 75 6e 63 74   following funct
2860: 69 6f 6e 20 63 61 6c 6c 20 68 61 73 20 72 65 74  ion call has ret
2870: 75 72 6e 65 64 2c 20 74 68 65 20 47 6c 6f 62 61  urned, the Globa
2880: 6c 2e 61 43 6f 6d 6d 69 74 46 69 6c 65 5b 5d 0a  l.aCommitFile[].
2890: 20 20 2a 2a 20 61 72 72 61 79 20 69 73 20 61 6c    ** array is al
28a0: 6c 6f 63 61 74 65 64 20 74 6f 20 63 6f 6e 74 61  located to conta
28b0: 69 6e 20 74 68 65 20 22 69 64 22 20 66 69 65 6c  in the "id" fiel
28c0: 64 20 66 72 6f 6d 20 74 68 65 20 76 66 69 6c 65  d from the vfile
28d0: 20 74 61 62 6c 65 0a 20 20 2a 2a 20 66 6f 72 20   table.  ** for 
28e0: 65 61 63 68 20 66 69 6c 65 20 74 6f 20 62 65 20  each file to be 
28f0: 63 6f 6d 6d 69 74 74 65 64 2e 20 4f 72 2c 20 69  committed. Or, i
2900: 66 20 61 43 6f 6d 6d 69 74 46 69 6c 65 20 69 73  f aCommitFile is
2910: 20 4e 55 4c 4c 2c 20 61 6c 6c 20 66 69 6c 65 73   NULL, all files
2920: 0a 20 20 2a 2a 20 73 68 6f 75 6c 64 20 62 65 20  .  ** should be 
2930: 63 6f 6d 6d 69 74 74 65 64 2e 0a 20 20 2a 2f 0a  committed..  */.
2940: 20 20 73 65 6c 65 63 74 5f 63 6f 6d 6d 69 74 5f    select_commit_
2950: 66 69 6c 65 73 28 29 3b 0a 20 20 69 73 41 4d 65  files();.  isAMe
2960: 72 67 65 20 3d 20 64 62 5f 65 78 69 73 74 73 28  rge = db_exists(
2970: 22 53 45 4c 45 43 54 20 31 20 46 52 4f 4d 20 76  "SELECT 1 FROM v
2980: 6d 65 72 67 65 22 29 3b 0a 20 20 69 66 28 20 67  merge");.  if( g
2990: 2e 61 43 6f 6d 6d 69 74 46 69 6c 65 20 26 26 20  .aCommitFile && 
29a0: 69 73 41 4d 65 72 67 65 20 29 7b 0a 20 20 20 20  isAMerge ){.    
29b0: 66 6f 73 73 69 6c 5f 66 61 74 61 6c 28 22 63 61  fossil_fatal("ca
29c0: 6e 6e 6f 74 20 64 6f 20 61 20 70 61 72 74 69 61  nnot do a partia
29d0: 6c 20 63 6f 6d 6d 69 74 20 6f 66 20 61 20 6d 65  l commit of a me
29e0: 72 67 65 22 29 3b 0a 20 20 7d 0a 0a 20 20 75 73  rge");.  }..  us
29f0: 65 72 5f 73 65 6c 65 63 74 28 29 3b 0a 20 20 64  er_select();.  d
2a00: 62 5f 62 65 67 69 6e 5f 74 72 61 6e 73 61 63 74  b_begin_transact
2a10: 69 6f 6e 28 29 3b 0a 20 20 72 63 20 3d 20 75 6e  ion();.  rc = un
2a20: 73 61 76 65 64 5f 63 68 61 6e 67 65 73 28 29 3b  saved_changes();
2a30: 0a 20 20 69 66 28 20 72 63 3d 3d 30 20 26 26 20  .  if( rc==0 && 
2a40: 21 69 73 41 4d 65 72 67 65 20 29 7b 0a 20 20 20  !isAMerge ){.   
2a50: 20 66 6f 73 73 69 6c 5f 70 61 6e 69 63 28 22 6e   fossil_panic("n
2a60: 6f 74 68 69 6e 67 20 68 61 73 20 63 68 61 6e 67  othing has chang
2a70: 65 64 22 29 3b 0a 20 20 7d 0a 0a 20 20 2f 2a 20  ed");.  }..  /* 
2a80: 49 66 20 6f 6e 65 20 6f 72 20 6d 6f 72 65 20 66  If one or more f
2a90: 69 6c 65 73 20 74 68 61 74 20 77 65 72 65 20 6e  iles that were n
2aa0: 61 6d 65 64 20 6f 6e 20 74 68 65 20 63 6f 6d 6d  amed on the comm
2ab0: 61 6e 64 20 6c 69 6e 65 20 68 61 76 65 20 6e 6f  and line have no
2ac0: 74 0a 20 20 2a 2a 20 62 65 65 6e 20 6d 6f 64 69  t.  ** been modi
2ad0: 66 69 65 64 2c 20 62 61 69 6c 20 6f 75 74 20 6e  fied, bail out n
2ae0: 6f 77 2e 0a 20 20 2a 2f 0a 20 20 69 66 28 20 67  ow..  */.  if( g
2af0: 2e 61 43 6f 6d 6d 69 74 46 69 6c 65 20 29 7b 0a  .aCommitFile ){.
2b00: 20 20 20 20 42 6c 6f 62 20 75 6e 6d 6f 64 69 66      Blob unmodif
2b10: 69 65 64 3b 0a 20 20 20 20 6d 65 6d 73 65 74 28  ied;.    memset(
2b20: 26 75 6e 6d 6f 64 69 66 69 65 64 2c 20 30 2c 20  &unmodified, 0, 
2b30: 73 69 7a 65 6f 66 28 42 6c 6f 62 29 29 3b 0a 20  sizeof(Blob));. 
2b40: 20 20 20 62 6c 6f 62 5f 69 6e 69 74 28 26 75 6e     blob_init(&un
2b50: 6d 6f 64 69 66 69 65 64 2c 20 30 2c 20 30 29 3b  modified, 0, 0);
2b60: 0a 20 20 20 20 64 62 5f 62 6c 6f 62 28 26 75 6e  .    db_blob(&un
2b70: 6d 6f 64 69 66 69 65 64 2c 20 0a 20 20 20 20 20  modified, .     
2b80: 20 22 53 45 4c 45 43 54 20 70 61 74 68 6e 61 6d   "SELECT pathnam
2b90: 65 20 46 52 4f 4d 20 76 66 69 6c 65 20 57 48 45  e FROM vfile WHE
2ba0: 52 45 20 63 68 6e 67 65 64 20 3d 20 30 20 41 4e  RE chnged = 0 AN
2bb0: 44 20 66 69 6c 65 5f 69 73 5f 73 65 6c 65 63 74  D file_is_select
2bc0: 65 64 28 69 64 29 22 0a 20 20 20 20 29 3b 0a 20  ed(id)".    );. 
2bd0: 20 20 20 69 66 28 20 73 74 72 6c 65 6e 28 62 6c     if( strlen(bl
2be0: 6f 62 5f 73 74 72 28 26 75 6e 6d 6f 64 69 66 69  ob_str(&unmodifi
2bf0: 65 64 29 29 20 29 7b 0a 20 20 20 20 20 20 66 6f  ed)) ){.      fo
2c00: 73 73 69 6c 5f 70 61 6e 69 63 28 22 66 69 6c 65  ssil_panic("file
2c10: 20 25 73 20 68 61 73 20 6e 6f 74 20 63 68 61 6e   %s has not chan
2c20: 67 65 64 22 2c 20 62 6c 6f 62 5f 73 74 72 28 26  ged", blob_str(&
2c30: 75 6e 6d 6f 64 69 66 69 65 64 29 29 3b 0a 20 20  unmodified));.  
2c40: 20 20 7d 0a 20 20 7d 0a 0a 20 20 76 69 64 20 3d    }.  }..  vid =
2c50: 20 64 62 5f 6c 67 65 74 5f 69 6e 74 28 22 63 68   db_lget_int("ch
2c60: 65 63 6b 6f 75 74 22 2c 20 30 29 3b 0a 20 20 76  eckout", 0);.  v
2c70: 66 69 6c 65 5f 61 67 67 72 65 67 61 74 65 5f 63  file_aggregate_c
2c80: 68 65 63 6b 73 75 6d 5f 64 69 73 6b 28 76 69 64  hecksum_disk(vid
2c90: 2c 20 26 63 6b 73 75 6d 31 29 3b 0a 20 20 69 66  , &cksum1);.  if
2ca0: 28 20 7a 43 6f 6d 6d 65 6e 74 20 29 7b 0a 20 20  ( zComment ){.  
2cb0: 20 20 62 6c 6f 62 5f 7a 65 72 6f 28 26 63 6f 6d    blob_zero(&com
2cc0: 6d 65 6e 74 29 3b 0a 20 20 20 20 62 6c 6f 62 5f  ment);.    blob_
2cd0: 61 70 70 65 6e 64 28 26 63 6f 6d 6d 65 6e 74 2c  append(&comment,
2ce0: 20 7a 43 6f 6d 6d 65 6e 74 2c 20 2d 31 29 3b 0a   zComment, -1);.
2cf0: 20 20 7d 65 6c 73 65 7b 0a 20 20 20 20 70 72 65    }else{.    pre
2d00: 70 61 72 65 5f 63 6f 6d 6d 69 74 5f 63 6f 6d 6d  pare_commit_comm
2d10: 65 6e 74 28 26 63 6f 6d 6d 65 6e 74 29 3b 0a 20  ent(&comment);. 
2d20: 20 7d 0a 0a 20 20 2f 2a 20 53 74 65 70 20 31 3a   }..  /* Step 1:
2d30: 20 49 6e 73 65 72 74 20 72 65 63 6f 72 64 73 20   Insert records 
2d40: 66 6f 72 20 61 6c 6c 20 6d 6f 64 69 66 69 65 64  for all modified
2d50: 20 66 69 6c 65 73 20 69 6e 74 6f 20 74 68 65 20   files into the 
2d60: 62 6c 6f 62 20 0a 20 20 2a 2a 20 74 61 62 6c 65  blob .  ** table
2d70: 2e 20 49 66 20 74 68 65 72 65 20 77 65 72 65 20  . If there were 
2d80: 61 72 67 75 6d 65 6e 74 73 20 70 61 73 73 65 64  arguments passed
2d90: 20 74 6f 20 74 68 69 73 20 63 6f 6d 6d 61 6e 64   to this command
2da0: 2c 20 6f 6e 6c 79 0a 20 20 2a 2a 20 74 68 65 20  , only.  ** the 
2db0: 69 64 65 6e 74 69 66 69 65 64 20 66 69 6c 73 20  identified fils 
2dc0: 61 72 65 20 69 6e 73 65 72 74 65 64 20 28 69 66  are inserted (if
2dd0: 20 74 68 65 79 20 68 61 76 65 20 62 65 65 6e 20   they have been 
2de0: 6d 6f 64 69 66 69 65 64 29 2e 0a 20 20 2a 2f 0a  modified)..  */.
2df0: 20 20 64 62 5f 70 72 65 70 61 72 65 28 26 71 2c    db_prepare(&q,
2e00: 0a 20 20 20 20 22 53 45 4c 45 43 54 20 69 64 2c  .    "SELECT id,
2e10: 20 25 51 20 7c 7c 20 70 61 74 68 6e 61 6d 65 2c   %Q || pathname,
2e20: 20 6d 72 69 64 20 46 52 4f 4d 20 76 66 69 6c 65   mrid FROM vfile
2e30: 20 22 0a 20 20 20 20 22 57 48 45 52 45 20 63 68   ".    "WHERE ch
2e40: 6e 67 65 64 3d 3d 31 20 41 4e 44 20 4e 4f 54 20  nged==1 AND NOT 
2e50: 64 65 6c 65 74 65 64 20 41 4e 44 20 66 69 6c 65  deleted AND file
2e60: 5f 69 73 5f 73 65 6c 65 63 74 65 64 28 69 64 29  _is_selected(id)
2e70: 22 0a 20 20 20 20 2c 20 67 2e 7a 4c 6f 63 61 6c  ".    , g.zLocal
2e80: 52 6f 6f 74 0a 20 20 29 3b 0a 20 20 77 68 69 6c  Root.  );.  whil
2e90: 65 28 20 64 62 5f 73 74 65 70 28 26 71 29 3d 3d  e( db_step(&q)==
2ea0: 53 51 4c 49 54 45 5f 52 4f 57 20 29 7b 0a 20 20  SQLITE_ROW ){.  
2eb0: 20 20 69 6e 74 20 69 64 2c 20 72 69 64 3b 0a 20    int id, rid;. 
2ec0: 20 20 20 63 6f 6e 73 74 20 63 68 61 72 20 2a 7a     const char *z
2ed0: 46 75 6c 6c 6e 61 6d 65 3b 0a 20 20 20 20 42 6c  Fullname;.    Bl
2ee0: 6f 62 20 63 6f 6e 74 65 6e 74 3b 0a 0a 20 20 20  ob content;..   
2ef0: 20 69 64 20 3d 20 64 62 5f 63 6f 6c 75 6d 6e 5f   id = db_column_
2f00: 69 6e 74 28 26 71 2c 20 30 29 3b 0a 20 20 20 20  int(&q, 0);.    
2f10: 7a 46 75 6c 6c 6e 61 6d 65 20 3d 20 64 62 5f 63  zFullname = db_c
2f20: 6f 6c 75 6d 6e 5f 74 65 78 74 28 26 71 2c 20 31  olumn_text(&q, 1
2f30: 29 3b 0a 20 20 20 20 72 69 64 20 3d 20 64 62 5f  );.    rid = db_
2f40: 63 6f 6c 75 6d 6e 5f 69 6e 74 28 26 71 2c 20 32  column_int(&q, 2
2f50: 29 3b 0a 0a 20 20 20 20 62 6c 6f 62 5f 7a 65 72  );..    blob_zer
2f60: 6f 28 26 63 6f 6e 74 65 6e 74 29 3b 0a 20 20 20  o(&content);.   
2f70: 20 62 6c 6f 62 5f 72 65 61 64 5f 66 72 6f 6d 5f   blob_read_from_
2f80: 66 69 6c 65 28 26 63 6f 6e 74 65 6e 74 2c 20 7a  file(&content, z
2f90: 46 75 6c 6c 6e 61 6d 65 29 3b 0a 20 20 20 20 6e  Fullname);.    n
2fa0: 72 69 64 20 3d 20 63 6f 6e 74 65 6e 74 5f 70 75  rid = content_pu
2fb0: 74 28 26 63 6f 6e 74 65 6e 74 2c 20 30 2c 20 30  t(&content, 0, 0
2fc0: 29 3b 0a 20 20 20 20 69 66 28 20 72 69 64 3e 30  );.    if( rid>0
2fd0: 20 29 7b 0a 20 20 20 20 20 20 63 6f 6e 74 65 6e   ){.      conten
2fe0: 74 5f 64 65 6c 74 69 66 79 28 72 69 64 2c 20 6e  t_deltify(rid, n
2ff0: 72 69 64 2c 20 30 29 3b 0a 20 20 20 20 7d 0a 20  rid, 0);.    }. 
3000: 20 20 20 64 62 5f 6d 75 6c 74 69 5f 65 78 65 63     db_multi_exec
3010: 28 22 55 50 44 41 54 45 20 76 66 69 6c 65 20 53  ("UPDATE vfile S
3020: 45 54 20 6d 72 69 64 3d 25 64 2c 20 72 69 64 3d  ET mrid=%d, rid=
3030: 25 64 20 57 48 45 52 45 20 69 64 3d 25 64 22 2c  %d WHERE id=%d",
3040: 20 6e 72 69 64 2c 6e 72 69 64 2c 69 64 29 3b 0a   nrid,nrid,id);.
3050: 20 20 20 20 64 62 5f 6d 75 6c 74 69 5f 65 78 65      db_multi_exe
3060: 63 28 22 49 4e 53 45 52 54 20 4f 52 20 49 47 4e  c("INSERT OR IGN
3070: 4f 52 45 20 49 4e 54 4f 20 75 6e 73 65 6e 74 20  ORE INTO unsent 
3080: 56 41 4c 55 45 53 28 25 64 29 22 2c 20 6e 72 69  VALUES(%d)", nri
3090: 64 29 3b 0a 20 20 7d 0a 20 20 64 62 5f 66 69 6e  d);.  }.  db_fin
30a0: 61 6c 69 7a 65 28 26 71 29 3b 0a 0a 20 20 2f 2a  alize(&q);..  /*
30b0: 20 43 72 65 61 74 65 20 74 68 65 20 6d 61 6e 69   Create the mani
30c0: 66 65 73 74 20 2a 2f 0a 20 20 62 6c 6f 62 5f 7a  fest */.  blob_z
30d0: 65 72 6f 28 26 6d 61 6e 69 66 65 73 74 29 3b 0a  ero(&manifest);.
30e0: 20 20 69 66 28 20 62 6c 6f 62 5f 73 69 7a 65 28    if( blob_size(
30f0: 26 63 6f 6d 6d 65 6e 74 29 3d 3d 30 20 29 7b 0a  &comment)==0 ){.
3100: 20 20 20 20 62 6c 6f 62 5f 61 70 70 65 6e 64 28      blob_append(
3110: 26 63 6f 6d 6d 65 6e 74 2c 20 22 28 6e 6f 20 63  &comment, "(no c
3120: 6f 6d 6d 65 6e 74 29 22 2c 20 2d 31 29 3b 0a 20  omment)", -1);. 
3130: 20 7d 0a 20 20 62 6c 6f 62 5f 61 70 70 65 6e 64   }.  blob_append
3140: 66 28 26 6d 61 6e 69 66 65 73 74 2c 20 22 43 20  f(&manifest, "C 
3150: 25 46 5c 6e 22 2c 20 62 6c 6f 62 5f 73 74 72 28  %F\n", blob_str(
3160: 26 63 6f 6d 6d 65 6e 74 29 29 3b 0a 20 20 7a 44  &comment));.  zD
3170: 61 74 65 20 3d 20 64 62 5f 74 65 78 74 28 30 2c  ate = db_text(0,
3180: 20 22 53 45 4c 45 43 54 20 64 61 74 65 74 69 6d   "SELECT datetim
3190: 65 28 27 6e 6f 77 27 29 22 29 3b 0a 20 20 7a 44  e('now')");.  zD
31a0: 61 74 65 5b 31 30 5d 20 3d 20 27 54 27 3b 0a 20  ate[10] = 'T';. 
31b0: 20 62 6c 6f 62 5f 61 70 70 65 6e 64 66 28 26 6d   blob_appendf(&m
31c0: 61 6e 69 66 65 73 74 2c 20 22 44 20 25 73 5c 6e  anifest, "D %s\n
31d0: 22 2c 20 7a 44 61 74 65 29 3b 0a 20 20 64 62 5f  ", zDate);.  db_
31e0: 70 72 65 70 61 72 65 28 26 71 2c 0a 20 20 20 20  prepare(&q,.    
31f0: 22 53 45 4c 45 43 54 20 70 61 74 68 6e 61 6d 65  "SELECT pathname
3200: 2c 20 75 75 69 64 20 46 52 4f 4d 20 76 66 69 6c  , uuid FROM vfil
3210: 65 20 4a 4f 49 4e 20 62 6c 6f 62 20 4f 4e 20 76  e JOIN blob ON v
3220: 66 69 6c 65 2e 6d 72 69 64 3d 62 6c 6f 62 2e 72  file.mrid=blob.r
3230: 69 64 22 0a 20 20 20 20 22 20 57 48 45 52 45 20  id".    " WHERE 
3240: 4e 4f 54 20 64 65 6c 65 74 65 64 20 41 4e 44 20  NOT deleted AND 
3250: 76 66 69 6c 65 2e 76 69 64 3d 25 64 22 0a 20 20  vfile.vid=%d".  
3260: 20 20 22 20 4f 52 44 45 52 20 42 59 20 31 22 2c    " ORDER BY 1",
3270: 20 76 69 64 29 3b 0a 20 20 77 68 69 6c 65 28 20   vid);.  while( 
3280: 64 62 5f 73 74 65 70 28 26 71 29 3d 3d 53 51 4c  db_step(&q)==SQL
3290: 49 54 45 5f 52 4f 57 20 29 7b 0a 20 20 20 20 63  ITE_ROW ){.    c
32a0: 6f 6e 73 74 20 63 68 61 72 20 2a 7a 4e 61 6d 65  onst char *zName
32b0: 20 3d 20 64 62 5f 63 6f 6c 75 6d 6e 5f 74 65 78   = db_column_tex
32c0: 74 28 26 71 2c 20 30 29 3b 0a 20 20 20 20 63 6f  t(&q, 0);.    co
32d0: 6e 73 74 20 63 68 61 72 20 2a 7a 55 75 69 64 20  nst char *zUuid 
32e0: 3d 20 64 62 5f 63 6f 6c 75 6d 6e 5f 74 65 78 74  = db_column_text
32f0: 28 26 71 2c 20 31 29 3b 0a 20 20 20 20 62 6c 6f  (&q, 1);.    blo
3300: 62 5f 61 70 70 65 6e 64 66 28 26 6d 61 6e 69 66  b_appendf(&manif
3310: 65 73 74 2c 20 22 46 20 25 46 20 25 73 5c 6e 22  est, "F %F %s\n"
3320: 2c 20 7a 4e 61 6d 65 2c 20 7a 55 75 69 64 29 3b  , zName, zUuid);
3330: 0a 20 20 7d 0a 20 20 64 62 5f 66 69 6e 61 6c 69  .  }.  db_finali
3340: 7a 65 28 26 71 29 3b 0a 20 20 7a 55 75 69 64 20  ze(&q);.  zUuid 
3350: 3d 20 64 62 5f 74 65 78 74 28 30 2c 20 22 53 45  = db_text(0, "SE
3360: 4c 45 43 54 20 75 75 69 64 20 46 52 4f 4d 20 62  LECT uuid FROM b
3370: 6c 6f 62 20 57 48 45 52 45 20 72 69 64 3d 25 64  lob WHERE rid=%d
3380: 22 2c 20 76 69 64 29 3b 0a 20 20 62 6c 6f 62 5f  ", vid);.  blob_
3390: 61 70 70 65 6e 64 66 28 26 6d 61 6e 69 66 65 73  appendf(&manifes
33a0: 74 2c 20 22 50 20 25 73 22 2c 20 7a 55 75 69 64  t, "P %s", zUuid
33b0: 29 3b 0a 0a 20 20 64 62 5f 70 72 65 70 61 72 65  );..  db_prepare
33c0: 28 26 71 32 2c 20 22 53 45 4c 45 43 54 20 6d 65  (&q2, "SELECT me
33d0: 72 67 65 20 46 52 4f 4d 20 76 6d 65 72 67 65 20  rge FROM vmerge 
33e0: 57 48 45 52 45 20 69 64 3d 3a 69 64 22 29 3b 0a  WHERE id=:id");.
33f0: 20 20 64 62 5f 62 69 6e 64 5f 69 6e 74 28 26 71    db_bind_int(&q
3400: 32 2c 20 22 3a 69 64 22 2c 20 30 29 3b 0a 20 20  2, ":id", 0);.  
3410: 77 68 69 6c 65 28 20 64 62 5f 73 74 65 70 28 26  while( db_step(&
3420: 71 32 29 3d 3d 53 51 4c 49 54 45 5f 52 4f 57 20  q2)==SQLITE_ROW 
3430: 29 7b 0a 20 20 20 20 69 6e 74 20 6d 69 64 20 3d  ){.    int mid =
3440: 20 64 62 5f 63 6f 6c 75 6d 6e 5f 69 6e 74 28 26   db_column_int(&
3450: 71 32 2c 20 30 29 3b 0a 20 20 20 20 7a 55 75 69  q2, 0);.    zUui
3460: 64 20 3d 20 64 62 5f 74 65 78 74 28 30 2c 20 22  d = db_text(0, "
3470: 53 45 4c 45 43 54 20 75 75 69 64 20 46 52 4f 4d  SELECT uuid FROM
3480: 20 62 6c 6f 62 20 57 48 45 52 45 20 72 69 64 3d   blob WHERE rid=
3490: 25 64 22 2c 20 6d 69 64 29 3b 0a 20 20 20 20 69  %d", mid);.    i
34a0: 66 28 20 7a 55 75 69 64 20 29 7b 0a 20 20 20 20  f( zUuid ){.    
34b0: 20 20 62 6c 6f 62 5f 61 70 70 65 6e 64 66 28 26    blob_appendf(&
34c0: 6d 61 6e 69 66 65 73 74 2c 20 22 20 25 73 22 2c  manifest, " %s",
34d0: 20 7a 55 75 69 64 29 3b 0a 20 20 20 20 20 20 66   zUuid);.      f
34e0: 72 65 65 28 7a 55 75 69 64 29 3b 0a 20 20 20 20  ree(zUuid);.    
34f0: 7d 0a 20 20 7d 0a 20 20 64 62 5f 72 65 73 65 74  }.  }.  db_reset
3500: 28 26 71 32 29 3b 0a 0a 20 20 62 6c 6f 62 5f 61  (&q2);..  blob_a
3510: 70 70 65 6e 64 66 28 26 6d 61 6e 69 66 65 73 74  ppendf(&manifest
3520: 2c 20 22 5c 6e 22 29 3b 0a 20 20 62 6c 6f 62 5f  , "\n");.  blob_
3530: 61 70 70 65 6e 64 66 28 26 6d 61 6e 69 66 65 73  appendf(&manifes
3540: 74 2c 20 22 52 20 25 62 5c 6e 22 2c 20 26 63 6b  t, "R %b\n", &ck
3550: 73 75 6d 31 29 3b 0a 20 20 62 6c 6f 62 5f 61 70  sum1);.  blob_ap
3560: 70 65 6e 64 66 28 26 6d 61 6e 69 66 65 73 74 2c  pendf(&manifest,
3570: 20 22 55 20 25 46 5c 6e 22 2c 20 67 2e 7a 4c 6f   "U %F\n", g.zLo
3580: 67 69 6e 29 3b 0a 20 20 6d 64 35 73 75 6d 5f 62  gin);.  md5sum_b
3590: 6c 6f 62 28 26 6d 61 6e 69 66 65 73 74 2c 20 26  lob(&manifest, &
35a0: 6d 63 6b 73 75 6d 29 3b 0a 20 20 62 6c 6f 62 5f  mcksum);.  blob_
35b0: 61 70 70 65 6e 64 66 28 26 6d 61 6e 69 66 65 73  appendf(&manifes
35c0: 74 2c 20 22 5a 20 25 62 5c 6e 22 2c 20 26 6d 63  t, "Z %b\n", &mc
35d0: 6b 73 75 6d 29 3b 0a 20 20 7a 4d 61 6e 69 66 65  ksum);.  zManife
35e0: 73 74 46 69 6c 65 20 3d 20 6d 70 72 69 6e 74 66  stFile = mprintf
35f0: 28 22 25 73 6d 61 6e 69 66 65 73 74 22 2c 20 67  ("%smanifest", g
3600: 2e 7a 4c 6f 63 61 6c 52 6f 6f 74 29 3b 0a 20 20  .zLocalRoot);.  
3610: 69 66 28 20 21 6e 6f 53 69 67 6e 20 26 26 20 63  if( !noSign && c
3620: 6c 65 61 72 73 69 67 6e 28 26 6d 61 6e 69 66 65  learsign(&manife
3630: 73 74 2c 20 26 6d 61 6e 69 66 65 73 74 29 20 29  st, &manifest) )
3640: 7b 0a 20 20 20 20 42 6c 6f 62 20 61 6e 73 3b 0a  {.    Blob ans;.
3650: 20 20 20 20 62 6c 6f 62 5f 7a 65 72 6f 28 26 61      blob_zero(&a
3660: 6e 73 29 3b 0a 20 20 20 20 70 72 6f 6d 70 74 5f  ns);.    prompt_
3670: 75 73 65 72 28 22 75 6e 61 62 6c 65 20 74 6f 20  user("unable to 
3680: 73 69 67 6e 20 6d 61 6e 69 66 65 73 74 2e 20 20  sign manifest.  
3690: 63 6f 6e 74 69 6e 75 65 20 5b 79 2f 4e 5d 3f 20  continue [y/N]? 
36a0: 22 2c 20 26 61 6e 73 29 3b 0a 20 20 20 20 69 66  ", &ans);.    if
36b0: 28 20 62 6c 6f 62 5f 73 74 72 28 26 61 6e 73 29  ( blob_str(&ans)
36c0: 5b 30 5d 21 3d 27 79 27 20 29 7b 0a 20 20 20 20  [0]!='y' ){.    
36d0: 20 20 64 62 5f 65 6e 64 5f 74 72 61 6e 73 61 63    db_end_transac
36e0: 74 69 6f 6e 28 31 29 3b 0a 20 20 20 20 20 20 65  tion(1);.      e
36f0: 78 69 74 28 31 29 3b 0a 20 20 20 20 7d 0a 20 20  xit(1);.    }.  
3700: 7d 0a 20 20 62 6c 6f 62 5f 77 72 69 74 65 5f 74  }.  blob_write_t
3710: 6f 5f 66 69 6c 65 28 26 6d 61 6e 69 66 65 73 74  o_file(&manifest
3720: 2c 20 7a 4d 61 6e 69 66 65 73 74 46 69 6c 65 29  , zManifestFile)
3730: 3b 0a 20 20 62 6c 6f 62 5f 72 65 73 65 74 28 26  ;.  blob_reset(&
3740: 6d 61 6e 69 66 65 73 74 29 3b 0a 20 20 62 6c 6f  manifest);.  blo
3750: 62 5f 72 65 61 64 5f 66 72 6f 6d 5f 66 69 6c 65  b_read_from_file
3760: 28 26 6d 61 6e 69 66 65 73 74 2c 20 7a 4d 61 6e  (&manifest, zMan
3770: 69 66 65 73 74 46 69 6c 65 29 3b 0a 20 20 66 72  ifestFile);.  fr
3780: 65 65 28 7a 4d 61 6e 69 66 65 73 74 46 69 6c 65  ee(zManifestFile
3790: 29 3b 0a 20 20 6e 76 69 64 20 3d 20 63 6f 6e 74  );.  nvid = cont
37a0: 65 6e 74 5f 70 75 74 28 26 6d 61 6e 69 66 65 73  ent_put(&manifes
37b0: 74 2c 20 30 2c 20 30 29 3b 0a 20 20 69 66 28 20  t, 0, 0);.  if( 
37c0: 6e 76 69 64 3d 3d 30 20 29 7b 0a 20 20 20 20 66  nvid==0 ){.    f
37d0: 6f 73 73 69 6c 5f 70 61 6e 69 63 28 22 74 72 6f  ossil_panic("tro
37e0: 75 62 6c 65 20 63 6f 6d 6d 69 74 74 69 6e 67 20  uble committing 
37f0: 6d 61 6e 69 66 65 73 74 3a 20 25 73 22 2c 20 67  manifest: %s", g
3800: 2e 7a 45 72 72 4d 73 67 29 3b 0a 20 20 7d 0a 20  .zErrMsg);.  }. 
3810: 20 64 62 5f 6d 75 6c 74 69 5f 65 78 65 63 28 22   db_multi_exec("
3820: 49 4e 53 45 52 54 20 4f 52 20 49 47 4e 4f 52 45  INSERT OR IGNORE
3830: 20 49 4e 54 4f 20 75 6e 73 65 6e 74 20 56 41 4c   INTO unsent VAL
3840: 55 45 53 28 25 64 29 22 2c 20 6e 76 69 64 29 3b  UES(%d)", nvid);
3850: 0a 20 20 6d 61 6e 69 66 65 73 74 5f 63 72 6f 73  .  manifest_cros
3860: 73 6c 69 6e 6b 28 6e 76 69 64 2c 20 26 6d 61 6e  slink(nvid, &man
3870: 69 66 65 73 74 29 3b 0a 20 20 63 6f 6e 74 65 6e  ifest);.  conten
3880: 74 5f 64 65 6c 74 69 66 79 28 76 69 64 2c 20 6e  t_deltify(vid, n
3890: 76 69 64 2c 20 30 29 3b 0a 20 20 7a 55 75 69 64  vid, 0);.  zUuid
38a0: 20 3d 20 64 62 5f 74 65 78 74 28 30 2c 20 22 53   = db_text(0, "S
38b0: 45 4c 45 43 54 20 75 75 69 64 20 46 52 4f 4d 20  ELECT uuid FROM 
38c0: 62 6c 6f 62 20 57 48 45 52 45 20 72 69 64 3d 25  blob WHERE rid=%
38d0: 64 22 2c 20 6e 76 69 64 29 3b 0a 20 20 70 72 69  d", nvid);.  pri
38e0: 6e 74 66 28 22 4e 65 77 5f 56 65 72 73 69 6f 6e  ntf("New_Version
38f0: 3a 20 25 73 5c 6e 22 2c 20 7a 55 75 69 64 29 3b  : %s\n", zUuid);
3900: 0a 20 20 7a 4d 61 6e 69 66 65 73 74 46 69 6c 65  .  zManifestFile
3910: 20 3d 20 6d 70 72 69 6e 74 66 28 22 25 73 6d 61   = mprintf("%sma
3920: 6e 69 66 65 73 74 2e 75 75 69 64 22 2c 20 67 2e  nifest.uuid", g.
3930: 7a 4c 6f 63 61 6c 52 6f 6f 74 29 3b 0a 20 20 62  zLocalRoot);.  b
3940: 6c 6f 62 5f 7a 65 72 6f 28 26 6d 75 75 69 64 29  lob_zero(&muuid)
3950: 3b 0a 20 20 62 6c 6f 62 5f 61 70 70 65 6e 64 66  ;.  blob_appendf
3960: 28 26 6d 75 75 69 64 2c 20 22 25 73 5c 6e 22 2c  (&muuid, "%s\n",
3970: 20 7a 55 75 69 64 29 3b 0a 20 20 62 6c 6f 62 5f   zUuid);.  blob_
3980: 77 72 69 74 65 5f 74 6f 5f 66 69 6c 65 28 26 6d  write_to_file(&m
3990: 75 75 69 64 2c 20 7a 4d 61 6e 69 66 65 73 74 46  uuid, zManifestF
39a0: 69 6c 65 29 3b 0a 20 20 66 72 65 65 28 7a 4d 61  ile);.  free(zMa
39b0: 6e 69 66 65 73 74 46 69 6c 65 29 3b 0a 20 20 62  nifestFile);.  b
39c0: 6c 6f 62 5f 72 65 73 65 74 28 26 6d 75 75 69 64  lob_reset(&muuid
39d0: 29 3b 0a 0a 20 20 0a 20 20 2f 2a 20 55 70 64 61  );..  .  /* Upda
39e0: 74 65 20 74 68 65 20 76 66 69 6c 65 20 61 6e 64  te the vfile and
39f0: 20 76 6d 65 72 67 65 20 74 61 62 6c 65 73 20 2a   vmerge tables *
3a00: 2f 0a 20 20 64 62 5f 6d 75 6c 74 69 5f 65 78 65  /.  db_multi_exe
3a10: 63 28 0a 20 20 20 20 22 44 45 4c 45 54 45 20 46  c(.    "DELETE F
3a20: 52 4f 4d 20 76 66 69 6c 65 20 57 48 45 52 45 20  ROM vfile WHERE 
3a30: 28 76 69 64 21 3d 25 64 20 4f 52 20 64 65 6c 65  (vid!=%d OR dele
3a40: 74 65 64 29 20 41 4e 44 20 66 69 6c 65 5f 69 73  ted) AND file_is
3a50: 5f 73 65 6c 65 63 74 65 64 28 69 64 29 3b 22 0a  _selected(id);".
3a60: 20 20 20 20 22 44 45 4c 45 54 45 20 46 52 4f 4d      "DELETE FROM
3a70: 20 76 6d 65 72 67 65 20 57 48 45 52 45 20 66 69   vmerge WHERE fi
3a80: 6c 65 5f 69 73 5f 73 65 6c 65 63 74 65 64 28 69  le_is_selected(i
3a90: 64 29 20 4f 52 20 69 64 3d 30 3b 22 0a 20 20 20  d) OR id=0;".   
3aa0: 20 22 55 50 44 41 54 45 20 76 66 69 6c 65 20 53   "UPDATE vfile S
3ab0: 45 54 20 76 69 64 3d 25 64 3b 22 0a 20 20 20 20  ET vid=%d;".    
3ac0: 22 55 50 44 41 54 45 20 76 66 69 6c 65 20 53 45  "UPDATE vfile SE
3ad0: 54 20 72 69 64 3d 6d 72 69 64 2c 20 63 68 6e 67  T rid=mrid, chng
3ae0: 65 64 3d 30 2c 20 64 65 6c 65 74 65 64 3d 30 20  ed=0, deleted=0 
3af0: 57 48 45 52 45 20 66 69 6c 65 5f 69 73 5f 73 65  WHERE file_is_se
3b00: 6c 65 63 74 65 64 28 69 64 29 3b 22 0a 20 20 20  lected(id);".   
3b10: 20 2c 20 76 69 64 2c 20 6e 76 69 64 0a 20 20 29   , vid, nvid.  )
3b20: 3b 0a 20 20 64 62 5f 6c 73 65 74 5f 69 6e 74 28  ;.  db_lset_int(
3b30: 22 63 68 65 63 6b 6f 75 74 22 2c 20 6e 76 69 64  "checkout", nvid
3b40: 29 3b 0a 0a 20 20 2f 2a 20 56 65 72 69 66 79 20  );..  /* Verify 
3b50: 74 68 61 74 20 74 68 65 20 72 65 70 6f 73 69 74  that the reposit
3b60: 6f 72 79 20 63 68 65 63 6b 73 75 6d 20 6d 61 74  ory checksum mat
3b70: 63 68 65 73 20 74 68 65 20 65 78 70 65 63 74 65  ches the expecte
3b80: 64 20 63 68 65 63 6b 73 75 6d 0a 20 20 2a 2a 20  d checksum.  ** 
3b90: 63 61 6c 63 75 6c 61 74 65 64 20 62 65 66 6f 72  calculated befor
3ba0: 65 20 74 68 65 20 63 68 65 63 6b 69 6e 20 73 74  e the checkin st
3bb0: 61 72 74 65 64 20 28 61 6e 64 20 73 74 6f 72 65  arted (and store
3bc0: 64 20 61 73 20 74 68 65 20 52 20 72 65 63 6f 72  d as the R recor
3bd0: 64 0a 20 20 2a 2a 20 6f 66 20 74 68 65 20 6d 61  d.  ** of the ma
3be0: 6e 69 66 65 73 74 20 66 69 6c 65 29 2e 0a 20 20  nifest file)..  
3bf0: 2a 2f 0a 20 20 76 66 69 6c 65 5f 61 67 67 72 65  */.  vfile_aggre
3c00: 67 61 74 65 5f 63 68 65 63 6b 73 75 6d 5f 72 65  gate_checksum_re
3c10: 70 6f 73 69 74 6f 72 79 28 6e 76 69 64 2c 20 26  pository(nvid, &
3c20: 63 6b 73 75 6d 32 29 3b 0a 20 20 69 66 28 20 62  cksum2);.  if( b
3c30: 6c 6f 62 5f 63 6f 6d 70 61 72 65 28 26 63 6b 73  lob_compare(&cks
3c40: 75 6d 31 2c 20 26 63 6b 73 75 6d 32 29 20 29 7b  um1, &cksum2) ){
3c50: 0a 20 20 20 20 66 6f 73 73 69 6c 5f 70 61 6e 69  .    fossil_pani
3c60: 63 28 22 74 72 65 65 20 63 68 65 63 6b 73 75 6d  c("tree checksum
3c70: 20 64 6f 65 73 20 6e 6f 74 20 6d 61 74 63 68 20   does not match 
3c80: 72 65 70 6f 73 69 74 6f 72 79 20 61 66 74 65 72  repository after
3c90: 20 63 6f 6d 6d 69 74 22 29 3b 0a 20 20 7d 0a 0a   commit");.  }..
3ca0: 20 20 2f 2a 20 56 65 72 69 66 79 20 74 68 61 74    /* Verify that
3cb0: 20 74 68 65 20 6d 61 6e 69 66 65 73 74 20 63 68   the manifest ch
3cc0: 65 63 6b 73 75 6d 20 6d 61 74 63 68 65 73 20 74  ecksum matches t
3cd0: 68 65 20 65 78 70 65 63 74 65 64 20 63 68 65 63  he expected chec
3ce0: 6b 73 75 6d 20 2a 2f 0a 20 20 76 66 69 6c 65 5f  ksum */.  vfile_
3cf0: 61 67 67 72 65 67 61 74 65 5f 63 68 65 63 6b 73  aggregate_checks
3d00: 75 6d 5f 6d 61 6e 69 66 65 73 74 28 6e 76 69 64  um_manifest(nvid
3d10: 2c 20 26 63 6b 73 75 6d 32 2c 20 26 63 6b 73 75  , &cksum2, &cksu
3d20: 6d 31 62 29 3b 0a 20 20 69 66 28 20 62 6c 6f 62  m1b);.  if( blob
3d30: 5f 63 6f 6d 70 61 72 65 28 26 63 6b 73 75 6d 31  _compare(&cksum1
3d40: 2c 20 26 63 6b 73 75 6d 31 62 29 20 29 7b 0a 20  , &cksum1b) ){. 
3d50: 20 20 20 66 6f 73 73 69 6c 5f 70 61 6e 69 63 28     fossil_panic(
3d60: 22 6d 61 6e 69 66 65 73 74 20 63 68 65 63 6b 73  "manifest checks
3d70: 75 6d 20 64 6f 65 73 20 6e 6f 74 20 61 67 72 65  um does not agre
3d80: 65 20 77 69 74 68 20 6d 61 6e 69 66 65 73 74 3a  e with manifest:
3d90: 20 22 0a 20 20 20 20 20 20 20 20 20 20 20 20 20   ".             
3da0: 20 20 20 20 22 25 62 20 76 65 72 73 75 73 20 25      "%b versus %
3db0: 62 22 2c 20 26 63 6b 73 75 6d 31 2c 20 26 63 6b  b", &cksum1, &ck
3dc0: 73 75 6d 31 62 29 3b 0a 20 20 7d 0a 20 20 69 66  sum1b);.  }.  if
3dd0: 28 20 62 6c 6f 62 5f 63 6f 6d 70 61 72 65 28 26  ( blob_compare(&
3de0: 63 6b 73 75 6d 31 2c 20 26 63 6b 73 75 6d 32 29  cksum1, &cksum2)
3df0: 20 29 7b 0a 20 20 20 20 66 6f 73 73 69 6c 5f 70   ){.    fossil_p
3e00: 61 6e 69 63 28 22 74 72 65 65 20 63 68 65 63 6b  anic("tree check
3e10: 73 75 6d 20 64 6f 65 73 20 6e 6f 74 20 6d 61 74  sum does not mat
3e20: 63 68 20 6d 61 6e 69 66 65 73 74 20 61 66 74 65  ch manifest afte
3e30: 72 20 63 6f 6d 6d 69 74 3a 20 22 0a 20 20 20 20  r commit: ".    
3e40: 20 20 20 20 20 20 20 20 20 20 20 20 20 22 25 62               "%b
3e50: 20 76 65 72 73 75 73 20 25 62 22 2c 20 26 63 6b   versus %b", &ck
3e60: 73 75 6d 31 2c 20 26 63 6b 73 75 6d 32 29 3b 0a  sum1, &cksum2);.
3e70: 20 20 7d 0a 0a 20 20 2f 2a 20 56 65 72 69 66 79    }..  /* Verify
3e80: 20 74 68 61 74 20 74 68 65 20 63 6f 6d 6d 69 74   that the commit
3e90: 20 64 69 64 20 6e 6f 74 20 6d 6f 64 69 66 79 20   did not modify 
3ea0: 61 6e 79 20 64 69 73 6b 20 69 6d 61 67 65 73 2e  any disk images.
3eb0: 20 2a 2f 0a 20 20 76 66 69 6c 65 5f 61 67 67 72   */.  vfile_aggr
3ec0: 65 67 61 74 65 5f 63 68 65 63 6b 73 75 6d 5f 64  egate_checksum_d
3ed0: 69 73 6b 28 6e 76 69 64 2c 20 26 63 6b 73 75 6d  isk(nvid, &cksum
3ee0: 32 29 3b 0a 20 20 69 66 28 20 62 6c 6f 62 5f 63  2);.  if( blob_c
3ef0: 6f 6d 70 61 72 65 28 26 63 6b 73 75 6d 31 2c 20  ompare(&cksum1, 
3f00: 26 63 6b 73 75 6d 32 29 20 29 7b 0a 20 20 20 20  &cksum2) ){.    
3f10: 66 6f 73 73 69 6c 5f 70 61 6e 69 63 28 22 74 72  fossil_panic("tr
3f20: 65 65 20 63 68 65 63 6b 73 75 6d 73 20 62 65 66  ee checksums bef
3f30: 6f 72 65 20 61 6e 64 20 61 66 74 65 72 20 63 6f  ore and after co
3f40: 6d 6d 69 74 20 64 6f 20 6e 6f 74 20 6d 61 74 63  mmit do not matc
3f50: 68 22 29 3b 0a 20 20 7d 0a 0a 20 20 2f 2a 20 43  h");.  }..  /* C
3f60: 6c 65 61 72 20 74 68 65 20 75 6e 64 6f 2f 72 65  lear the undo/re
3f70: 64 6f 20 73 74 61 63 6b 20 2a 2f 0a 20 20 75 6e  do stack */.  un
3f80: 64 6f 5f 72 65 73 65 74 28 29 3b 0a 0a 20 20 2f  do_reset();..  /
3f90: 2a 20 43 6f 6d 6d 69 74 20 2a 2f 0a 20 20 64 62  * Commit */.  db
3fa0: 5f 65 6e 64 5f 74 72 61 6e 73 61 63 74 69 6f 6e  _end_transaction
3fb0: 28 30 29 3b 0a 20 20 0a 20 20 2f 2a 20 41 75 74  (0);.  .  /* Aut
3fc0: 6f 73 79 6e 63 20 61 6e 64 20 64 6f 20 61 20 70  osync and do a p
3fd0: 75 73 68 3f 20 2a 2f 0a 20 20 69 66 28 20 64 6f  ush? */.  if( do
3fe0: 5f 61 75 74 6f 73 79 6e 63 28 29 20 29 7b 20 20  _autosync() ){  
3ff0: 0a 20 20 20 20 67 2e 61 72 67 63 3d 32 3b 0a 20  .    g.argc=2;. 
4000: 20 20 20 67 2e 61 72 67 76 5b 31 5d 3d 22 70 75     g.argv[1]="pu
4010: 73 68 22 3b 0a 20 20 20 20 70 75 73 68 5f 63 6d  sh";.    push_cm
4020: 64 28 29 3b 0a 20 20 7d 0a 7d 0a                 d();.  }.}.