Fossil SCM

Added the test-unsent and test-unclustered commands. Further integration of the describe_artifacts() utility. Fixes to "fossil bundle purge".

drh 2014-11-29 00:20 UTC DBP-workflow
Commit 79ce83dc90ffcdd51608aa4d235d2bf2ee18992a
3 files changed +26 -56 +32 -4 +2 -2
+26 -56
--- src/bundle.c
+++ src/bundle.c
@@ -226,11 +226,11 @@
226226
db_begin_transaction();
227227
db_multi_exec("CREATE TEMP TABLE tobundle(rid INTEGER PRIMARY KEY);");
228228
subtree_from_arguments("tobundle");
229229
verify_all_options();
230230
if( bAll ) find_checkin_associates("tobundle",bExcl);
231
- describe_artifacts_to_stdout("IN tobundle");
231
+ describe_artifacts_to_stdout("IN tobundle", 0);
232232
db_end_transaction(1);
233233
}
234234
235235
/* fossil bundle export BUNDLE ?OPTIONS?
236236
**
@@ -590,11 +590,11 @@
590590
db_begin_transaction();
591591
592592
/* Find all checkins of the bundle */
593593
db_multi_exec(
594594
"CREATE TEMP TABLE ok(rid INTEGER PRIMARY KEY);"
595
- "INSERT INTO ok SELECT blob.rid FROM bblob, blob, plink"
595
+ "INSERT OR IGNORE INTO ok SELECT blob.rid FROM bblob, blob, plink"
596596
" WHERE bblob.uuid=blob.uuid"
597597
" AND plink.cid=blob.rid;"
598598
);
599599
600600
/* Check to see if new checkins have been committed to checkins in
@@ -624,71 +624,41 @@
624624
625625
/* Check to see if any associated files are not in the bundle. Issue
626626
** an error if there are any, unless --force is used.
627627
*/
628628
if( !bForce ){
629
- Stmt q;
630
- int n = 0;
631
- db_prepare(&q,
632
- "SELECT rid FROM ok, blob"
633
- " WHERE blob.rid=ok.rid"
634
- " AND blob.uuid NOT IN (SELECT uuid FROM bblob)"
629
+ db_multi_exec(
630
+ "CREATE TEMP TABLE err1(rid INTEGER PRIMARY KEY);"
631
+ "INSERT INTO err1 "
632
+ " SELECT blob.rid FROM ok CROSS JOIN blob"
633
+ " WHERE blob.rid=ok.rid"
634
+ " AND blob.uuid NOT IN (SELECT uuid FROM bblob);"
635635
);
636
- while( db_step(&q)==SQLITE_OK ){
637
- whatis_rid(db_column_int(&q,0),0);
638
- fossil_print("%.78c\n", '-');
639
- n++;
640
- }
641
- if( n>0 ){
636
+ if( db_changes() ){
637
+ describe_artifacts_to_stdout("IN err1", 0);
642638
fossil_fatal("artifacts above associated with bundle checkins "
643639
" are not in the bundle");
640
+ }else{
641
+ db_multi_exec("DROP TABLE err1;");
644642
}
645643
}
646644
647645
if( bTest ){
648
- const char *zBanner = "Artifacts purged that are found in %s:\n";
649
- Stmt q;
650
- db_prepare(&q,"SELECT blob.uuid FROM ok, blob, bblob"
651
- " WHERE blob.rid=ok.rid AND blob.uuid=bblob.uuid"
652
- " ORDER BY 1"
653
- );
654
- while( db_step(&q)==SQLITE_ROW ){
655
- if( zBanner ){
656
- fossil_print(zBanner/*works-like:"%s"*/,zFile);
657
- zBanner = 0;
658
- }
659
- fossil_print(" %s\n", db_column_text(&q,0));
660
- }
661
- db_finalize(&q);
662
- zBanner = "Artifacts purged that are NOT found in %s:\n";
663
- db_prepare(&q,"SELECT blob.uuid FROM ok, blob"
664
- " WHERE blob.rid=ok.rid"
665
- " AND blob.uuid NOT IN (SELECT uuid FROM bblob)"
666
- " ORDER BY 1"
667
- );
668
- while( db_step(&q)==SQLITE_ROW ){
669
- if( zBanner ){
670
- fossil_print(zBanner/*works-like:"%s"*/,zFile);
671
- zBanner = 0;
672
- }
673
- fossil_print(" %s\n", db_column_text(&q,0));
674
- }
675
- db_finalize(&q);
676
- zBanner = "Artifacts in %s that are not purged:\n";
677
- db_prepare(&q,"SELECT bblob.uuid FROM bblob, blob"
678
- " WHERE blob.uuid=bblob.uuid"
679
- " AND blob.rid NOT IN ok"
680
- " ORDER BY 1"
681
- );
682
- while( db_step(&q)==SQLITE_ROW ){
683
- if( zBanner ){
684
- fossil_print(zBanner/*works-like:"%s"*/,zFile);
685
- zBanner = 0;
686
- }
687
- fossil_print(" %s\n", db_column_text(&q,0));
688
- }
689
- db_finalize(&q);
646
+ describe_artifacts_to_stdout(
647
+ "IN (SELECT blob.rid FROM ok, blob, bblob"
648
+ " WHERE blob.rid=ok.rid AND blob.uuid=bblob.uuid)",
649
+ "Purged artifacts found in the bundle:");
650
+ describe_artifacts_to_stdout(
651
+ "IN (SELECT blob.rid FROM ok, blob"
652
+ " WHERE blob.rid=ok.rid "
653
+ " AND blob.uuid NOT IN (SELECT uuid FROM bblob))",
654
+ "Purged artifacts NOT in the bundle:");
655
+ describe_artifacts_to_stdout(
656
+ "IN (SELECT blob.rid FROM bblob, blob"
657
+ " WHERE blob.uuid=bblob.uuid "
658
+ " AND blob.rid NOT IN ok)",
659
+ "Artifacts in the bundle but not purged:");
690660
}else{
691661
purge_artifact_list("ok",0,0);
692662
}
693663
db_end_transaction(0);
694664
}
695665
--- src/bundle.c
+++ src/bundle.c
@@ -226,11 +226,11 @@
226 db_begin_transaction();
227 db_multi_exec("CREATE TEMP TABLE tobundle(rid INTEGER PRIMARY KEY);");
228 subtree_from_arguments("tobundle");
229 verify_all_options();
230 if( bAll ) find_checkin_associates("tobundle",bExcl);
231 describe_artifacts_to_stdout("IN tobundle");
232 db_end_transaction(1);
233 }
234
235 /* fossil bundle export BUNDLE ?OPTIONS?
236 **
@@ -590,11 +590,11 @@
590 db_begin_transaction();
591
592 /* Find all checkins of the bundle */
593 db_multi_exec(
594 "CREATE TEMP TABLE ok(rid INTEGER PRIMARY KEY);"
595 "INSERT INTO ok SELECT blob.rid FROM bblob, blob, plink"
596 " WHERE bblob.uuid=blob.uuid"
597 " AND plink.cid=blob.rid;"
598 );
599
600 /* Check to see if new checkins have been committed to checkins in
@@ -624,71 +624,41 @@
624
625 /* Check to see if any associated files are not in the bundle. Issue
626 ** an error if there are any, unless --force is used.
627 */
628 if( !bForce ){
629 Stmt q;
630 int n = 0;
631 db_prepare(&q,
632 "SELECT rid FROM ok, blob"
633 " WHERE blob.rid=ok.rid"
634 " AND blob.uuid NOT IN (SELECT uuid FROM bblob)"
635 );
636 while( db_step(&q)==SQLITE_OK ){
637 whatis_rid(db_column_int(&q,0),0);
638 fossil_print("%.78c\n", '-');
639 n++;
640 }
641 if( n>0 ){
642 fossil_fatal("artifacts above associated with bundle checkins "
643 " are not in the bundle");
 
 
644 }
645 }
646
647 if( bTest ){
648 const char *zBanner = "Artifacts purged that are found in %s:\n";
649 Stmt q;
650 db_prepare(&q,"SELECT blob.uuid FROM ok, blob, bblob"
651 " WHERE blob.rid=ok.rid AND blob.uuid=bblob.uuid"
652 " ORDER BY 1"
653 );
654 while( db_step(&q)==SQLITE_ROW ){
655 if( zBanner ){
656 fossil_print(zBanner/*works-like:"%s"*/,zFile);
657 zBanner = 0;
658 }
659 fossil_print(" %s\n", db_column_text(&q,0));
660 }
661 db_finalize(&q);
662 zBanner = "Artifacts purged that are NOT found in %s:\n";
663 db_prepare(&q,"SELECT blob.uuid FROM ok, blob"
664 " WHERE blob.rid=ok.rid"
665 " AND blob.uuid NOT IN (SELECT uuid FROM bblob)"
666 " ORDER BY 1"
667 );
668 while( db_step(&q)==SQLITE_ROW ){
669 if( zBanner ){
670 fossil_print(zBanner/*works-like:"%s"*/,zFile);
671 zBanner = 0;
672 }
673 fossil_print(" %s\n", db_column_text(&q,0));
674 }
675 db_finalize(&q);
676 zBanner = "Artifacts in %s that are not purged:\n";
677 db_prepare(&q,"SELECT bblob.uuid FROM bblob, blob"
678 " WHERE blob.uuid=bblob.uuid"
679 " AND blob.rid NOT IN ok"
680 " ORDER BY 1"
681 );
682 while( db_step(&q)==SQLITE_ROW ){
683 if( zBanner ){
684 fossil_print(zBanner/*works-like:"%s"*/,zFile);
685 zBanner = 0;
686 }
687 fossil_print(" %s\n", db_column_text(&q,0));
688 }
689 db_finalize(&q);
690 }else{
691 purge_artifact_list("ok",0,0);
692 }
693 db_end_transaction(0);
694 }
695
--- src/bundle.c
+++ src/bundle.c
@@ -226,11 +226,11 @@
226 db_begin_transaction();
227 db_multi_exec("CREATE TEMP TABLE tobundle(rid INTEGER PRIMARY KEY);");
228 subtree_from_arguments("tobundle");
229 verify_all_options();
230 if( bAll ) find_checkin_associates("tobundle",bExcl);
231 describe_artifacts_to_stdout("IN tobundle", 0);
232 db_end_transaction(1);
233 }
234
235 /* fossil bundle export BUNDLE ?OPTIONS?
236 **
@@ -590,11 +590,11 @@
590 db_begin_transaction();
591
592 /* Find all checkins of the bundle */
593 db_multi_exec(
594 "CREATE TEMP TABLE ok(rid INTEGER PRIMARY KEY);"
595 "INSERT OR IGNORE INTO ok SELECT blob.rid FROM bblob, blob, plink"
596 " WHERE bblob.uuid=blob.uuid"
597 " AND plink.cid=blob.rid;"
598 );
599
600 /* Check to see if new checkins have been committed to checkins in
@@ -624,71 +624,41 @@
624
625 /* Check to see if any associated files are not in the bundle. Issue
626 ** an error if there are any, unless --force is used.
627 */
628 if( !bForce ){
629 db_multi_exec(
630 "CREATE TEMP TABLE err1(rid INTEGER PRIMARY KEY);"
631 "INSERT INTO err1 "
632 " SELECT blob.rid FROM ok CROSS JOIN blob"
633 " WHERE blob.rid=ok.rid"
634 " AND blob.uuid NOT IN (SELECT uuid FROM bblob);"
635 );
636 if( db_changes() ){
637 describe_artifacts_to_stdout("IN err1", 0);
 
 
 
 
638 fossil_fatal("artifacts above associated with bundle checkins "
639 " are not in the bundle");
640 }else{
641 db_multi_exec("DROP TABLE err1;");
642 }
643 }
644
645 if( bTest ){
646 describe_artifacts_to_stdout(
647 "IN (SELECT blob.rid FROM ok, blob, bblob"
648 " WHERE blob.rid=ok.rid AND blob.uuid=bblob.uuid)",
649 "Purged artifacts found in the bundle:");
650 describe_artifacts_to_stdout(
651 "IN (SELECT blob.rid FROM ok, blob"
652 " WHERE blob.rid=ok.rid "
653 " AND blob.uuid NOT IN (SELECT uuid FROM bblob))",
654 "Purged artifacts NOT in the bundle:");
655 describe_artifacts_to_stdout(
656 "IN (SELECT blob.rid FROM bblob, blob"
657 " WHERE blob.uuid=bblob.uuid "
658 " AND blob.rid NOT IN ok)",
659 "Artifacts in the bundle but not purged:");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
660 }else{
661 purge_artifact_list("ok",0,0);
662 }
663 db_end_transaction(0);
664 }
665
+32 -4
--- src/name.c
+++ src/name.c
@@ -901,29 +901,31 @@
901901
);
902902
903903
/* Everything else */
904904
db_multi_exec(
905905
"INSERT OR IGNORE INTO description(rid,uuid,type)\n"
906
- "SELECT blob.rid, blob.uuid, 'unknown'\n"
906
+ "SELECT blob.rid, blob.uuid, ''\n"
907907
" FROM blob WHERE blob.rid %s;",
908908
zWhere /*safe-for-%s*/
909909
);
910910
}
911911
912912
/*
913913
** Print the content of the description table on stdout
914914
*/
915
-void describe_artifacts_to_stdout(const char *zWhere){
915
+int describe_artifacts_to_stdout(const char *zWhere, const char *zLabel){
916916
Stmt q;
917
+ int cnt = 0;
917918
describe_artifacts(zWhere);
918919
db_prepare(&q,
919920
"SELECT rid, uuid, datetime(ctime,'localtime'), type, detail\n"
920921
" FROM description\n"
921922
" ORDER BY rid;"
922923
);
923924
while( db_step(&q)==SQLITE_ROW ){
924925
const char *zType = db_column_text(&q,3);
926
+ if( zLabel ){ fossil_print("%s\n", zLabel); zLabel = 0; }
925927
fossil_print("%6d %.16s %s", db_column_int(&q,0),
926928
db_column_text(&q,1), db_column_text(&q,3));
927929
if( db_column_bytes(&q,4)>0 ){
928930
fossil_print(" %s", db_column_text(&q,4));
929931
}
@@ -931,13 +933,15 @@
931933
&& fossil_strcmp(zType,"checkin")==0
932934
){
933935
fossil_print(" %s", db_column_text(&q,2));
934936
}
935937
fossil_print("\n");
938
+ cnt++;
936939
}
937940
db_finalize(&q);
938
-
941
+ db_multi_exec("DELETE FROM description;");
942
+ return cnt;
939943
}
940944
941945
/*
942946
** COMMAND: test-describe-artifacts
943947
**
@@ -945,7 +949,31 @@
945949
**
946950
** Display a one-line description of every artifact.
947951
*/
948952
void test_describe_artifacts_cmd(void){
949953
db_find_and_open_repository(0,0);
950
- describe_artifacts_to_stdout("IN (SELECT rid FROM blob)");
954
+ describe_artifacts_to_stdout("IN (SELECT rid FROM blob)", 0);
955
+}
956
+
957
+/*
958
+** COMMAND: test-unsent
959
+**
960
+** Usage: %fossil test-unsent
961
+**
962
+** Show all artifacts in the unsent table
963
+*/
964
+void test_unsent_cmd(void){
965
+ db_find_and_open_repository(0,0);
966
+ describe_artifacts_to_stdout("IN unsent", 0);
967
+}
968
+
969
+/*
970
+** COMMAND: test-unclustered
971
+**
972
+** Usage: %fossil test-unclustered
973
+**
974
+** Show all artifacts in the unclustered table
975
+*/
976
+void test_unclusterd_cmd(void){
977
+ db_find_and_open_repository(0,0);
978
+ describe_artifacts_to_stdout("IN unclustered", 0);
951979
}
952980
--- src/name.c
+++ src/name.c
@@ -901,29 +901,31 @@
901 );
902
903 /* Everything else */
904 db_multi_exec(
905 "INSERT OR IGNORE INTO description(rid,uuid,type)\n"
906 "SELECT blob.rid, blob.uuid, 'unknown'\n"
907 " FROM blob WHERE blob.rid %s;",
908 zWhere /*safe-for-%s*/
909 );
910 }
911
912 /*
913 ** Print the content of the description table on stdout
914 */
915 void describe_artifacts_to_stdout(const char *zWhere){
916 Stmt q;
 
917 describe_artifacts(zWhere);
918 db_prepare(&q,
919 "SELECT rid, uuid, datetime(ctime,'localtime'), type, detail\n"
920 " FROM description\n"
921 " ORDER BY rid;"
922 );
923 while( db_step(&q)==SQLITE_ROW ){
924 const char *zType = db_column_text(&q,3);
 
925 fossil_print("%6d %.16s %s", db_column_int(&q,0),
926 db_column_text(&q,1), db_column_text(&q,3));
927 if( db_column_bytes(&q,4)>0 ){
928 fossil_print(" %s", db_column_text(&q,4));
929 }
@@ -931,13 +933,15 @@
931 && fossil_strcmp(zType,"checkin")==0
932 ){
933 fossil_print(" %s", db_column_text(&q,2));
934 }
935 fossil_print("\n");
 
936 }
937 db_finalize(&q);
938
 
