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.

drh 2026-05-24 16:26 UTC trunk
Commit 6c2efda1a0119769b62a55bf9a0805b33b0e250f3fb1aaee13b83dc375ddae6a
1 file changed +23 -8
+23 -8
--- src/content.c
+++ src/content.c
@@ -701,24 +701,39 @@
701701
702702
703703
/*
704704
** COMMAND: test-content-put
705705
**
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:
707712
**
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
710715
*/
711716
void test_content_put_cmd(void){
712717
int rid;
713718
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);
716722
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);
720735
}
721736
722737
/*
723738
** Make sure the content at rid is the original content and is not a
724739
** delta.
725740
--- 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

Keyboard Shortcuts

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