Fossil SCM
Always show a listing of imported content on "fossil bundle import". Added the "fossil test-phantoms" command.
Commit
dd5635561a77e7f545d39e424e0066d3c74ca573
Parent
8d94eab98a742e6…
2 files changed
+3
+30
-9
+3
| --- src/bundle.c | ||
| +++ src/bundle.c | ||
| @@ -420,10 +420,11 @@ | ||
| 420 | 420 | fossil_fatal("%s", g.zErrMsg); |
| 421 | 421 | }else{ |
| 422 | 422 | if( !isPriv ) content_make_public(rid); |
| 423 | 423 | content_get(rid, &c1); |
| 424 | 424 | manifest_crosslink(rid, &c1, MC_NO_ERRORS); |
| 425 | + db_multi_exec("INSERT INTO got(rid) VALUES(%d)",rid); | |
| 425 | 426 | } |
| 426 | 427 | bundle_import_elements(db_column_int(&q,3), &c2, isPriv); |
| 427 | 428 | blob_reset(&c2); |
| 428 | 429 | } |
| 429 | 430 | db_finalize(&q); |
| @@ -562,14 +563,16 @@ | ||
| 562 | 563 | " SELECT blobid," |
| 563 | 564 | " CASE WHEN typeof(delta)=='integer'" |
| 564 | 565 | " THEN delta ELSE 0 END" |
| 565 | 566 | " FROM bblob" |
| 566 | 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);" | |
| 567 | 569 | ); |
| 568 | 570 | manifest_crosslink_begin(); |
| 569 | 571 | bundle_import_elements(0, 0, isPriv); |
| 570 | 572 | manifest_crosslink_end(0); |
| 573 | + describe_artifacts_to_stdout("IN got", "Imported content:"); | |
| 571 | 574 | db_end_transaction(0); |
| 572 | 575 | } |
| 573 | 576 | |
| 574 | 577 | /* fossil bundle purge BUNDLE |
| 575 | 578 | ** |
| 576 | 579 |
| --- 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 @@ | ||
| 785 | 785 | /* |
| 786 | 786 | ** Schema for the description table |
| 787 | 787 | */ |
| 788 | 788 | static const char zDescTab[] = |
| 789 | 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 | |
| 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 | |
| 795 | 796 | @ ); |
| 796 | 797 | ; |
| 797 | 798 | |
| 798 | 799 | /* |
| 799 | 800 | ** Create the description table if it does not already exists. |
| @@ -901,14 +902,20 @@ | ||
| 901 | 902 | ); |
| 902 | 903 | |
| 903 | 904 | /* Everything else */ |
| 904 | 905 | db_multi_exec( |
| 905 | 906 | "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" | |
| 907 | 909 | " FROM blob WHERE blob.rid %s;", |
| 908 | 910 | zWhere /*safe-for-%s*/ |
| 909 | 911 | ); |
| 912 | + | |
| 913 | + /* Mark private elements */ | |
| 914 | + db_multi_exec( | |
| 915 | + "UPDATE description SET isPrivate=1 WHERE rid IN private" | |
| 916 | + ); | |
| 910 | 917 | } |
| 911 | 918 | |
| 912 | 919 | /* |
| 913 | 920 | ** Print the content of the description table on stdout |
| 914 | 921 | */ |
| @@ -915,19 +922,21 @@ | ||
| 915 | 922 | int describe_artifacts_to_stdout(const char *zWhere, const char *zLabel){ |
| 916 | 923 | Stmt q; |
| 917 | 924 | int cnt = 0; |
| 918 | 925 | describe_artifacts(zWhere); |
| 919 | 926 | db_prepare(&q, |
| 920 | - "SELECT rid, uuid, datetime(ctime,'localtime'), type, detail\n" | |
| 927 | + "SELECT rid, uuid, datetime(ctime,'localtime'), type, detail, isPrivate\n" | |
| 921 | 928 | " FROM description\n" |
| 922 | 929 | " ORDER BY rid;" |
| 923 | 930 | ); |
| 924 | 931 | while( db_step(&q)==SQLITE_ROW ){ |
| 925 | 932 | const char *zType = db_column_text(&q,3); |
| 933 | + const char *zPrivate = db_column_int(&q,5) ? "(U) " : ""; | |
| 926 | 934 | 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)); | |
| 929 | 938 | if( db_column_bytes(&q,4)>0 ){ |
| 930 | 939 | fossil_print(" %s", db_column_text(&q,4)); |
| 931 | 940 | } |
| 932 | 941 | if( db_column_bytes(&q,2)>0 |
| 933 | 942 | && fossil_strcmp(zType,"checkin")==0 |
| @@ -975,5 +984,17 @@ | ||
| 975 | 984 | */ |
| 976 | 985 | void test_unclusterd_cmd(void){ |
| 977 | 986 | db_find_and_open_repository(0,0); |
| 978 | 987 | describe_artifacts_to_stdout("IN unclustered", 0); |
| 979 | 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 | +} | |
| 980 | 1001 |
| --- 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 |