Fossil SCM

Always show a listing of imported content on "fossil bundle import". Added the "fossil test-phantoms" command.

drh 2014-11-29 14:16 UTC DBP-workflow
Commit dd5635561a77e7f545d39e424e0066d3c74ca573
2 files changed +3 +30 -9
--- src/bundle.c
+++ src/bundle.c
@@ -420,10 +420,11 @@
420420
fossil_fatal("%s", g.zErrMsg);
421421
}else{
422422
if( !isPriv ) content_make_public(rid);
423423
content_get(rid, &c1);
424424
manifest_crosslink(rid, &c1, MC_NO_ERRORS);
425
+ db_multi_exec("INSERT INTO got(rid) VALUES(%d)",rid);
425426
}
426427
bundle_import_elements(db_column_int(&q,3), &c2, isPriv);
427428
blob_reset(&c2);
428429
}
429430
db_finalize(&q);
@@ -562,14 +563,16 @@
562563
" SELECT blobid,"
563564
" CASE WHEN typeof(delta)=='integer'"
564565
" THEN delta ELSE 0 END"
565566
" FROM bblob"
566567
" WHERE NOT EXISTS(SELECT 1 FROM blob WHERE uuid=bblob.uuid AND size>=0);"
568
+ "CREATE TEMP TABLE got(rid INTEGER PRIMARY KEY ON CONFLICT IGNORE);"
567569
);
568570
manifest_crosslink_begin();
569571
bundle_import_elements(0, 0, isPriv);
570572
manifest_crosslink_end(0);
573
+ describe_artifacts_to_stdout("IN got", "Imported content:");
571574
db_end_transaction(0);
572575
}
573576
574577
/* fossil bundle purge BUNDLE
575578
**
576579
--- src/bundle.c
+++ src/bundle.c
@@ -420,10 +420,11 @@
420 fossil_fatal("%s", g.zErrMsg);
421 }else{
422 if( !isPriv ) content_make_public(rid);
423 content_get(rid, &c1);
424 manifest_crosslink(rid, &c1, MC_NO_ERRORS);
 
425 }
426 bundle_import_elements(db_column_int(&q,3), &c2, isPriv);
427 blob_reset(&c2);
428 }
429 db_finalize(&q);
@@ -562,14 +563,16 @@
562 " SELECT blobid,"
563 " CASE WHEN typeof(delta)=='integer'"
564 " THEN delta ELSE 0 END"
565 " FROM bblob"
566 " WHERE NOT EXISTS(SELECT 1 FROM blob WHERE uuid=bblob.uuid AND size>=0);"
 
567 );
568 manifest_crosslink_begin();
569 bundle_import_elements(0, 0, isPriv);
570 manifest_crosslink_end(0);
 
571 db_end_transaction(0);
572 }
573
574 /* fossil bundle purge BUNDLE
575 **
576
--- src/bundle.c
+++ src/bundle.c
@@ -420,10 +420,11 @@
420 fossil_fatal("%s", g.zErrMsg);
421 }else{
422 if( !isPriv ) content_make_public(rid);
423 content_get(rid, &c1);
424 manifest_crosslink(rid, &c1, MC_NO_ERRORS);
425 db_multi_exec("INSERT INTO got(rid) VALUES(%d)",rid);
426 }
427 bundle_import_elements(db_column_int(&q,3), &c2, isPriv);
428 blob_reset(&c2);
429 }
430 db_finalize(&q);
@@ -562,14 +563,16 @@
563 " SELECT blobid,"
564 " CASE WHEN typeof(delta)=='integer'"
565 " THEN delta ELSE 0 END"
566 " FROM bblob"
567 " WHERE NOT EXISTS(SELECT 1 FROM blob WHERE uuid=bblob.uuid AND size>=0);"
568 "CREATE TEMP TABLE got(rid INTEGER PRIMARY KEY ON CONFLICT IGNORE);"
569 );
570 manifest_crosslink_begin();
571 bundle_import_elements(0, 0, isPriv);
572 manifest_crosslink_end(0);
573 describe_artifacts_to_stdout("IN got", "Imported content:");
574 db_end_transaction(0);
575 }
576
577 /* fossil bundle purge BUNDLE
578 **
579
+30 -9
--- src/name.c
+++ src/name.c
@@ -785,15 +785,16 @@
785785
/*
786786
** Schema for the description table
787787
*/
788788
static const char zDescTab[] =
789789
@ CREATE TEMP TABLE IF NOT EXISTS description(
790
-@ rid INTEGER PRIMARY KEY,
791
-@ uuid TEXT, -- SHA1 hash of the object
792
-@ ctime DATETIME, -- Time of creation
793
-@ type TEXT, -- file, checkin, wiki, ticket-change, etc.
794
-@ detail TEXT -- filename, checkin comment, etc
790
+@ rid INTEGER PRIMARY KEY, -- RID of the object
791
+@ uuid TEXT, -- SHA1 hash of the object
792
+@ ctime DATETIME, -- Time of creation
793
+@ isPrivate BOOLEAN DEFAULT 0, -- True for unpublished artifacts
794
+@ type TEXT, -- file, checkin, wiki, ticket, etc.
795
+@ detail TEXT -- filename, checkin comment, etc
795796
@ );
796797
;
797798
798799
/*
799800
** Create the description table if it does not already exists.
@@ -901,14 +902,20 @@
901902
);
902903
903904
/* Everything else */
904905
db_multi_exec(
905906
"INSERT OR IGNORE INTO description(rid,uuid,type)\n"
906
- "SELECT blob.rid, blob.uuid, ''\n"
907
+ "SELECT blob.rid, blob.uuid,"
908
+ " CASE WHEN blob.size<0 THEN 'phantom' ELSE '' END\n"
907909
" FROM blob WHERE blob.rid %s;",
908910
zWhere /*safe-for-%s*/
909911
);
912
+
913
+ /* Mark private elements */
914
+ db_multi_exec(
915
+ "UPDATE description SET isPrivate=1 WHERE rid IN private"
916
+ );
910917
}
911918
912919
/*
913920
** Print the content of the description table on stdout
914921
*/
@@ -915,19 +922,21 @@
915922
int describe_artifacts_to_stdout(const char *zWhere, const char *zLabel){
916923
Stmt q;
917924
int cnt = 0;
918925
describe_artifacts(zWhere);
919926
db_prepare(&q,
920
- "SELECT rid, uuid, datetime(ctime,'localtime'), type, detail\n"
927
+ "SELECT rid, uuid, datetime(ctime,'localtime'), type, detail, isPrivate\n"
921928
" FROM description\n"
922929
" ORDER BY rid;"
923930
);
924931
while( db_step(&q)==SQLITE_ROW ){
925932
const char *zType = db_column_text(&q,3);
933
+ const char *zPrivate = db_column_int(&q,5) ? "(U) " : "";
926934
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));
935
+ fossil_print("%6d %.16s %s%s",
936
+ db_column_int(&q,0), db_column_text(&q,1), zPrivate,
937
+ db_column_text(&q,3));
929938
if( db_column_bytes(&q,4)>0 ){
930939
fossil_print(" %s", db_column_text(&q,4));
931940
}
932941
if( db_column_bytes(&q,2)>0
933942
&& fossil_strcmp(zType,"checkin")==0
@@ -975,5 +984,17 @@
975984
*/
976985
void test_unclusterd_cmd(void){
977986
db_find_and_open_repository(0,0);
978987
describe_artifacts_to_stdout("IN unclustered", 0);
979988
}
989
+
990
+/*
991
+** COMMAND: test-phantoms
992
+**
993
+** Usage: %fossil test-phantoms
994
+**
995
+** Show all phantom artifacts
996
+*/
997
+void test_phatoms_cmd(void){
998
+ db_find_and_open_repository(0,0);
999
+ describe_artifacts_to_stdout("IN (SELECT rid FROM blob WHERE size<0)", 0);
1000
+}
9801001
--- src/name.c
+++ src/name.c
@@ -785,15 +785,16 @@
785 /*
786 ** Schema for the description table
787 */
788 static const char zDescTab[] =
789 @ CREATE TEMP TABLE IF NOT EXISTS description(
790 @ rid INTEGER PRIMARY KEY,
791 @ uuid TEXT, -- SHA1 hash of the object
792 @ ctime DATETIME, -- Time of creation
793 @ type TEXT, -- file, checkin, wiki, ticket-change, etc.
794 @ detail TEXT -- filename, checkin comment, etc
 
795 @ );
796 ;
797
798 /*
799 ** Create the description table if it does not already exists.
@@ -901,14 +902,20 @@
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,19 +922,21 @@
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 }
932 if( db_column_bytes(&q,2)>0
933 && fossil_strcmp(zType,"checkin")==0
@@ -975,5 +984,17 @@
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
--- src/name.c
+++ src/name.c
@@ -785,15 +785,16 @@
785 /*
786 ** Schema for the description table
787 */
788 static const char zDescTab[] =
789 @ CREATE TEMP TABLE IF NOT EXISTS description(
790 @ rid INTEGER PRIMARY KEY, -- RID of the object
791 @ uuid TEXT, -- SHA1 hash of the object
792 @ ctime DATETIME, -- Time of creation
793 @ isPrivate BOOLEAN DEFAULT 0, -- True for unpublished artifacts
794 @ type TEXT, -- file, checkin, wiki, ticket, etc.
795 @ detail TEXT -- filename, checkin comment, etc
796 @ );
797 ;
798
799 /*
800 ** Create the description table if it does not already exists.
@@ -901,14 +902,20 @@
902 );
903
904 /* Everything else */
905 db_multi_exec(
906 "INSERT OR IGNORE INTO description(rid,uuid,type)\n"
907 "SELECT blob.rid, blob.uuid,"
908 " CASE WHEN blob.size<0 THEN 'phantom' ELSE '' END\n"
909 " FROM blob WHERE blob.rid %s;",
910 zWhere /*safe-for-%s*/
911 );
912
913 /* Mark private elements */
914 db_multi_exec(
915 "UPDATE description SET isPrivate=1 WHERE rid IN private"
916 );
917 }
918
919 /*
920 ** Print the content of the description table on stdout
921 */
@@ -915,19 +922,21 @@
922 int describe_artifacts_to_stdout(const char *zWhere, const char *zLabel){
923 Stmt q;
924 int cnt = 0;
925 describe_artifacts(zWhere);
926 db_prepare(&q,
927 "SELECT rid, uuid, datetime(ctime,'localtime'), type, detail, isPrivate\n"
928 " FROM description\n"
929 " ORDER BY rid;"
930 );
931 while( db_step(&q)==SQLITE_ROW ){
932 const char *zType = db_column_text(&q,3);
933 const char *zPrivate = db_column_int(&q,5) ? "(U) " : "";
934 if( zLabel ){ fossil_print("%s\n", zLabel); zLabel = 0; }
935 fossil_print("%6d %.16s %s%s",
936 db_column_int(&q,0), db_column_text(&q,1), zPrivate,
937 db_column_text(&q,3));
938 if( db_column_bytes(&q,4)>0 ){
939 fossil_print(" %s", db_column_text(&q,4));
940 }
941 if( db_column_bytes(&q,2)>0
942 && fossil_strcmp(zType,"checkin")==0
@@ -975,5 +984,17 @@
984 */
985 void test_unclusterd_cmd(void){
986 db_find_and_open_repository(0,0);
987 describe_artifacts_to_stdout("IN unclustered", 0);
988 }
989
990 /*
991 ** COMMAND: test-phantoms
992 **
993 ** Usage: %fossil test-phantoms
994 **
995 ** Show all phantom artifacts
996 */
997 void test_phatoms_cmd(void){
998 db_find_and_open_repository(0,0);
999 describe_artifacts_to_stdout("IN (SELECT rid FROM blob WHERE size<0)", 0);
1000 }
1001

Keyboard Shortcuts

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