Fossil SCM

Report an error if the repository schema version does not match what the fossil executable expects.

drh 2010-11-26 18:37 trunk
Commit c0c3d92340da4aa70b0853707e88490d1a4798ae
+2 -2
--- src/branch.c
+++ src/branch.c
@@ -48,11 +48,11 @@
4848
zUserOvrd = find_option("user-override",0,1);
4949
verify_all_options();
5050
if( g.argc<5 ){
5151
usage("new BRANCH-NAME CHECK-IN ?-bgcolor COLOR?");
5252
}
53
- db_find_and_open_repository(1);
53
+ db_find_and_open_repository(0, 0);
5454
noSign = db_get_int("omitsign", 0)|noSign;
5555
5656
/* fossil branch new name */
5757
zBranch = g.argv[3];
5858
if( zBranch==0 || zBranch[0]==0 ){
@@ -188,11 +188,11 @@
188188
**
189189
*/
190190
void branch_cmd(void){
191191
int n;
192192
const char *zCmd = "list";
193
- db_find_and_open_repository(1);
193
+ db_find_and_open_repository(0, 0);
194194
if( g.argc<2 ){
195195
usage("new|list ...");
196196
}
197197
if( g.argc>=3 ) zCmd = g.argv[2];
198198
n = strlen(zCmd);
199199
--- src/branch.c
+++ src/branch.c
@@ -48,11 +48,11 @@
48 zUserOvrd = find_option("user-override",0,1);
49 verify_all_options();
50 if( g.argc<5 ){
51 usage("new BRANCH-NAME CHECK-IN ?-bgcolor COLOR?");
52 }
53 db_find_and_open_repository(1);
54 noSign = db_get_int("omitsign", 0)|noSign;
55
56 /* fossil branch new name */
57 zBranch = g.argv[3];
58 if( zBranch==0 || zBranch[0]==0 ){
@@ -188,11 +188,11 @@
188 **
189 */
190 void branch_cmd(void){
191 int n;
192 const char *zCmd = "list";
193 db_find_and_open_repository(1);
194 if( g.argc<2 ){
195 usage("new|list ...");
196 }
197 if( g.argc>=3 ) zCmd = g.argv[2];
198 n = strlen(zCmd);
199
--- src/branch.c
+++ src/branch.c
@@ -48,11 +48,11 @@
48 zUserOvrd = find_option("user-override",0,1);
49 verify_all_options();
50 if( g.argc<5 ){
51 usage("new BRANCH-NAME CHECK-IN ?-bgcolor COLOR?");
52 }
53 db_find_and_open_repository(0, 0);
54 noSign = db_get_int("omitsign", 0)|noSign;
55
56 /* fossil branch new name */
57 zBranch = g.argv[3];
58 if( zBranch==0 || zBranch[0]==0 ){
@@ -188,11 +188,11 @@
188 **
189 */
190 void branch_cmd(void){
191 int n;
192 const char *zCmd = "list";
193 db_find_and_open_repository(0, 0);
194 if( g.argc<2 ){
195 usage("new|list ...");
196 }
197 if( g.argc>=3 ) zCmd = g.argv[2];
198 n = strlen(zCmd);
199
+1 -1
--- src/configure.c
+++ src/configure.c
@@ -415,11 +415,11 @@
415415
int n;
416416
const char *zMethod;
417417
if( g.argc<3 ){
418418
usage("export|import|merge|pull|reset ...");
419419
}
420
- db_find_and_open_repository(1);
420
+ db_find_and_open_repository(0, 0);
421421
zMethod = g.argv[2];
422422
n = strlen(zMethod);
423423
if( strncmp(zMethod, "export", n)==0 ){
424424
int mask;
425425
if( g.argc!=5 ){
426426
--- src/configure.c
+++ src/configure.c
@@ -415,11 +415,11 @@
415 int n;
416 const char *zMethod;
417 if( g.argc<3 ){
418 usage("export|import|merge|pull|reset ...");
419 }
420 db_find_and_open_repository(1);
421 zMethod = g.argv[2];
422 n = strlen(zMethod);
423 if( strncmp(zMethod, "export", n)==0 ){
424 int mask;
425 if( g.argc!=5 ){
426
--- src/configure.c
+++ src/configure.c
@@ -415,11 +415,11 @@
415 int n;
416 const char *zMethod;
417 if( g.argc<3 ){
418 usage("export|import|merge|pull|reset ...");
419 }
420 db_find_and_open_repository(0, 0);
421 zMethod = g.argv[2];
422 n = strlen(zMethod);
423 if( strncmp(zMethod, "export", n)==0 ){
424 int mask;
425 if( g.argc!=5 ){
426
+1 -1
--- src/content.c
+++ src/content.c
@@ -297,11 +297,11 @@
297297
*/
298298
void artifact_cmd(void){
299299
int rid;
300300
Blob content;
301301
const char *zFile;
302
- db_find_and_open_repository(1);
302
+ db_find_and_open_repository(OPEN_ANY_SCHEMA, 0);
303303
if( g.argc!=4 && g.argc!=3 ) usage("ARTIFACT-ID ?FILENAME? ?OPTIONS?");
304304
zFile = g.argc==4 ? g.argv[3] : "-";
305305
rid = name_to_rid(g.argv[2]);
306306
content_get(rid, &content);
307307
blob_write_to_file(&content, zFile);
308308
--- src/content.c
+++ src/content.c
@@ -297,11 +297,11 @@
297 */
298 void artifact_cmd(void){
299 int rid;
300 Blob content;
301 const char *zFile;
302 db_find_and_open_repository(1);
303 if( g.argc!=4 && g.argc!=3 ) usage("ARTIFACT-ID ?FILENAME? ?OPTIONS?");
304 zFile = g.argc==4 ? g.argv[3] : "-";
305 rid = name_to_rid(g.argv[2]);
306 content_get(rid, &content);
307 blob_write_to_file(&content, zFile);
308
--- src/content.c
+++ src/content.c
@@ -297,11 +297,11 @@
297 */
298 void artifact_cmd(void){
299 int rid;
300 Blob content;
301 const char *zFile;
302 db_find_and_open_repository(OPEN_ANY_SCHEMA, 0);
303 if( g.argc!=4 && g.argc!=3 ) usage("ARTIFACT-ID ?FILENAME? ?OPTIONS?");
304 zFile = g.argc==4 ? g.argv[3] : "-";
305 rid = name_to_rid(g.argv[2]);
306 content_get(rid, &content);
307 blob_write_to_file(&content, zFile);
308
+32 -4
--- src/db.c
+++ src/db.c
@@ -612,11 +612,11 @@
612612
/*
613613
** zDbName is the name of a database file. If no other database
614614
** file is open, then open this one. If another database file is
615615
** already open, then attach zDbName using the name zLabel.
616616
*/
617
-void db_open_or_attach(const char *zDbName, const char *zLabel){
617
+static void db_open_or_attach(const char *zDbName, const char *zLabel){
618618
if( !g.db ){
619619
g.db = openDatabase(zDbName);
620620
g.zRepoDb = "main";
621621
db_connection_init();
622622
}else{
@@ -826,19 +826,30 @@
826826
db_open_or_attach(zDbName, "repository");
827827
g.repositoryOpen = 1;
828828
g.zRepositoryName = mprintf("%s", zDbName);
829829
}
830830
831
+/*
832
+** Flags for the db_find_and_open_repository() function.
833
+*/
834
+#if INTERFACE
835
+#define OPEN_OK_NOT_FOUND 0x001 /* Do not error out if not found */
836
+#define OPEN_ANY_SCHEMA 0x002 /* Do not error if schema is wrong */
837
+#endif
838
+
831839
/*
832840
** Try to find the repository and open it. Use the -R or --repository
833841
** option to locate the repository. If no such option is available, then
834842
** use the repository of the open checkout if there is one.
835843
**
836844
** Error out if the repository cannot be opened.
837845
*/
838
-void db_find_and_open_repository(int errIfNotFound){
846
+void db_find_and_open_repository(int bFlags, const char *zRepoFilename){
839847
const char *zRep = find_option("repository", "R", 1);
848
+ if( zRep==0 ){
849
+ zRep = zRepoFilename;
850
+ }
840851
if( zRep==0 ){
841852
if( db_open_local()==0 ){
842853
goto rep_not_found;
843854
}
844855
zRep = db_lget("repository", 0);
@@ -846,17 +857,33 @@
846857
goto rep_not_found;
847858
}
848859
}
849860
db_open_repository(zRep);
850861
if( g.repositoryOpen ){
862
+ if( (bFlags & OPEN_ANY_SCHEMA)==0 ) db_verify_schema();
851863
return;
852864
}
853865
rep_not_found:
854
- if( errIfNotFound ){
866
+ if( (bFlags & OPEN_OK_NOT_FOUND)==0 ){
855867
fossil_fatal("use --repository or -R to specify the repository database");
856868
}
857869
}
870
+
871
+/*
872
+** Verify that the repository schema is correct. If it is not correct,
873
+** issue a fatal error and die.
874
+*/
875
+void db_verify_schema(void){
876
+ if( db_exists("SELECT 1 FROM config"
877
+ " WHERE name='aux-schema'"
878
+ " AND value<>'%s'", AUX_SCHEMA) ){
879
+ fossil_warning("incorrect repository schema version");
880
+ fossil_warning("you have version \"%s\" but you need version \"%s\"",
881
+ db_get("aux-schema",0), AUX_SCHEMA);
882
+ fossil_fatal("run \"fossil rebuild\" to fix this problem");
883
+ }
884
+}
858885
859886
/*
860887
** COMMAND: test-move-repository
861888
**
862889
** Usage: %fossil test-move-repository PATHNAME
@@ -892,10 +919,11 @@
892919
void db_must_be_within_tree(void){
893920
if( db_open_local()==0 ){
894921
fossil_fatal("not within an open checkout");
895922
}
896923
db_open_repository(0);
924
+ db_verify_schema();
897925
}
898926
899927
/*
900928
** Close the database connection.
901929
*/
@@ -1625,11 +1653,11 @@
16251653
void setting_cmd(void){
16261654
int i;
16271655
int globalFlag = find_option("global","g",0)!=0;
16281656
int unsetFlag = g.argv[1][0]=='u';
16291657
db_open_config(1);
1630
- db_find_and_open_repository(0);
1658
+ db_find_and_open_repository(OPEN_ANY_SCHEMA, 0);
16311659
if( !g.repositoryOpen ){
16321660
globalFlag = 1;
16331661
}
16341662
if( unsetFlag && g.argc!=3 ){
16351663
usage("PROPERTY ?-global?");
16361664
--- src/db.c
+++ src/db.c
@@ -612,11 +612,11 @@
612 /*
613 ** zDbName is the name of a database file. If no other database
614 ** file is open, then open this one. If another database file is
615 ** already open, then attach zDbName using the name zLabel.
616 */
617 void db_open_or_attach(const char *zDbName, const char *zLabel){
618 if( !g.db ){
619 g.db = openDatabase(zDbName);
620 g.zRepoDb = "main";
621 db_connection_init();
622 }else{
@@ -826,19 +826,30 @@
826 db_open_or_attach(zDbName, "repository");
827 g.repositoryOpen = 1;
828 g.zRepositoryName = mprintf("%s", zDbName);
829 }
830
 
 
 
 
 
 
 
 
831 /*
832 ** Try to find the repository and open it. Use the -R or --repository
833 ** option to locate the repository. If no such option is available, then
834 ** use the repository of the open checkout if there is one.
835 **
836 ** Error out if the repository cannot be opened.
837 */
838 void db_find_and_open_repository(int errIfNotFound){
839 const char *zRep = find_option("repository", "R", 1);
 
 
 
840 if( zRep==0 ){
841 if( db_open_local()==0 ){
842 goto rep_not_found;
843 }
844 zRep = db_lget("repository", 0);
@@ -846,17 +857,33 @@
846 goto rep_not_found;
847 }
848 }
849 db_open_repository(zRep);
850 if( g.repositoryOpen ){
 
851 return;
852 }
853 rep_not_found:
854 if( errIfNotFound ){
855 fossil_fatal("use --repository or -R to specify the repository database");
856 }
857 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
858
859 /*
860 ** COMMAND: test-move-repository
861 **
862 ** Usage: %fossil test-move-repository PATHNAME
@@ -892,10 +919,11 @@
892 void db_must_be_within_tree(void){
893 if( db_open_local()==0 ){
894 fossil_fatal("not within an open checkout");
895 }
896 db_open_repository(0);
 
897 }
898
899 /*
900 ** Close the database connection.
901 */
@@ -1625,11 +1653,11 @@
1625 void setting_cmd(void){
1626 int i;
1627 int globalFlag = find_option("global","g",0)!=0;
1628 int unsetFlag = g.argv[1][0]=='u';
1629 db_open_config(1);
1630 db_find_and_open_repository(0);
1631 if( !g.repositoryOpen ){
1632 globalFlag = 1;
1633 }
1634 if( unsetFlag && g.argc!=3 ){
1635 usage("PROPERTY ?-global?");
1636
--- src/db.c
+++ src/db.c
@@ -612,11 +612,11 @@
612 /*
613 ** zDbName is the name of a database file. If no other database
614 ** file is open, then open this one. If another database file is
615 ** already open, then attach zDbName using the name zLabel.
616 */
617 static void db_open_or_attach(const char *zDbName, const char *zLabel){
618 if( !g.db ){
619 g.db = openDatabase(zDbName);
620 g.zRepoDb = "main";
621 db_connection_init();
622 }else{
@@ -826,19 +826,30 @@
826 db_open_or_attach(zDbName, "repository");
827 g.repositoryOpen = 1;
828 g.zRepositoryName = mprintf("%s", zDbName);
829 }
830
831 /*
832 ** Flags for the db_find_and_open_repository() function.
833 */
834 #if INTERFACE
835 #define OPEN_OK_NOT_FOUND 0x001 /* Do not error out if not found */
836 #define OPEN_ANY_SCHEMA 0x002 /* Do not error if schema is wrong */
837 #endif
838
839 /*
840 ** Try to find the repository and open it. Use the -R or --repository
841 ** option to locate the repository. If no such option is available, then
842 ** use the repository of the open checkout if there is one.
843 **
844 ** Error out if the repository cannot be opened.
845 */
846 void db_find_and_open_repository(int bFlags, const char *zRepoFilename){
847 const char *zRep = find_option("repository", "R", 1);
848 if( zRep==0 ){
849 zRep = zRepoFilename;
850 }
851 if( zRep==0 ){
852 if( db_open_local()==0 ){
853 goto rep_not_found;
854 }
855 zRep = db_lget("repository", 0);
@@ -846,17 +857,33 @@
857 goto rep_not_found;
858 }
859 }
860 db_open_repository(zRep);
861 if( g.repositoryOpen ){
862 if( (bFlags & OPEN_ANY_SCHEMA)==0 ) db_verify_schema();
863 return;
864 }
865 rep_not_found:
866 if( (bFlags & OPEN_OK_NOT_FOUND)==0 ){
867 fossil_fatal("use --repository or -R to specify the repository database");
868 }
869 }
870
871 /*
872 ** Verify that the repository schema is correct. If it is not correct,
873 ** issue a fatal error and die.
874 */
875 void db_verify_schema(void){
876 if( db_exists("SELECT 1 FROM config"
877 " WHERE name='aux-schema'"
878 " AND value<>'%s'", AUX_SCHEMA) ){
879 fossil_warning("incorrect repository schema version");
880 fossil_warning("you have version \"%s\" but you need version \"%s\"",
881 db_get("aux-schema",0), AUX_SCHEMA);
882 fossil_fatal("run \"fossil rebuild\" to fix this problem");
883 }
884 }
885
886 /*
887 ** COMMAND: test-move-repository
888 **
889 ** Usage: %fossil test-move-repository PATHNAME
@@ -892,10 +919,11 @@
919 void db_must_be_within_tree(void){
920 if( db_open_local()==0 ){
921 fossil_fatal("not within an open checkout");
922 }
923 db_open_repository(0);
924 db_verify_schema();
925 }
926
927 /*
928 ** Close the database connection.
929 */
@@ -1625,11 +1653,11 @@
1653 void setting_cmd(void){
1654 int i;
1655 int globalFlag = find_option("global","g",0)!=0;
1656 int unsetFlag = g.argv[1][0]=='u';
1657 db_open_config(1);
1658 db_find_and_open_repository(OPEN_ANY_SCHEMA, 0);
1659 if( !g.repositoryOpen ){
1660 globalFlag = 1;
1661 }
1662 if( unsetFlag && g.argc!=3 ){
1663 usage("PROPERTY ?-global?");
1664
+1 -1
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -442,11 +442,11 @@
442442
diff_all_against_disk(zFrom, zDiffCmd, diffFlags);
443443
}
444444
}else if( zFrom==0 ){
445445
fossil_fatal("must use --from if --to is present");
446446
}else{
447
- db_find_and_open_repository(1);
447
+ db_find_and_open_repository(0, 0);
448448
verify_all_options();
449449
if( !isInternDiff ){
450450
zDiffCmd = db_get(isGDiff ? "gdiff-command" : "diff-command", 0);
451451
}
452452
if( g.argc==3 ){
453453
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -442,11 +442,11 @@
442 diff_all_against_disk(zFrom, zDiffCmd, diffFlags);
443 }
444 }else if( zFrom==0 ){
445 fossil_fatal("must use --from if --to is present");
446 }else{
447 db_find_and_open_repository(1);
448 verify_all_options();
449 if( !isInternDiff ){
450 zDiffCmd = db_get(isGDiff ? "gdiff-command" : "diff-command", 0);
451 }
452 if( g.argc==3 ){
453
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -442,11 +442,11 @@
442 diff_all_against_disk(zFrom, zDiffCmd, diffFlags);
443 }
444 }else if( zFrom==0 ){
445 fossil_fatal("must use --from if --to is present");
446 }else{
447 db_find_and_open_repository(0, 0);
448 verify_all_options();
449 if( !isInternDiff ){
450 zDiffCmd = db_get(isGDiff ? "gdiff-command" : "diff-command", 0);
451 }
452 if( g.argc==3 ){
453
+1 -1
--- src/export.c
+++ src/export.c
@@ -100,11 +100,11 @@
100100
int i;
101101
Bag blobs, vers;
102102
bag_init(&blobs);
103103
bag_init(&vers);
104104
105
- db_find_and_open_repository(1);
105
+ db_find_and_open_repository(0, 0);
106106
107107
/* Step 1: Generate "blob" records for every artifact that is part
108108
** of a check-in
109109
*/
110110
fossil_binary_mode(stdout);
111111
--- src/export.c
+++ src/export.c
@@ -100,11 +100,11 @@
100 int i;
101 Bag blobs, vers;
102 bag_init(&blobs);
103 bag_init(&vers);
104
105 db_find_and_open_repository(1);
106
107 /* Step 1: Generate "blob" records for every artifact that is part
108 ** of a check-in
109 */
110 fossil_binary_mode(stdout);
111
--- src/export.c
+++ src/export.c
@@ -100,11 +100,11 @@
100 int i;
101 Bag blobs, vers;
102 bag_init(&blobs);
103 bag_init(&vers);
104
105 db_find_and_open_repository(0, 0);
106
107 /* Step 1: Generate "blob" records for every artifact that is part
108 ** of a check-in
109 */
110 fossil_binary_mode(stdout);
111
+10 -5
--- src/rebuild.c
+++ src/rebuild.c
@@ -360,20 +360,25 @@
360360
forceFlag = find_option("force","f",0)!=0;
361361
randomizeFlag = find_option("randomize", 0, 0)!=0;
362362
if( g.argc==3 ){
363363
db_open_repository(g.argv[2]);
364364
}else{
365
- db_find_and_open_repository(1);
365
+ db_find_and_open_repository(OPEN_ANY_SCHEMA, 0);
366366
if( g.argc!=2 ){
367367
usage("?REPOSITORY-FILENAME?");
368368
}
369369
db_close();
370370
db_open_repository(g.zRepositoryName);
371371
}
372372
db_begin_transaction();
373373
ttyOutput = 1;
374374
errCnt = rebuild_db(randomizeFlag, 1);
375
+ db_multi_exec(
376
+ "REPLACE INTO config(name,value) VALUES('content-schema','%s');"
377
+ "REPLACE INTO config(name,value) VALUES('aux-schema','%s');",
378
+ CONTENT_SCHEMA, AUX_SCHEMA
379
+ );
375380
if( errCnt && !forceFlag ){
376381
printf("%d errors. Rolling back changes. Use --force to force a commit.\n",
377382
errCnt);
378383
db_end_transaction(1);
379384
}else{
@@ -381,19 +386,19 @@
381386
db_end_transaction(0);
382387
}
383388
}
384389
385390
/*
386
-** COMMAND: test-detach
391
+** COMMAND: test-detach ?REPOSITORY?
387392
**
388393
** Change the project-code and make other changes in order to prevent
389394
** the repository from ever again pushing or pulling to other
390395
** repositories. Used to create a "test" repository for development
391396
** testing by cloning a working project repository.
392397
*/
393398
void test_detach_cmd(void){
394
- db_find_and_open_repository(1);
399
+ db_find_and_open_repository(0, g.argv[2]);
395400
db_begin_transaction();
396401
db_multi_exec(
397402
"DELETE FROM config WHERE name='last-sync-url';"
398403
"UPDATE config SET value=lower(hex(randomblob(20)))"
399404
" WHERE name='project-code';"
@@ -411,11 +416,11 @@
411416
*/
412417
void test_createcluster_cmd(void){
413418
if( g.argc==3 ){
414419
db_open_repository(g.argv[2]);
415420
}else{
416
- db_find_and_open_repository(1);
421
+ db_find_and_open_repository(0, 0);
417422
if( g.argc!=2 ){
418423
usage("?REPOSITORY-FILENAME?");
419424
}
420425
db_close();
421426
db_open_repository(g.zRepositoryName);
@@ -638,11 +643,11 @@
638643
zFNameFormat = mprintf("%s/%%.%ds/%%s",zDestDir,prefixLength);
639644
}else{
640645
zFNameFormat = mprintf("%s/%%s",zDestDir);
641646
}
642647
/* open repository and open query for all artifacts */
643
- db_find_and_open_repository(1);
648
+ db_find_and_open_repository(OPEN_ANY_SCHEMA, 0);
644649
bag_init(&bagDone);
645650
ttyOutput = 1;
646651
processCnt = 0;
647652
if (!g.fQuiet) {
648653
printf("0 (0%%)...\r");
649654
--- src/rebuild.c
+++ src/rebuild.c
@@ -360,20 +360,25 @@
360 forceFlag = find_option("force","f",0)!=0;
361 randomizeFlag = find_option("randomize", 0, 0)!=0;
362 if( g.argc==3 ){
363 db_open_repository(g.argv[2]);
364 }else{
365 db_find_and_open_repository(1);
366 if( g.argc!=2 ){
367 usage("?REPOSITORY-FILENAME?");
368 }
369 db_close();
370 db_open_repository(g.zRepositoryName);
371 }
372 db_begin_transaction();
373 ttyOutput = 1;
374 errCnt = rebuild_db(randomizeFlag, 1);
 
 
 
 
 
375 if( errCnt && !forceFlag ){
376 printf("%d errors. Rolling back changes. Use --force to force a commit.\n",
377 errCnt);
378 db_end_transaction(1);
379 }else{
@@ -381,19 +386,19 @@
381 db_end_transaction(0);
382 }
383 }
384
385 /*
386 ** COMMAND: test-detach
387 **
388 ** Change the project-code and make other changes in order to prevent
389 ** the repository from ever again pushing or pulling to other
390 ** repositories. Used to create a "test" repository for development
391 ** testing by cloning a working project repository.
392 */
393 void test_detach_cmd(void){
394 db_find_and_open_repository(1);
395 db_begin_transaction();
396 db_multi_exec(
397 "DELETE FROM config WHERE name='last-sync-url';"
398 "UPDATE config SET value=lower(hex(randomblob(20)))"
399 " WHERE name='project-code';"
@@ -411,11 +416,11 @@
411 */
412 void test_createcluster_cmd(void){
413 if( g.argc==3 ){
414 db_open_repository(g.argv[2]);
415 }else{
416 db_find_and_open_repository(1);
417 if( g.argc!=2 ){
418 usage("?REPOSITORY-FILENAME?");
419 }
420 db_close();
421 db_open_repository(g.zRepositoryName);
@@ -638,11 +643,11 @@
638 zFNameFormat = mprintf("%s/%%.%ds/%%s",zDestDir,prefixLength);
639 }else{
640 zFNameFormat = mprintf("%s/%%s",zDestDir);
641 }
642 /* open repository and open query for all artifacts */
643 db_find_and_open_repository(1);
644 bag_init(&bagDone);
645 ttyOutput = 1;
646 processCnt = 0;
647 if (!g.fQuiet) {
648 printf("0 (0%%)...\r");
649
--- src/rebuild.c
+++ src/rebuild.c
@@ -360,20 +360,25 @@
360 forceFlag = find_option("force","f",0)!=0;
361 randomizeFlag = find_option("randomize", 0, 0)!=0;
362 if( g.argc==3 ){
363 db_open_repository(g.argv[2]);
364 }else{
365 db_find_and_open_repository(OPEN_ANY_SCHEMA, 0);
366 if( g.argc!=2 ){
367 usage("?REPOSITORY-FILENAME?");
368 }
369 db_close();
370 db_open_repository(g.zRepositoryName);
371 }
372 db_begin_transaction();
373 ttyOutput = 1;
374 errCnt = rebuild_db(randomizeFlag, 1);
375 db_multi_exec(
376 "REPLACE INTO config(name,value) VALUES('content-schema','%s');"
377 "REPLACE INTO config(name,value) VALUES('aux-schema','%s');",
378 CONTENT_SCHEMA, AUX_SCHEMA
379 );
380 if( errCnt && !forceFlag ){
381 printf("%d errors. Rolling back changes. Use --force to force a commit.\n",
382 errCnt);
383 db_end_transaction(1);
384 }else{
@@ -381,19 +386,19 @@
386 db_end_transaction(0);
387 }
388 }
389
390 /*
391 ** COMMAND: test-detach ?REPOSITORY?
392 **
393 ** Change the project-code and make other changes in order to prevent
394 ** the repository from ever again pushing or pulling to other
395 ** repositories. Used to create a "test" repository for development
396 ** testing by cloning a working project repository.
397 */
398 void test_detach_cmd(void){
399 db_find_and_open_repository(0, g.argv[2]);
400 db_begin_transaction();
401 db_multi_exec(
402 "DELETE FROM config WHERE name='last-sync-url';"
403 "UPDATE config SET value=lower(hex(randomblob(20)))"
404 " WHERE name='project-code';"
@@ -411,11 +416,11 @@
416 */
417 void test_createcluster_cmd(void){
418 if( g.argc==3 ){
419 db_open_repository(g.argv[2]);
420 }else{
421 db_find_and_open_repository(0, 0);
422 if( g.argc!=2 ){
423 usage("?REPOSITORY-FILENAME?");
424 }
425 db_close();
426 db_open_repository(g.zRepositoryName);
@@ -638,11 +643,11 @@
643 zFNameFormat = mprintf("%s/%%.%ds/%%s",zDestDir,prefixLength);
644 }else{
645 zFNameFormat = mprintf("%s/%%s",zDestDir);
646 }
647 /* open repository and open query for all artifacts */
648 db_find_and_open_repository(OPEN_ANY_SCHEMA, 0);
649 bag_init(&bagDone);
650 ttyOutput = 1;
651 processCnt = 0;
652 if (!g.fQuiet) {
653 printf("0 (0%%)...\r");
654
+1 -1
--- src/schema.c
+++ src/schema.c
@@ -40,11 +40,11 @@
4040
** a date) which can change frequently. When the content schema changes,
4141
** we have to execute special procedures to update the schema. When
4242
** the aux schema changes, all we need to do is rebuild the database.
4343
*/
4444
#define CONTENT_SCHEMA "1"
45
-#define AUX_SCHEMA "2006-12-23"
45
+#define AUX_SCHEMA "2010-11-24"
4646
4747
#endif /* INTERFACE */
4848
4949
5050
/*
5151
--- src/schema.c
+++ src/schema.c
@@ -40,11 +40,11 @@
40 ** a date) which can change frequently. When the content schema changes,
41 ** we have to execute special procedures to update the schema. When
42 ** the aux schema changes, all we need to do is rebuild the database.
43 */
44 #define CONTENT_SCHEMA "1"
45 #define AUX_SCHEMA "2006-12-23"
46
47 #endif /* INTERFACE */
48
49
50 /*
51
--- src/schema.c
+++ src/schema.c
@@ -40,11 +40,11 @@
40 ** a date) which can change frequently. When the content schema changes,
41 ** we have to execute special procedures to update the schema. When
42 ** the aux schema changes, all we need to do is rebuild the database.
43 */
44 #define CONTENT_SCHEMA "1"
45 #define AUX_SCHEMA "2010-11-24"
46
47 #endif /* INTERFACE */
48
49
50 /*
51
+3 -1
--- src/sqlcmd.c
+++ src/sqlcmd.c
@@ -75,17 +75,19 @@
7575
** in ways that are unrecoverable. Be sure you know what you are doing before
7676
** running any SQL commands that modifies the repository database.
7777
*/
7878
void sqlite3_cmd(void){
7979
extern int sqlite3_shell(int, char**);
80
+ db_find_and_open_repository(OPEN_ANY_SCHEMA, 0);
81
+ db_close();
82
+ sqlite3_shutdown();
8083
sqlite3_shell(g.argc-1, g.argv+1);
8184
}
8285
8386
/*
8487
** This routine is called by the patched sqlite3 command-line shell in order
8588
** to load the name and database connection for the open Fossil database.
8689
*/
8790
void fossil_open(const char **pzRepoName){
88
- db_must_be_within_tree();
8991
sqlite3_auto_extension((void(*)(void))sqlcmd_autoinit);
9092
*pzRepoName = g.zRepositoryName;
9193
}
9294
--- src/sqlcmd.c
+++ src/sqlcmd.c
@@ -75,17 +75,19 @@
75 ** in ways that are unrecoverable. Be sure you know what you are doing before
76 ** running any SQL commands that modifies the repository database.
77 */
78 void sqlite3_cmd(void){
79 extern int sqlite3_shell(int, char**);
 
 
 
80 sqlite3_shell(g.argc-1, g.argv+1);
81 }
82
83 /*
84 ** This routine is called by the patched sqlite3 command-line shell in order
85 ** to load the name and database connection for the open Fossil database.
86 */
87 void fossil_open(const char **pzRepoName){
88 db_must_be_within_tree();
89 sqlite3_auto_extension((void(*)(void))sqlcmd_autoinit);
90 *pzRepoName = g.zRepositoryName;
91 }
92
--- src/sqlcmd.c
+++ src/sqlcmd.c
@@ -75,17 +75,19 @@
75 ** in ways that are unrecoverable. Be sure you know what you are doing before
76 ** running any SQL commands that modifies the repository database.
77 */
78 void sqlite3_cmd(void){
79 extern int sqlite3_shell(int, char**);
80 db_find_and_open_repository(OPEN_ANY_SCHEMA, 0);
81 db_close();
82 sqlite3_shutdown();
83 sqlite3_shell(g.argc-1, g.argv+1);
84 }
85
86 /*
87 ** This routine is called by the patched sqlite3 command-line shell in order
88 ** to load the name and database connection for the open Fossil database.
89 */
90 void fossil_open(const char **pzRepoName){
 
91 sqlite3_auto_extension((void(*)(void))sqlcmd_autoinit);
92 *pzRepoName = g.zRepositoryName;
93 }
94
+2 -2
--- src/sync.c
+++ src/sync.c
@@ -96,11 +96,11 @@
9696
const char *zPw = 0;
9797
int configSync = 0;
9898
int urlOptional = find_option("autourl",0,0)!=0;
9999
g.dontKeepUrl = find_option("once",0,0)!=0;
100100
url_proxy_options();
101
- db_find_and_open_repository(1);
101
+ db_find_and_open_repository(0, 0);
102102
db_open_config(0);
103103
if( g.argc==2 ){
104104
zUrl = db_get("last-sync-url", 0);
105105
zPw = unobscure(db_get("last-sync-pw", 0));
106106
if( db_get_boolean("auto-sync",1) ) configSync = CONFIGSET_SHUN;
@@ -224,11 +224,11 @@
224224
**
225225
** See also: clone, push, pull, sync
226226
*/
227227
void remote_url_cmd(void){
228228
char *zUrl;
229
- db_find_and_open_repository(1);
229
+ db_find_and_open_repository(0, 0);
230230
if( g.argc!=2 && g.argc!=3 ){
231231
usage("remote-url ?URL|off?");
232232
}
233233
if( g.argc==3 ){
234234
if( strcmp(g.argv[2],"off")==0 ){
235235
--- src/sync.c
+++ src/sync.c
@@ -96,11 +96,11 @@
96 const char *zPw = 0;
97 int configSync = 0;
98 int urlOptional = find_option("autourl",0,0)!=0;
99 g.dontKeepUrl = find_option("once",0,0)!=0;
100 url_proxy_options();
101 db_find_and_open_repository(1);
102 db_open_config(0);
103 if( g.argc==2 ){
104 zUrl = db_get("last-sync-url", 0);
105 zPw = unobscure(db_get("last-sync-pw", 0));
106 if( db_get_boolean("auto-sync",1) ) configSync = CONFIGSET_SHUN;
@@ -224,11 +224,11 @@
224 **
225 ** See also: clone, push, pull, sync
226 */
227 void remote_url_cmd(void){
228 char *zUrl;
229 db_find_and_open_repository(1);
230 if( g.argc!=2 && g.argc!=3 ){
231 usage("remote-url ?URL|off?");
232 }
233 if( g.argc==3 ){
234 if( strcmp(g.argv[2],"off")==0 ){
235
--- src/sync.c
+++ src/sync.c
@@ -96,11 +96,11 @@
96 const char *zPw = 0;
97 int configSync = 0;
98 int urlOptional = find_option("autourl",0,0)!=0;
99 g.dontKeepUrl = find_option("once",0,0)!=0;
100 url_proxy_options();
101 db_find_and_open_repository(0, 0);
102 db_open_config(0);
103 if( g.argc==2 ){
104 zUrl = db_get("last-sync-url", 0);
105 zPw = unobscure(db_get("last-sync-pw", 0));
106 if( db_get_boolean("auto-sync",1) ) configSync = CONFIGSET_SHUN;
@@ -224,11 +224,11 @@
224 **
225 ** See also: clone, push, pull, sync
226 */
227 void remote_url_cmd(void){
228 char *zUrl;
229 db_find_and_open_repository(0, 0);
230 if( g.argc!=2 && g.argc!=3 ){
231 usage("remote-url ?URL|off?");
232 }
233 if( g.argc==3 ){
234 if( strcmp(g.argv[2],"off")==0 ){
235
+1 -1
--- src/tag.c
+++ src/tag.c
@@ -368,11 +368,11 @@
368368
int n;
369369
int fRaw = find_option("raw","",0)!=0;
370370
int fPropagate = find_option("propagate","",0)!=0;
371371
const char *zPrefix = fRaw ? "" : "sym-";
372372
373
- db_find_and_open_repository(1);
373
+ db_find_and_open_repository(0, 0);
374374
if( g.argc<3 ){
375375
goto tag_cmd_usage;
376376
}
377377
n = strlen(g.argv[2]);
378378
if( n==0 ){
379379
--- src/tag.c
+++ src/tag.c
@@ -368,11 +368,11 @@
368 int n;
369 int fRaw = find_option("raw","",0)!=0;
370 int fPropagate = find_option("propagate","",0)!=0;
371 const char *zPrefix = fRaw ? "" : "sym-";
372
373 db_find_and_open_repository(1);
374 if( g.argc<3 ){
375 goto tag_cmd_usage;
376 }
377 n = strlen(g.argv[2]);
378 if( n==0 ){
379
--- src/tag.c
+++ src/tag.c
@@ -368,11 +368,11 @@
368 int n;
369 int fRaw = find_option("raw","",0)!=0;
370 int fPropagate = find_option("propagate","",0)!=0;
371 const char *zPrefix = fRaw ? "" : "sym-";
372
373 db_find_and_open_repository(0, 0);
374 if( g.argc<3 ){
375 goto tag_cmd_usage;
376 }
377 n = strlen(g.argv[2]);
378 if( n==0 ){
379
+1 -1
--- src/timeline.c
+++ src/timeline.c
@@ -1131,11 +1131,11 @@
11311131
char *zDate;
11321132
Blob sql;
11331133
int objid = 0;
11341134
Blob uuid;
11351135
int mode = 0 ; /* 0:none 1: before 2:after 3:children 4:parents */
1136
- db_find_and_open_repository(1);
1136
+ db_find_and_open_repository(0, 0);
11371137
zCount = find_option("count","n",1);
11381138
zType = find_option("type","t",1);
11391139
if( zCount ){
11401140
n = atoi(zCount);
11411141
}else{
11421142
--- src/timeline.c
+++ src/timeline.c
@@ -1131,11 +1131,11 @@
1131 char *zDate;
1132 Blob sql;
1133 int objid = 0;
1134 Blob uuid;
1135 int mode = 0 ; /* 0:none 1: before 2:after 3:children 4:parents */
1136 db_find_and_open_repository(1);
1137 zCount = find_option("count","n",1);
1138 zType = find_option("type","t",1);
1139 if( zCount ){
1140 n = atoi(zCount);
1141 }else{
1142
--- src/timeline.c
+++ src/timeline.c
@@ -1131,11 +1131,11 @@
1131 char *zDate;
1132 Blob sql;
1133 int objid = 0;
1134 Blob uuid;
1135 int mode = 0 ; /* 0:none 1: before 2:after 3:children 4:parents */
1136 db_find_and_open_repository(0, 0);
1137 zCount = find_option("count","n",1);
1138 zType = find_option("type","t",1);
1139 if( zCount ){
1140 n = atoi(zCount);
1141 }else{
1142
+1 -1
--- src/tkt.c
+++ src/tkt.c
@@ -903,11 +903,11 @@
903903
*/
904904
void ticket_cmd(void){
905905
int n;
906906
907907
/* do some ints, we want to be inside a checkout */
908
- db_find_and_open_repository(1);
908
+ db_find_and_open_repository(0, 0);
909909
user_select();
910910
/*
911911
** Check that the user exists.
912912
*/
913913
if( !db_exists("SELECT 1 FROM user WHERE login=%Q", g.zLogin) ){
914914
--- src/tkt.c
+++ src/tkt.c
@@ -903,11 +903,11 @@
903 */
904 void ticket_cmd(void){
905 int n;
906
907 /* do some ints, we want to be inside a checkout */
908 db_find_and_open_repository(1);
909 user_select();
910 /*
911 ** Check that the user exists.
912 */
913 if( !db_exists("SELECT 1 FROM user WHERE login=%Q", g.zLogin) ){
914
--- src/tkt.c
+++ src/tkt.c
@@ -903,11 +903,11 @@
903 */
904 void ticket_cmd(void){
905 int n;
906
907 /* do some ints, we want to be inside a checkout */
908 db_find_and_open_repository(0, 0);
909 user_select();
910 /*
911 ** Check that the user exists.
912 */
913 if( !db_exists("SELECT 1 FROM user WHERE login=%Q", g.zLogin) ){
914
+1 -1
--- src/user.c
+++ src/user.c
@@ -174,11 +174,11 @@
174174
**
175175
** Change the web access password for a user.
176176
*/
177177
void user_cmd(void){
178178
int n;
179
- db_find_and_open_repository(1);
179
+ db_find_and_open_repository(0, 0);
180180
if( g.argc<3 ){
181181
usage("capabilities|default|list|new|password ...");
182182
}
183183
n = strlen(g.argv[2]);
184184
if( n>=2 && strncmp(g.argv[2],"new",n)==0 ){
185185
--- src/user.c
+++ src/user.c
@@ -174,11 +174,11 @@
174 **
175 ** Change the web access password for a user.
176 */
177 void user_cmd(void){
178 int n;
179 db_find_and_open_repository(1);
180 if( g.argc<3 ){
181 usage("capabilities|default|list|new|password ...");
182 }
183 n = strlen(g.argv[2]);
184 if( n>=2 && strncmp(g.argv[2],"new",n)==0 ){
185
--- src/user.c
+++ src/user.c
@@ -174,11 +174,11 @@
174 **
175 ** Change the web access password for a user.
176 */
177 void user_cmd(void){
178 int n;
179 db_find_and_open_repository(0, 0);
180 if( g.argc<3 ){
181 usage("capabilities|default|list|new|password ...");
182 }
183 n = strlen(g.argv[2]);
184 if( n>=2 && strncmp(g.argv[2],"new",n)==0 ){
185
+1 -1
--- src/wiki.c
+++ src/wiki.c
@@ -880,11 +880,11 @@
880880
** Diffs the local copy of a page with a given version (defaulting
881881
** to the head version).
882882
*/
883883
void wiki_cmd(void){
884884
int n;
885
- db_find_and_open_repository(1);
885
+ db_find_and_open_repository(0, 0);
886886
if( g.argc<3 ){
887887
goto wiki_cmd_usage;
888888
}
889889
n = strlen(g.argv[2]);
890890
if( n==0 ){
891891
--- src/wiki.c
+++ src/wiki.c
@@ -880,11 +880,11 @@
880 ** Diffs the local copy of a page with a given version (defaulting
881 ** to the head version).
882 */
883 void wiki_cmd(void){
884 int n;
885 db_find_and_open_repository(1);
886 if( g.argc<3 ){
887 goto wiki_cmd_usage;
888 }
889 n = strlen(g.argv[2]);
890 if( n==0 ){
891
--- src/wiki.c
+++ src/wiki.c
@@ -880,11 +880,11 @@
880 ** Diffs the local copy of a page with a given version (defaulting
881 ** to the head version).
882 */
883 void wiki_cmd(void){
884 int n;
885 db_find_and_open_repository(0, 0);
886 if( g.argc<3 ){
887 goto wiki_cmd_usage;
888 }
889 n = strlen(g.argv[2]);
890 if( n==0 ){
891
+1 -1
--- src/zip.c
+++ src/zip.c
@@ -388,11 +388,11 @@
388388
void baseline_zip_cmd(void){
389389
int rid;
390390
Blob zip;
391391
const char *zName;
392392
zName = find_option("name", 0, 1);
393
- db_find_and_open_repository(1);
393
+ db_find_and_open_repository(0, 0);
394394
if( g.argc!=4 ){
395395
usage("VERSION OUTPUTFILE");
396396
}
397397
rid = name_to_rid(g.argv[2]);
398398
if( zName==0 ){
399399
--- src/zip.c
+++ src/zip.c
@@ -388,11 +388,11 @@
388 void baseline_zip_cmd(void){
389 int rid;
390 Blob zip;
391 const char *zName;
392 zName = find_option("name", 0, 1);
393 db_find_and_open_repository(1);
394 if( g.argc!=4 ){
395 usage("VERSION OUTPUTFILE");
396 }
397 rid = name_to_rid(g.argv[2]);
398 if( zName==0 ){
399
--- src/zip.c
+++ src/zip.c
@@ -388,11 +388,11 @@
388 void baseline_zip_cmd(void){
389 int rid;
390 Blob zip;
391 const char *zName;
392 zName = find_option("name", 0, 1);
393 db_find_and_open_repository(0, 0);
394 if( g.argc!=4 ){
395 usage("VERSION OUTPUTFILE");
396 }
397 rid = name_to_rid(g.argv[2]);
398 if( zName==0 ){
399

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button