Check-in [0315f3f03b]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
SHA1 Hash:0315f3f03bd9b6786550628e07e06b6b25736cc6
Date: 2012-06-29 15:47:46
User: drh
Comment:Merge in the trunk changes.
Tags And Properties
Changes

Changes to src/checkin.c

40 Stmt q; 40 Stmt q; 41 int nPrefix = strlen(zPrefix); 41 int nPrefix = strlen(zPrefix); 42 int nErr = 0; 42 int nErr = 0; 43 Blob rewrittenPathname; 43 Blob rewrittenPathname; 44 db_prepare(&q, 44 db_prepare(&q, 45 "SELECT pathname, deleted, chnged, rid, coalesce(origname!=pathname,0)" 45 "SELECT pathname, deleted, chnged, rid, coalesce(origname!=pathname,0)" 46 " FROM vfile " 46 " FROM vfile " 47 " WHERE file_is_selected(id)" | 47 " WHERE is_selected(id)" 48 " AND (chnged OR deleted OR rid=0 OR pathname!=origname) ORDER BY 1" 48 " AND (chnged OR deleted OR rid=0 OR pathname!=origname) ORDER BY 1" 49 ); 49 ); 50 blob_zero(&rewrittenPathname); 50 blob_zero(&rewrittenPathname); 51 while( db_step(&q)==SQLITE_ROW ){ 51 while( db_step(&q)==SQLITE_ROW ){ 52 const char *zPathname = db_column_text(&q,0); 52 const char *zPathname = db_column_text(&q,0); 53 const char *zDisplayName = zPathname; 53 const char *zDisplayName = zPathname; 54 int isDeleted = db_column_int(&q, 1); 54 int isDeleted = db_column_int(&q, 1); ................................................................................................................................................................................ 680 } 680 } 681 blob_appendf(pOut, "C %F\n", blob_str(pComment)); 681 blob_appendf(pOut, "C %F\n", blob_str(pComment)); 682 zDate = date_in_standard_format(zDateOvrd ? zDateOvrd : "now"); 682 zDate = date_in_standard_format(zDateOvrd ? zDateOvrd : "now"); 683 blob_appendf(pOut, "D %s\n", zDate); 683 blob_appendf(pOut, "D %s\n", zDate); 684 zDate[10] = ' '; 684 zDate[10] = ' '; 685 db_prepare(&q, 685 db_prepare(&q, 686 "SELECT pathname, uuid, origname, blob.rid, isexe, islink," 686 "SELECT pathname, uuid, origname, blob.rid, isexe, islink," 687 " file_is_selected(vfile.id)" | 687 " is_selected(vfile.id)" 688 " FROM vfile JOIN blob ON vfile.mrid=blob.rid" 688 " FROM vfile JOIN blob ON vfile.mrid=blob.rid" 689 " WHERE (NOT deleted OR NOT file_is_selected(vfile.id))" | 689 " WHERE (NOT deleted OR NOT is_selected(vfile.id))" 690 " AND vfile.vid=%d" 690 " AND vfile.vid=%d" > 691 " ORDER BY if_selected(vfile.id, pathname, origname)", 691 " ORDER BY 1", vid); | 692 vid); 692 blob_zero(&filename); 693 blob_zero(&filename); 693 blob_appendf(&filename, "%s", g.zLocalRoot); 694 blob_appendf(&filename, "%s", g.zLocalRoot); 694 nBasename = blob_size(&filename); 695 nBasename = blob_size(&filename); 695 while( db_step(&q)==SQLITE_ROW ){ 696 while( db_step(&q)==SQLITE_ROW ){ 696 const char *zName = db_column_text(&q, 0); 697 const char *zName = db_column_text(&q, 0); 697 const char *zUuid = db_column_text(&q, 1); 698 const char *zUuid = db_column_text(&q, 1); 698 const char *zOrig = db_column_text(&q, 2); 699 const char *zOrig = db_column_text(&q, 2); ................................................................................................................................................................................ 1088 */ 1089 */ 1089 if( g.aCommitFile ){ 1090 if( g.aCommitFile ){ 1090 Blob unmodified; 1091 Blob unmodified; 1091 memset(&unmodified, 0, sizeof(Blob)); 1092 memset(&unmodified, 0, sizeof(Blob)); 1092 blob_init(&unmodified, 0, 0); 1093 blob_init(&unmodified, 0, 0); 1093 db_blob(&unmodified, 1094 db_blob(&unmodified, 1094 "SELECT pathname FROM vfile" 1095 "SELECT pathname FROM vfile" 1095 " WHERE chnged = 0 AND origname IS NULL AND file_is_selected(id)" | 1096 " WHERE chnged = 0 AND origname IS NULL AND is_selected(id)" 1096 ); 1097 ); 1097 if( strlen(blob_str(&unmodified)) ){ 1098 if( strlen(blob_str(&unmodified)) ){ 1098 fossil_fatal("file %s has not changed", blob_str(&unmodified)); 1099 fossil_fatal("file %s has not changed", blob_str(&unmodified)); 1099 } 1100 } 1100 } 1101 } 1101 1102 1102 /* 1103 /* ................................................................................................................................................................................ 1149 1150 1150 /* Step 1: Insert records for all modified files into the blob 1151 /* Step 1: Insert records for all modified files into the blob 1151 ** table. If there were arguments passed to this command, only 1152 ** table. If there were arguments passed to this command, only 1152 ** the identified fils are inserted (if they have been modified). 1153 ** the identified fils are inserted (if they have been modified). 1153 */ 1154 */ 1154 db_prepare(&q, 1155 db_prepare(&q, 1155 "SELECT id, %Q || pathname, mrid, %s FROM vfile " 1156 "SELECT id, %Q || pathname, mrid, %s FROM vfile " 1156 "WHERE chnged==1 AND NOT deleted AND file_is_selected(id)", | 1157 "WHERE chnged==1 AND NOT deleted AND is_selected(id)", 1157 g.zLocalRoot, glob_expr("pathname", db_get("crnl-glob","")) 1158 g.zLocalRoot, glob_expr("pathname", db_get("crnl-glob","")) 1158 ); 1159 ); 1159 while( db_step(&q)==SQLITE_ROW ){ 1160 while( db_step(&q)==SQLITE_ROW ){ 1160 int id, rid; 1161 int id, rid; 1161 const char *zFullname; 1162 const char *zFullname; 1162 Blob content; 1163 Blob content; 1163 int crnlOk; 1164 int crnlOk; ................................................................................................................................................................................ 1287 free(zManifestFile); 1288 free(zManifestFile); 1288 blob_reset(&muuid); 1289 blob_reset(&muuid); 1289 } 1290 } 1290 1291 1291 1292 1292 /* Update the vfile and vmerge tables */ 1293 /* Update the vfile and vmerge tables */ 1293 db_multi_exec( 1294 db_multi_exec( 1294 "DELETE FROM vfile WHERE (vid!=%d OR deleted) AND file_is_selected(id);" | 1295 "DELETE FROM vfile WHERE (vid!=%d OR deleted) AND is_selected(id);" 1295 "DELETE FROM vmerge;" 1296 "DELETE FROM vmerge;" 1296 "UPDATE vfile SET vid=%d;" 1297 "UPDATE vfile SET vid=%d;" 1297 "UPDATE vfile SET rid=mrid, chnged=0, deleted=0, origname=NULL" 1298 "UPDATE vfile SET rid=mrid, chnged=0, deleted=0, origname=NULL" 1298 " WHERE file_is_selected(id);" | 1299 " WHERE is_selected(id);" 1299 , vid, nvid 1300 , vid, nvid 1300 ); 1301 ); 1301 db_lset_int("checkout", nvid); 1302 db_lset_int("checkout", nvid); 1302 1303 1303 if( useCksum ){ 1304 if( useCksum ){ 1304 /* Verify that the repository checksum matches the expected checksum 1305 /* Verify that the repository checksum matches the expected checksum 1305 ** calculated before the checkin started (and stored as the R record 1306 ** calculated before the checkin started (and stored as the R record

Changes to src/db.c

1354 }else if( argc==2 ){ 1354 }else if( argc==2 ){ 1355 zP = (const char*)sqlite4_value_text(argv[1]); 1355 zP = (const char*)sqlite4_value_text(argv[1]); 1356 if( zP ) sqlite4_result_text(context, zP, -1, SQLITE_TRANSIENT); 1356 if( zP ) sqlite4_result_text(context, zP, -1, SQLITE_TRANSIENT); 1357 } 1357 } 1358 } 1358 } 1359 1359 1360 /* 1360 /* 1361 ** This is used by the [commit] command. | 1361 ** SQL function: 1362 ** 1362 ** 1363 ** Return true if either: | 1363 ** is_selected(id) > 1364 ** if_selected(id, X, Y) 1364 ** 1365 ** > 1366 ** On the commit command, when filenames are specified (in order to do > 1367 ** a partial commit) the vfile.id values for the named files are loaded > 1368 ** into the g.aCommitFile[] array. This function looks at that array > 1369 ** to see if a file is named on the command-line. > 1370 ** > 1371 ** In the first form (1 argument) return TRUE if either no files are 1365 ** a) Global.aCommitFile is NULL, or | 1372 ** named on the command line (g.aCommitFile is NULL meaning that all 1366 ** b) Global.aCommitFile contains the integer passed as an argument. < > 1373 ** changes are to be committed) or if id is found in g.aCommitFile[] > 1374 ** (meaning that id was named on the command-line). 1367 ** 1375 ** > 1376 ** In the second form (3 arguments) return argument X if true and Y 1368 ** Otherwise return false. | 1377 ** if false. 1369 */ 1378 */ 1370 static void file_is_selected( 1379 static void file_is_selected( 1371 sqlite4_context *context, 1380 sqlite4_context *context, 1372 int argc, 1381 int argc, 1373 sqlite4_value **argv 1382 sqlite4_value **argv 1374 ){ 1383 ){ > 1384 int rc = 0; > 1385 1375 assert(argc==1); | 1386 assert(argc==1 || argc==3); 1376 if( g.aCommitFile ){ 1387 if( g.aCommitFile ){ 1377 int iId = sqlite4_value_int(argv[0]); 1388 int iId = sqlite4_value_int(argv[0]); 1378 int ii; 1389 int ii; 1379 for(ii=0; g.aCommitFile[ii]; ii++){ 1390 for(ii=0; g.aCommitFile[ii]; ii++){ 1380 if( iId==g.aCommitFile[ii] ){ 1391 if( iId==g.aCommitFile[ii] ){ 1381 sqlite4_result_int(context, 1); | 1392 rc = 1; 1382 return; | 1393 break; 1383 } 1394 } 1384 } 1395 } > 1396 }else{ > 1397 rc = 1; > 1398 } > 1399 if( argc==1 ){ 1385 sqlite4_result_int(context, 0); | 1400 sqlite4_result_int(context, rc); 1386 }else{ 1401 }else{ > 1402 assert( argc==3 ); > 1403 assert( rc==0 || rc==1 ); 1387 sqlite4_result_int(context, 1); | 1404 sqlite4_result_value(context, argv[2-rc]); 1388 } 1405 } 1389 } 1406 } 1390 1407 1391 /* 1408 /* 1392 ** Convert the input string into an SHA1. Make a notation in the 1409 ** Convert the input string into an SHA1. Make a notation in the 1393 ** CONCEALED table so that the hash can be undo using the db_reveal() 1410 ** CONCEALED table so that the hash can be undo using the db_reveal() 1394 ** function at some later time. 1411 ** function at some later time. ................................................................................................................................................................................ 1453 LOCAL void db_connection_init(void){ 1470 LOCAL void db_connection_init(void){ 1454 sqlite4_exec(g.db, "PRAGMA foreign_keys=OFF;", 0, 0, 0); 1471 sqlite4_exec(g.db, "PRAGMA foreign_keys=OFF;", 0, 0, 0); 1455 sqlite4_create_function(g.db, "user", 0, SQLITE_ANY, 0, db_sql_user, 0, 0); 1472 sqlite4_create_function(g.db, "user", 0, SQLITE_ANY, 0, db_sql_user, 0, 0); 1456 sqlite4_create_function(g.db, "cgi", 1, SQLITE_ANY, 0, db_sql_cgi, 0, 0); 1473 sqlite4_create_function(g.db, "cgi", 1, SQLITE_ANY, 0, db_sql_cgi, 0, 0); 1457 sqlite4_create_function(g.db, "cgi", 2, SQLITE_ANY, 0, db_sql_cgi, 0, 0); 1474 sqlite4_create_function(g.db, "cgi", 2, SQLITE_ANY, 0, db_sql_cgi, 0, 0); 1458 sqlite4_create_function(g.db, "print", -1, SQLITE_UTF8, 0,db_sql_print,0,0); 1475 sqlite4_create_function(g.db, "print", -1, SQLITE_UTF8, 0,db_sql_print,0,0); 1459 sqlite4_create_function( 1476 sqlite4_create_function( 1460 g.db, "file_is_selected", 1, SQLITE_UTF8, 0, file_is_selected,0,0 | 1477 g.db, "is_selected", 1, SQLITE_UTF8, 0, file_is_selected,0,0 > 1478 ); > 1479 sqlite4_create_function( > 1480 g.db, "if_selected", 3, SQLITE_UTF8, 0, file_is_selected,0,0 1461 ); 1481 ); 1462 if( g.fSqlTrace ){ 1482 if( g.fSqlTrace ){ 1463 sqlite4_trace(g.db, db_sql_trace, 0); 1483 sqlite4_trace(g.db, db_sql_trace, 0); 1464 } 1484 } 1465 } 1485 } 1466 1486 1467 /* 1487 /*

Changes to src/manifest.c

972 } 972 } 973 blob_read_from_file(&b, g.argv[2]); 973 blob_read_from_file(&b, g.argv[2]); 974 if( g.argc>3 ) n = atoi(g.argv[3]); 974 if( g.argc>3 ) n = atoi(g.argv[3]); 975 for(i=0; i<n; i++){ 975 for(i=0; i<n; i++){ 976 Blob b2; 976 Blob b2; 977 blob_copy(&b2, &b); 977 blob_copy(&b2, &b); 978 p = manifest_parse(&b2, 0); 978 p = manifest_parse(&b2, 0); > 979 if( p==0 ) fossil_print("FAILED!\n"); 979 manifest_destroy(p); 980 manifest_destroy(p); 980 } 981 } 981 } 982 } 982 983 983 /* 984 /* 984 ** Fetch the baseline associated with the delta-manifest p. 985 ** Fetch the baseline associated with the delta-manifest p. 985 ** Return 0 on success. If unable to parse the baseline, 986 ** Return 0 on success. If unable to parse the baseline,

Changes to src/vfile.c

472 void vfile_aggregate_checksum_disk(int vid, Blob *pOut){ 472 void vfile_aggregate_checksum_disk(int vid, Blob *pOut){ 473 FILE *in; 473 FILE *in; 474 Stmt q; 474 Stmt q; 475 char zBuf[4096]; 475 char zBuf[4096]; 476 476 477 db_must_be_within_tree(); 477 db_must_be_within_tree(); 478 db_prepare(&q, 478 db_prepare(&q, 479 "SELECT %Q || pathname, pathname, origname, file_is_selected(id), rid" | 479 "SELECT %Q || pathname, pathname, origname, is_selected(id), rid" 480 " FROM vfile" 480 " FROM vfile" 481 " WHERE (NOT deleted OR NOT file_is_selected(id)) AND vid=%d" | 481 " WHERE (NOT deleted OR NOT is_selected(id)) AND vid=%d" 482 " ORDER BY pathname /*scan*/", | 482 " ORDER BY if_selected(id, pathname, origname) /*scan*/", 483 g.zLocalRoot, vid 483 g.zLocalRoot, vid 484 ); 484 ); 485 md5sum_init(); 485 md5sum_init(); 486 while( db_step(&q)==SQLITE_ROW ){ 486 while( db_step(&q)==SQLITE_ROW ){ 487 const char *zFullpath = db_column_text(&q, 0); 487 const char *zFullpath = db_column_text(&q, 0); 488 const char *zName = db_column_text(&q, 1); 488 const char *zName = db_column_text(&q, 1); 489 int isSelected = db_column_int(&q, 3); 489 int isSelected = db_column_int(&q, 3); ................................................................................................................................................................................ 564 Stmt q; 564 Stmt q; 565 Blob disk, repo; 565 Blob disk, repo; 566 char *zOut; 566 char *zOut; 567 567 568 db_must_be_within_tree(); 568 db_must_be_within_tree(); 569 db_prepare(&q, 569 db_prepare(&q, 570 "SELECT %Q || pathname, pathname, rid FROM vfile" 570 "SELECT %Q || pathname, pathname, rid FROM vfile" 571 " WHERE NOT deleted AND vid=%d AND file_is_selected(id)", | 571 " WHERE NOT deleted AND vid=%d AND is_selected(id)" > 572 " ORDER BY if_selected(id, pathname, origname) /*scan*/", 572 g.zLocalRoot, vid 573 g.zLocalRoot, vid 573 ); 574 ); 574 md5sum_init(); 575 md5sum_init(); 575 while( db_step(&q)==SQLITE_ROW ){ 576 while( db_step(&q)==SQLITE_ROW ){ 576 const char *zFullpath = db_column_text(&q, 0); 577 const char *zFullpath = db_column_text(&q, 0); 577 const char *zName = db_column_text(&q, 1); 578 const char *zName = db_column_text(&q, 1); 578 int rid = db_column_int(&q, 2); 579 int rid = db_column_int(&q, 2); ................................................................................................................................................................................ 626 void vfile_aggregate_checksum_repository(int vid, Blob *pOut){ 627 void vfile_aggregate_checksum_repository(int vid, Blob *pOut){ 627 Blob file; 628 Blob file; 628 Stmt q; 629 Stmt q; 629 char zBuf[100]; 630 char zBuf[100]; 630 631 631 db_must_be_within_tree(); 632 db_must_be_within_tree(); 632 633 633 db_prepare(&q, "SELECT pathname, origname, rid, file_is_selected(id)" | 634 db_prepare(&q, "SELECT pathname, origname, rid, is_selected(id)" 634 " FROM vfile" 635 " FROM vfile" 635 " WHERE (NOT deleted OR NOT file_is_selected(id))" | 636 " WHERE (NOT deleted OR NOT is_selected(id))" 636 " AND rid>0 AND vid=%d" 637 " AND rid>0 AND vid=%d" 637 " ORDER BY pathname /*scan*/", | 638 " ORDER BY if_selected(id,pathname,origname) /*scan*/", 638 vid); 639 vid); 639 blob_zero(&file); 640 blob_zero(&file); 640 md5sum_init(); 641 md5sum_init(); 641 while( db_step(&q)==SQLITE_ROW ){ 642 while( db_step(&q)==SQLITE_ROW ){ 642 const char *zName = db_column_text(&q, 0); 643 const char *zName = db_column_text(&q, 0); 643 const char *zOrigName = db_column_text(&q, 1); 644 const char *zOrigName = db_column_text(&q, 1); 644 int rid = db_column_int(&q, 2); 645 int rid = db_column_int(&q, 2);