939 }
940
941 /*
942 ** COMMAND: test-describe-artifacts
943 **
@@ -945,7 +949,31 @@
945 **
946 ** Display a one-line description of every artifact.
947 */
948 void test_describe_artifacts_cmd(void){
949 db_find_and_open_repository(0,0);
950 describe_artifacts_to_stdout("IN (SELECT rid FROM blob)");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
951 }
952
--- src/name.c
+++ src/name.c
@@ -901,29 +901,31 @@
901 );
902
903 /* Everything else */
904 db_multi_exec(
905 "INSERT OR IGNORE INTO description(rid,uuid,type)\n"
906 "SELECT blob.rid, blob.uuid, ''\n"
907 " FROM blob WHERE blob.rid %s;",
908 zWhere /*safe-for-%s*/
909 );
910 }
911
912 /*
913 ** Print the content of the description table on stdout
914 */
915 int describe_artifacts_to_stdout(const char *zWhere, const char *zLabel){
916 Stmt q;
917 int cnt = 0;
918 describe_artifacts(zWhere);
919 db_prepare(&q,
920 "SELECT rid, uuid, datetime(ctime,'localtime'), type, detail\n"
921 " FROM description\n"
922 " ORDER BY rid;"
923 );
924 while( db_step(&q)==SQLITE_ROW ){
925 const char *zType = db_column_text(&q,3);
926 if( zLabel ){ fossil_print("%s\n", zLabel); zLabel = 0; }
927 fossil_print("%6d %.16s %s", db_column_int(&q,0),
928 db_column_text(&q,1), db_column_text(&q,3));
929 if( db_column_bytes(&q,4)>0 ){
930 fossil_print(" %s", db_column_text(&q,4));
931 }
@@ -931,13 +933,15 @@
933 && fossil_strcmp(zType,"checkin")==0
934 ){
935 fossil_print(" %s", db_column_text(&q,2));
936 }
937 fossil_print("\n");
938 cnt++;
939 }
940 db_finalize(&q);
941 db_multi_exec("DELETE FROM description;");
942 return cnt;
943 }
944
945 /*
946 ** COMMAND: test-describe-artifacts
947 **
@@ -945,7 +949,31 @@
949 **
950 ** Display a one-line description of every artifact.
951 */
952 void test_describe_artifacts_cmd(void){
953 db_find_and_open_repository(0,0);
954 describe_artifacts_to_stdout("IN (SELECT rid FROM blob)", 0);
955 }
956
957 /*
958 ** COMMAND: test-unsent
959 **
960 ** Usage: %fossil test-unsent
961 **
962 ** Show all artifacts in the unsent table
963 */
964 void test_unsent_cmd(void){
965 db_find_and_open_repository(0,0);
966 describe_artifacts_to_stdout("IN unsent", 0);
967 }
968
969 /*
970 ** COMMAND: test-unclustered
971 **
972 ** Usage: %fossil test-unclustered
973 **
974 ** Show all artifacts in the unclustered table
975 */
976 void test_unclusterd_cmd(void){
977 db_find_and_open_repository(0,0);
978 describe_artifacts_to_stdout("IN unclustered", 0);
979 }
980
+2 -2
--- src/purge.c
+++ src/purge.c
@@ -179,11 +179,11 @@
179179
db_prepare(&q, "SELECT tkt_uuid FROM \"%w_tickets\"", zTab);
180180
while( db_step(&q)==SQLITE_ROW ){
181181
ticket_rebuild_entry(db_column_text(&q, 0));
182182
}
183183
db_finalize(&q);
184
- db_multi_exec("DROP TABLE \"%w_tickets\"", zTab);
184
+ /* db_multi_exec("DROP TABLE \"%w_tickets\"", zTab); */
185185
186186
/* Mission accomplished */
187187
db_end_transaction(0);
188188
return peid;
189189
}
@@ -567,15 +567,15 @@
567567
}
568568
nCkin = db_int(0, "SELECT count(*) FROM ok");
569569
find_checkin_associates("ok", 1);
570570
nArtifact = db_int(0, "SELECT count(*) FROM ok");
571571
if( explainOnly ){
572
- describe_artifacts_to_stdout("IN ok");
572
+ describe_artifacts_to_stdout("IN ok", 0);
573573
}else{
574574
int peid = purge_artifact_list("ok","",1);
575575
fossil_print("%d checkins and %d artifacts purged.\n", nCkin, nArtifact);
576576
fossil_print("undoable using \"%s purge undo %d\".\n",
577577
g.nameOfExe, peid);
578578
}
579579
db_end_transaction(explainOnly||dryRun);
580580
}
581581
}
582582
--- src/purge.c
+++ src/purge.c
@@ -179,11 +179,11 @@
179 db_prepare(&q, "SELECT tkt_uuid FROM \"%w_tickets\"", zTab);
180 while( db_step(&q)==SQLITE_ROW ){
181 ticket_rebuild_entry(db_column_text(&q, 0));
182 }
183 db_finalize(&q);
184 db_multi_exec("DROP TABLE \"%w_tickets\"", zTab);
185
186 /* Mission accomplished */
187 db_end_transaction(0);
188 return peid;
189 }
@@ -567,15 +567,15 @@
567 }
568 nCkin = db_int(0, "SELECT count(*) FROM ok");
569 find_checkin_associates("ok", 1);
570 nArtifact = db_int(0, "SELECT count(*) FROM ok");
571 if( explainOnly ){
572 describe_artifacts_to_stdout("IN ok");
573 }else{
574 int peid = purge_artifact_list("ok","",1);
575 fossil_print("%d checkins and %d artifacts purged.\n", nCkin, nArtifact);
576 fossil_print("undoable using \"%s purge undo %d\".\n",
577 g.nameOfExe, peid);
578 }
579 db_end_transaction(explainOnly||dryRun);
580 }
581 }
582
--- src/purge.c
+++ src/purge.c
@@ -179,11 +179,11 @@
179 db_prepare(&q, "SELECT tkt_uuid FROM \"%w_tickets\"", zTab);
180 while( db_step(&q)==SQLITE_ROW ){
181 ticket_rebuild_entry(db_column_text(&q, 0));
182 }
183 db_finalize(&q);
184 /* db_multi_exec("DROP TABLE \"%w_tickets\"", zTab); */
185
186 /* Mission accomplished */
187 db_end_transaction(0);
188 return peid;
189 }
@@ -567,15 +567,15 @@
567 }
568 nCkin = db_int(0, "SELECT count(*) FROM ok");
569 find_checkin_associates("ok", 1);
570 nArtifact = db_int(0, "SELECT count(*) FROM ok");
571 if( explainOnly ){
572 describe_artifacts_to_stdout("IN ok", 0);
573 }else{
574 int peid = purge_artifact_list("ok","",1);
575 fossil_print("%d checkins and %d artifacts purged.\n", nCkin, nArtifact);
576 fossil_print("undoable using \"%s purge undo %d\".\n",
577 g.nameOfExe, peid);
578 }
579 db_end_transaction(explainOnly||dryRun);
580 }
581 }
582

Keyboard Shortcuts

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