Fossil SCM
Enhance the test-content-put command to support the --moderate option and to be able to specify a repository using -R and to support inserting multiple artifacts all at once.
Commit
6c2efda1a0119769b62a55bf9a0805b33b0e250f3fb1aaee13b83dc375ddae6a
Parent
86d07e8a7448009…
1 file changed
+23
-8
+23
-8
| --- src/content.c | ||
| +++ src/content.c | ||
| @@ -701,24 +701,39 @@ | ||
| 701 | 701 | |
| 702 | 702 | |
| 703 | 703 | /* |
| 704 | 704 | ** COMMAND: test-content-put |
| 705 | 705 | ** |
| 706 | -** Usage: %fossil test-content-put FILE | |
| 706 | +** Usage: %fossil test-content-put [OPTIONS] FILE ... | |
| 707 | +** | |
| 708 | +** Read the content of all FILE argments and add them to the Blob | |
| 709 | +** table as a new artifact using a direct call to content_put(). | |
| 710 | +** | |
| 711 | +** Options: | |
| 707 | 712 | ** |
| 708 | -** Read the content of FILE and add it to the Blob table as a new | |
| 709 | -** artifact using a direct call to content_put(). | |
| 713 | +** --moderate Make corresponding entries to the MODREQ table | |
| 714 | +** -R REPO Add the content to repository file REPO | |
| 710 | 715 | */ |
| 711 | 716 | void test_content_put_cmd(void){ |
| 712 | 717 | int rid; |
| 713 | 718 | Blob content; |
| 714 | - if( g.argc!=3 ) usage("FILENAME"); | |
| 715 | - db_must_be_within_tree(); | |
| 719 | + int i; | |
| 720 | + int bModreq = find_option("moderate",0,0)!=0; | |
| 721 | + db_find_and_open_repository(0,0); | |
| 716 | 722 | user_select(); |
| 717 | - blob_read_from_file(&content, g.argv[2], ExtFILE); | |
| 718 | - rid = content_put(&content); | |
| 719 | - fossil_print("inserted as record %d\n", rid); | |
| 723 | + verify_all_options(); | |
| 724 | + db_begin_transaction(); | |
| 725 | + if( bModreq ) moderation_table_create(); | |
| 726 | + for(i=2; i<g.argc; i++){ | |
| 727 | + blob_read_from_file(&content, g.argv[i], ExtFILE); | |
| 728 | + rid = content_put(&content); | |
| 729 | + if( bModreq ){ | |
| 730 | + db_multi_exec("INSERT INTO modreq(objid) VALUES(%d)",rid); | |
| 731 | + } | |
| 732 | + fossil_print("inserted as record %d\n", rid); | |
| 733 | + } | |
| 734 | + db_end_transaction(0); | |
| 720 | 735 | } |
| 721 | 736 | |
| 722 | 737 | /* |
| 723 | 738 | ** Make sure the content at rid is the original content and is not a |
| 724 | 739 | ** delta. |
| 725 | 740 |
| --- src/content.c | |
| +++ src/content.c | |
| @@ -701,24 +701,39 @@ | |
| 701 | |
| 702 | |
| 703 | /* |
| 704 | ** COMMAND: test-content-put |
| 705 | ** |
| 706 | ** Usage: %fossil test-content-put FILE |
| 707 | ** |
| 708 | ** Read the content of FILE and add it to the Blob table as a new |
| 709 | ** artifact using a direct call to content_put(). |
| 710 | */ |
| 711 | void test_content_put_cmd(void){ |
| 712 | int rid; |
| 713 | Blob content; |
| 714 | if( g.argc!=3 ) usage("FILENAME"); |
| 715 | db_must_be_within_tree(); |
| 716 | user_select(); |
| 717 | blob_read_from_file(&content, g.argv[2], ExtFILE); |
| 718 | rid = content_put(&content); |
| 719 | fossil_print("inserted as record %d\n", rid); |
| 720 | } |
| 721 | |
| 722 | /* |
| 723 | ** Make sure the content at rid is the original content and is not a |
| 724 | ** delta. |
| 725 |
| --- src/content.c | |
| +++ src/content.c | |
| @@ -701,24 +701,39 @@ | |
| 701 | |
| 702 | |
| 703 | /* |
| 704 | ** COMMAND: test-content-put |
| 705 | ** |
| 706 | ** Usage: %fossil test-content-put [OPTIONS] FILE ... |
| 707 | ** |
| 708 | ** Read the content of all FILE argments and add them to the Blob |
| 709 | ** table as a new artifact using a direct call to content_put(). |
| 710 | ** |
| 711 | ** Options: |
| 712 | ** |
| 713 | ** --moderate Make corresponding entries to the MODREQ table |
| 714 | ** -R REPO Add the content to repository file REPO |
| 715 | */ |
| 716 | void test_content_put_cmd(void){ |
| 717 | int rid; |
| 718 | Blob content; |
| 719 | int i; |
| 720 | int bModreq = find_option("moderate",0,0)!=0; |
| 721 | db_find_and_open_repository(0,0); |
| 722 | user_select(); |
| 723 | verify_all_options(); |
| 724 | db_begin_transaction(); |
| 725 | if( bModreq ) moderation_table_create(); |
| 726 | for(i=2; i<g.argc; i++){ |
| 727 | blob_read_from_file(&content, g.argv[i], ExtFILE); |
| 728 | rid = content_put(&content); |
| 729 | if( bModreq ){ |
| 730 | db_multi_exec("INSERT INTO modreq(objid) VALUES(%d)",rid); |
| 731 | } |
| 732 | fossil_print("inserted as record %d\n", rid); |
| 733 | } |
| 734 | db_end_transaction(0); |
| 735 | } |
| 736 | |
| 737 | /* |
| 738 | ** Make sure the content at rid is the original content and is not a |
| 739 | ** delta. |
| 740 |