Fossil SCM

Add a test command to invoke the manifest parser from the command-line on an arbitrary text file. For testing only.

drh 2008-11-09 13:21 trunk
Commit 55fc643edab6cbe5638fe2458bd07e46328c85ab
1 file changed +19 -41
+19 -41
--- src/manifest.c
+++ src/manifest.c
@@ -669,10 +669,29 @@
669669
/*fprintf(stderr, "Manifest error on line %i\n", lineNo);fflush(stderr);*/
670670
md5sum_init();
671671
manifest_clear(p);
672672
return 0;
673673
}
674
+
675
+/*
676
+** COMMAND: test-parse-manifest
677
+**
678
+** Usage: %fossil test-parse-manifest FILENAME
679
+**
680
+** Parse the manifest and discarded. Use for testing only.
681
+*/
682
+void manifest_test_parse_cmd(void){
683
+ Manifest m;
684
+ Blob b;
685
+ if( g.argc!=3 ){
686
+ usage("FILENAME");
687
+ }
688
+ db_must_be_within_tree();
689
+ blob_read_from_file(&b, g.argv[2]);
690
+ manifest_parse(&m, &b);
691
+ manifest_clear(&m);
692
+}
674693
675694
/*
676695
** Add a single entry to the mlink table. Also add the filename to
677696
** the filename table if it is not there already.
678697
*/
@@ -916,51 +935,10 @@
916935
isNew = ticket_insert(&m, 1, 1);
917936
zTag = mprintf("tkt-%s", m.zTicketUuid);
918937
tag_insert(zTag, 1, 0, rid, m.rDate, rid);
919938
free(zTag);
920939
blob_zero(&comment);
921
-#if 0
922
- if( m.nField==1 ){
923
- if( m.aField[0].zName[0]=='+' ){
924
- blob_appendf(&comment,
925
- "Appended to %h in ticket [%.10s]",
926
- &m.aField[0].zName[1], m.zTicketUuid
927
- );
928
- }else if( strlen(m.aField[0].zValue)<40 ){
929
- blob_appendf(&comment,
930
- "Changed %h to \"%h\" in ticket [%.10s]",
931
- m.aField[0].zName, m.aField[0].zValue, m.zTicketUuid
932
- );
933
- }else{
934
- blob_appendf(&comment,
935
- "Changed %h in ticket [%.10s]",
936
- m.aField[0].zName, m.zTicketUuid
937
- );
938
- }
939
- }else{
940
- int i;
941
- const char *z;
942
- const char *zSep = " ";
943
- blob_appendf(&comment, "%d changes to ticket [%.10s]:",
944
- m.nField, m.zTicketUuid);
945
- for(i=0; i<m.nField; i++){
946
- z = m.aField[i].zName;
947
- if( z[0]=='+' ) z++;
948
- blob_appendf(&comment, "%s%h", zSep, z);
949
- zSep = ", ";
950
- }
951
- int i;
952
- const char *zStatus = 0;
953
- const char *zTitle;
954
- for(i=0; i<m.nField; i++){
955
- z = m.aField[i].zName;
956
- if( strcmp(z, "status") ) zStatus = m.aField[i].zValue;
957
- }
958
- if( zField
959
- blob_appendf(&comment, "Edits to ticket [%.10s]", m.zTicketUuid);
960
- }
961
-#endif
962940
if( once ){
963941
once = 0;
964942
zTitleExpr = db_get("ticket-title-expr", "title");
965943
zStatusColumn = db_get("ticket-status-column", "status");
966944
}
967945
--- src/manifest.c
+++ src/manifest.c
@@ -669,10 +669,29 @@
669 /*fprintf(stderr, "Manifest error on line %i\n", lineNo);fflush(stderr);*/
670 md5sum_init();
671 manifest_clear(p);
672 return 0;
673 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
674
675 /*
676 ** Add a single entry to the mlink table. Also add the filename to
677 ** the filename table if it is not there already.
678 */
@@ -916,51 +935,10 @@
916 isNew = ticket_insert(&m, 1, 1);
917 zTag = mprintf("tkt-%s", m.zTicketUuid);
918 tag_insert(zTag, 1, 0, rid, m.rDate, rid);
919 free(zTag);
920 blob_zero(&comment);
921 #if 0
922 if( m.nField==1 ){
923 if( m.aField[0].zName[0]=='+' ){
924 blob_appendf(&comment,
925 "Appended to %h in ticket [%.10s]",
926 &m.aField[0].zName[1], m.zTicketUuid
927 );
928 }else if( strlen(m.aField[0].zValue)<40 ){
929 blob_appendf(&comment,
930 "Changed %h to \"%h\" in ticket [%.10s]",
931 m.aField[0].zName, m.aField[0].zValue, m.zTicketUuid
932 );
933 }else{
934 blob_appendf(&comment,
935 "Changed %h in ticket [%.10s]",
936 m.aField[0].zName, m.zTicketUuid
937 );
938 }
939 }else{
940 int i;
941 const char *z;
942 const char *zSep = " ";
943 blob_appendf(&comment, "%d changes to ticket [%.10s]:",
944 m.nField, m.zTicketUuid);
945 for(i=0; i<m.nField; i++){
946 z = m.aField[i].zName;
947 if( z[0]=='+' ) z++;
948 blob_appendf(&comment, "%s%h", zSep, z);
949 zSep = ", ";
950 }
951 int i;
952 const char *zStatus = 0;
953 const char *zTitle;
954 for(i=0; i<m.nField; i++){
955 z = m.aField[i].zName;
956 if( strcmp(z, "status") ) zStatus = m.aField[i].zValue;
957 }
958 if( zField
959 blob_appendf(&comment, "Edits to ticket [%.10s]", m.zTicketUuid);
960 }
961 #endif
962 if( once ){
963 once = 0;
964 zTitleExpr = db_get("ticket-title-expr", "title");
965 zStatusColumn = db_get("ticket-status-column", "status");
966 }
967
--- src/manifest.c
+++ src/manifest.c
@@ -669,10 +669,29 @@
669 /*fprintf(stderr, "Manifest error on line %i\n", lineNo);fflush(stderr);*/
670 md5sum_init();
671 manifest_clear(p);
672 return 0;
673 }
674
675 /*
676 ** COMMAND: test-parse-manifest
677 **
678 ** Usage: %fossil test-parse-manifest FILENAME
679 **
680 ** Parse the manifest and discarded. Use for testing only.
681 */
682 void manifest_test_parse_cmd(void){
683 Manifest m;
684 Blob b;
685 if( g.argc!=3 ){
686 usage("FILENAME");
687 }
688 db_must_be_within_tree();
689 blob_read_from_file(&b, g.argv[2]);
690 manifest_parse(&m, &b);
691 manifest_clear(&m);
692 }
693
694 /*
695 ** Add a single entry to the mlink table. Also add the filename to
696 ** the filename table if it is not there already.
697 */
@@ -916,51 +935,10 @@
935 isNew = ticket_insert(&m, 1, 1);
936 zTag = mprintf("tkt-%s", m.zTicketUuid);
937 tag_insert(zTag, 1, 0, rid, m.rDate, rid);
938 free(zTag);
939 blob_zero(&comment);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
940 if( once ){
941 once = 0;
942 zTitleExpr = db_get("ticket-title-expr", "title");
943 zStatusColumn = db_get("ticket-status-column", "status");
944 }
945

Keyboard Shortcuts

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