Fossil SCM

Add an 'artifact' command to TH1.

mistachkin 2014-06-16 18:02 trunk
Commit 109d8f5dd67e0de0f50e3bd73f4022cc094f284b
+63 -28
--- src/th_main.c
+++ src/th_main.c
@@ -139,11 +139,11 @@
139139
fossil_print("\n------------------- END TRACE LOG -------------------\n");
140140
}
141141
}
142142
143143
/*
144
-** TH1 command: httpize STRING
144
+** TH1 command: httpize STRING
145145
**
146146
** Escape all characters of STRING which have special meaning in URI
147147
** components. Return a new string result.
148148
*/
149149
static int httpizeCmd(
@@ -167,11 +167,11 @@
167167
** True if output is enabled. False if disabled.
168168
*/
169169
static int enableOutput = 1;
170170
171171
/*
172
-** TH1 command: enable_output BOOLEAN
172
+** TH1 command: enable_output BOOLEAN
173173
**
174174
** Enable or disable the puts and hputs commands.
175175
*/
176176
static int enableOutputCmd(
177177
Th_Interp *interp,
@@ -242,12 +242,12 @@
242242
sendText(forceCgi || g.cgiOutput ? "</p>" : "\n", -1, 0);
243243
enableOutput = savedEnable;
244244
}
245245
246246
/*
247
-** TH1 command: puts STRING
248
-** TH1 command: html STRING
247
+** TH1 command: puts STRING
248
+** TH1 command: html STRING
249249
**
250250
** Output STRING escaped for HTML (html) or unchanged (puts).
251251
*/
252252
static int putsCmd(
253253
Th_Interp *interp,
@@ -262,11 +262,11 @@
262262
sendText((char*)argv[1], argl[1], *(unsigned int*)pConvert);
263263
return TH_OK;
264264
}
265265
266266
/*
267
-** TH1 command: wiki STRING
267
+** TH1 command: wiki STRING
268268
**
269269
** Render the input string as wiki.
270270
*/
271271
static int wikiCmd(
272272
Th_Interp *interp,
@@ -287,11 +287,11 @@
287287
}
288288
return TH_OK;
289289
}
290290
291291
/*
292
-** TH1 command: htmlize STRING
292
+** TH1 command: htmlize STRING
293293
**
294294
** Escape all characters of STRING which have special meaning in HTML.
295295
** Return a new string result.
296296
*/
297297
static int htmlizeCmd(
@@ -310,11 +310,11 @@
310310
free(zOut);
311311
return TH_OK;
312312
}
313313
314314
/*
315
-** TH1 command: date
315
+** TH1 command: date
316316
**
317317
** Return a string which is the current time and date. If the
318318
** -local option is used, the date appears using localtime instead
319319
** of UTC.
320320
*/
@@ -335,11 +335,11 @@
335335
free(zOut);
336336
return TH_OK;
337337
}
338338
339339
/*
340
-** TH1 command: hascap STRING...
340
+** TH1 command: hascap STRING...
341341
**
342342
** Return true if the user has all of the capabilities listed in STRING.
343343
*/
344344
static int hascapCmd(
345345
Th_Interp *interp,
@@ -361,11 +361,11 @@
361361
Th_SetResultInt(interp, rc);
362362
return TH_OK;
363363
}
364364
365365
/*
366
-** TH1 command: hasfeature STRING
366
+** TH1 command: hasfeature STRING
367367
**
368368
** Return true if the fossil binary has the given compile-time feature
369369
** enabled. The set of features includes:
370370
**
371371
** "ssl" = FOSSIL_ENABLE_SSL
@@ -439,11 +439,11 @@
439439
return TH_OK;
440440
}
441441
442442
443443
/*
444
-** TH1 command: tclReady
444
+** TH1 command: tclReady
445445
**
446446
** Return true if the fossil binary has the Tcl integration feature
447447
** enabled and it is currently available for use by TH1 scripts.
448448
**
449449
*/
@@ -470,11 +470,11 @@
470470
return TH_OK;
471471
}
472472
473473
474474
/*
475
-** TH1 command: anycap STRING
475
+** TH1 command: anycap STRING
476476
**
477477
** Return true if the user has any one of the capabilities listed in STRING.
478478
*/
479479
static int anycapCmd(
480480
Th_Interp *interp,
@@ -497,11 +497,11 @@
497497
Th_SetResultInt(interp, rc);
498498
return TH_OK;
499499
}
500500
501501
/*
502
-** TH1 command: combobox NAME TEXT-LIST NUMLINES
502
+** TH1 command: combobox NAME TEXT-LIST NUMLINES
503503
**
504504
** Generate an HTML combobox. NAME is both the name of the
505505
** CGI parameter and the name of a variable that contains the
506506
** currently selected value. TEXT-LIST is a list of possible
507507
** values for the combobox. NUMLINES is 1 for a true combobox.
@@ -557,11 +557,11 @@
557557
}
558558
return TH_OK;
559559
}
560560
561561
/*
562
-** TH1 command: linecount STRING MAX MIN
562
+** TH1 command: linecount STRING MAX MIN
563563
**
564564
** Return one more than the number of \n characters in STRING. But
565565
** never return less than MIN or more than MAX.
566566
*/
567567
static int linecntCmd(
@@ -592,11 +592,11 @@
592592
Th_SetResultInt(interp, n);
593593
return TH_OK;
594594
}
595595
596596
/*
597
-** TH1 command: repository ?BOOLEAN?
597
+** TH1 command: repository ?BOOLEAN?
598598
**
599599
** Return the fully qualified file name of the open repository or an empty
600600
** string if one is not currently open. Optionally, it will attempt to open
601601
** the repository if the boolean argument is non-zero.
602602
*/
@@ -620,11 +620,11 @@
620620
Th_SetResult(interp, g.zRepositoryName, -1);
621621
return TH_OK;
622622
}
623623
624624
/*
625
-** TH1 command: checkout ?BOOLEAN?
625
+** TH1 command: checkout ?BOOLEAN?
626626
**
627627
** Return the fully qualified directory name of the current checkout or an
628628
** empty string if it is not available. Optionally, it will attempt to find
629629
** the current checkout, opening the configuration ("user") database and the
630630
** repository as necessary, if the boolean argument is non-zero.
@@ -649,11 +649,11 @@
649649
Th_SetResult(interp, g.zLocalRoot, -1);
650650
return TH_OK;
651651
}
652652
653653
/*
654
-** TH1 command: trace STRING
654
+** TH1 command: trace STRING
655655
**
656656
** Generate a TH1 trace message if debugging is enabled.
657657
*/
658658
static int traceCmd(
659659
Th_Interp *interp,
@@ -671,11 +671,11 @@
671671
Th_SetResult(interp, 0, 0);
672672
return TH_OK;
673673
}
674674
675675
/*
676
-** TH1 command: getParameter NAME ?DEFAULT?
676
+** TH1 command: getParameter NAME ?DEFAULT?
677677
**
678678
** Return the value of the specified query parameter or the specified default
679679
** value when there is no matching query parameter.
680680
*/
681681
static int getParameterCmd(
@@ -695,11 +695,11 @@
695695
Th_SetResult(interp, cgi_parameter(argv[1], zDefault), -1);
696696
return TH_OK;
697697
}
698698
699699
/*
700
-** TH1 command: setParameter NAME VALUE
700
+** TH1 command: setParameter NAME VALUE
701701
**
702702
** Sets the value of the specified query parameter.
703703
*/
704704
static int setParameterCmd(
705705
Th_Interp *interp,
@@ -714,11 +714,11 @@
714714
cgi_replace_parameter(mprintf("%s", argv[1]), mprintf("%s", argv[2]));
715715
return TH_OK;
716716
}
717717
718718
/*
719
-** TH1 command: render STRING
719
+** TH1 command: render STRING
720720
**
721721
** Renders the template and writes the results.
722722
*/
723723
static int renderCmd(
724724
Th_Interp *interp,
@@ -735,11 +735,11 @@
735735
Th_SetResult(interp, 0, 0);
736736
return rc;
737737
}
738738
739739
/*
740
-** TH1 command: styleHeader TITLE
740
+** TH1 command: styleHeader TITLE
741741
**
742742
** Render the configured style header.
743743
*/
744744
static int styleHeaderCmd(
745745
Th_Interp *interp,
@@ -760,11 +760,11 @@
760760
return TH_ERROR;
761761
}
762762
}
763763
764764
/*
765
-** TH1 command: styleFooter
765
+** TH1 command: styleFooter
766766
**
767767
** Render the configured style footer.
768768
*/
769769
static int styleFooterCmd(
770770
Th_Interp *interp,
@@ -778,10 +778,44 @@
778778
}
779779
if( Th_IsRepositoryOpen() ){
780780
style_footer();
781781
Th_SetResult(interp, 0, 0);
782782
return TH_OK;
783
+ }else{
784
+ Th_SetResult(interp, "repository unavailable", -1);
785
+ return TH_ERROR;
786
+ }
787
+}
788
+
789
+/*
790
+** TH1 command: artifact ID
791
+**
792
+** Attempts to locate the specified artifact and return its contents. An
793
+** error is generated if the repository is not open or the artifact cannot
794
+** be found.
795
+*/
796
+static int artifactCmd(
797
+ Th_Interp *interp,
798
+ void *p,
799
+ int argc,
800
+ const char **argv,
801
+ int *argl
802
+){
803
+ if( argc!=2 ){
804
+ return Th_WrongNumArgs(interp, "artifact ID");
805
+ }
806
+ if( Th_IsRepositoryOpen() ){
807
+ int rid;
808
+ Blob content;
809
+ rid = name_to_rid(argv[1]);
810
+ if( rid!=0 && content_get(rid, &content) ){
811
+ Th_SetResult(interp, blob_str(&content), blob_size(&content));
812
+ return TH_OK;
813
+ }else{
814
+ Th_SetResult(interp, "artifact not found", -1);
815
+ return TH_ERROR;
816
+ }
783817
}else{
784818
Th_SetResult(interp, "repository unavailable", -1);
785819
return TH_ERROR;
786820
}
787821
}
@@ -823,11 +857,11 @@
823857
}
824858
#endif
825859
}
826860
827861
/*
828
-** TH1 command: utime
862
+** TH1 command: utime
829863
**
830864
** Return the number of microseconds of CPU time consumed by the current
831865
** process in user space.
832866
*/
833867
static int utimeCmd(
@@ -844,11 +878,11 @@
844878
Th_SetResult(interp, zUTime, -1);
845879
return TH_OK;
846880
}
847881
848882
/*
849
-** TH1 command: stime
883
+** TH1 command: stime
850884
**
851885
** Return the number of microseconds of CPU time consumed by the current
852886
** process in system space.
853887
*/
854888
static int stimeCmd(
@@ -866,11 +900,11 @@
866900
return TH_OK;
867901
}
868902
869903
870904
/*
871
-** TH1 command: randhex N
905
+** TH1 command: randhex N
872906
**
873907
** Return N*2 random hexadecimal digits with N<50. If N is omitted,
874908
** use a value of 10.
875909
*/
876910
static int randhexCmd(
@@ -900,11 +934,11 @@
900934
Th_SetResult(interp, (const char *)zOut, -1);
901935
return TH_OK;
902936
}
903937
904938
/*
905
-** TH1 command: query SQL CODE
939
+** TH1 command: query SQL CODE
906940
**
907941
** Run the SQL query given by the SQL argument. For each row in the result
908942
** set, run CODE.
909943
**
910944
** In SQL, parameters such as $var are filled in using the value of variable
@@ -982,11 +1016,11 @@
9821016
}
9831017
return res;
9841018
}
9851019
9861020
/*
987
-** TH1 command: setting name
1021
+** TH1 command: setting name
9881022
**
9891023
** Gets and returns the value of the specified Fossil setting.
9901024
*/
9911025
#define SETTING_WRONGNUMARGS "setting ?-strict? ?--? name"
9921026
static int settingCmd(
@@ -1027,11 +1061,11 @@
10271061
}
10281062
return rc;
10291063
}
10301064
10311065
/*
1032
-** TH1 command: regexp ?-nocase? ?--? exp string
1066
+** TH1 command: regexp ?-nocase? ?--? exp string
10331067
**
10341068
** Checks the string against the specified regular expression and returns
10351069
** non-zero if it matches. If the regular expression is invalid or cannot
10361070
** be compiled, an error will be generated.
10371071
*/
@@ -1070,11 +1104,11 @@
10701104
re_free(pRe);
10711105
return rc;
10721106
}
10731107
10741108
/*
1075
-** TH1 command: http ?-asynchronous? ?--? url ?payload?
1109
+** TH1 command: http ?-asynchronous? ?--? url ?payload?
10761110
**
10771111
** Perform an HTTP or HTTPS request for the specified URL. If a
10781112
** payload is present, it will be interpreted as text/plain and
10791113
** the POST method will be used; otherwise, the GET method will
10801114
** be used. Upon success, if the -asynchronous option is used, an
@@ -1244,10 +1278,11 @@
12441278
const char *zName;
12451279
Th_CommandProc xProc;
12461280
void *pContext;
12471281
} aCommand[] = {
12481282
{"anycap", anycapCmd, 0},
1283
+ {"artifact", artifactCmd, 0},
12491284
{"checkout", checkoutCmd, 0},
12501285
{"combobox", comboboxCmd, 0},
12511286
{"date", dateCmd, 0},
12521287
{"decorate", wikiCmd, (void*)&aFlags[2]},
12531288
{"enable_output", enableOutputCmd, 0},
12541289
--- src/th_main.c
+++ src/th_main.c
@@ -139,11 +139,11 @@
139 fossil_print("\n------------------- END TRACE LOG -------------------\n");
140 }
141 }
142
143 /*
144 ** TH1 command: httpize STRING
145 **
146 ** Escape all characters of STRING which have special meaning in URI
147 ** components. Return a new string result.
148 */
149 static int httpizeCmd(
@@ -167,11 +167,11 @@
167 ** True if output is enabled. False if disabled.
168 */
169 static int enableOutput = 1;
170
171 /*
172 ** TH1 command: enable_output BOOLEAN
173 **
174 ** Enable or disable the puts and hputs commands.
175 */
176 static int enableOutputCmd(
177 Th_Interp *interp,
@@ -242,12 +242,12 @@
242 sendText(forceCgi || g.cgiOutput ? "</p>" : "\n", -1, 0);
243 enableOutput = savedEnable;
244 }
245
246 /*
247 ** TH1 command: puts STRING
248 ** TH1 command: html STRING
249 **
250 ** Output STRING escaped for HTML (html) or unchanged (puts).
251 */
252 static int putsCmd(
253 Th_Interp *interp,
@@ -262,11 +262,11 @@
262 sendText((char*)argv[1], argl[1], *(unsigned int*)pConvert);
263 return TH_OK;
264 }
265
266 /*
267 ** TH1 command: wiki STRING
268 **
269 ** Render the input string as wiki.
270 */
271 static int wikiCmd(
272 Th_Interp *interp,
@@ -287,11 +287,11 @@
287 }
288 return TH_OK;
289 }
290
291 /*
292 ** TH1 command: htmlize STRING
293 **
294 ** Escape all characters of STRING which have special meaning in HTML.
295 ** Return a new string result.
296 */
297 static int htmlizeCmd(
@@ -310,11 +310,11 @@
310 free(zOut);
311 return TH_OK;
312 }
313
314 /*
315 ** TH1 command: date
316 **
317 ** Return a string which is the current time and date. If the
318 ** -local option is used, the date appears using localtime instead
319 ** of UTC.
320 */
@@ -335,11 +335,11 @@
335 free(zOut);
336 return TH_OK;
337 }
338
339 /*
340 ** TH1 command: hascap STRING...
341 **
342 ** Return true if the user has all of the capabilities listed in STRING.
343 */
344 static int hascapCmd(
345 Th_Interp *interp,
@@ -361,11 +361,11 @@
361 Th_SetResultInt(interp, rc);
362 return TH_OK;
363 }
364
365 /*
366 ** TH1 command: hasfeature STRING
367 **
368 ** Return true if the fossil binary has the given compile-time feature
369 ** enabled. The set of features includes:
370 **
371 ** "ssl" = FOSSIL_ENABLE_SSL
@@ -439,11 +439,11 @@
439 return TH_OK;
440 }
441
442
443 /*
444 ** TH1 command: tclReady
445 **
446 ** Return true if the fossil binary has the Tcl integration feature
447 ** enabled and it is currently available for use by TH1 scripts.
448 **
449 */
@@ -470,11 +470,11 @@
470 return TH_OK;
471 }
472
473
474 /*
475 ** TH1 command: anycap STRING
476 **
477 ** Return true if the user has any one of the capabilities listed in STRING.
478 */
479 static int anycapCmd(
480 Th_Interp *interp,
@@ -497,11 +497,11 @@
497 Th_SetResultInt(interp, rc);
498 return TH_OK;
499 }
500
501 /*
502 ** TH1 command: combobox NAME TEXT-LIST NUMLINES
503 **
504 ** Generate an HTML combobox. NAME is both the name of the
505 ** CGI parameter and the name of a variable that contains the
506 ** currently selected value. TEXT-LIST is a list of possible
507 ** values for the combobox. NUMLINES is 1 for a true combobox.
@@ -557,11 +557,11 @@
557 }
558 return TH_OK;
559 }
560
561 /*
562 ** TH1 command: linecount STRING MAX MIN
563 **
564 ** Return one more than the number of \n characters in STRING. But
565 ** never return less than MIN or more than MAX.
566 */
567 static int linecntCmd(
@@ -592,11 +592,11 @@
592 Th_SetResultInt(interp, n);
593 return TH_OK;
594 }
595
596 /*
597 ** TH1 command: repository ?BOOLEAN?
598 **
599 ** Return the fully qualified file name of the open repository or an empty
600 ** string if one is not currently open. Optionally, it will attempt to open
601 ** the repository if the boolean argument is non-zero.
602 */
@@ -620,11 +620,11 @@
620 Th_SetResult(interp, g.zRepositoryName, -1);
621 return TH_OK;
622 }
623
624 /*
625 ** TH1 command: checkout ?BOOLEAN?
626 **
627 ** Return the fully qualified directory name of the current checkout or an
628 ** empty string if it is not available. Optionally, it will attempt to find
629 ** the current checkout, opening the configuration ("user") database and the
630 ** repository as necessary, if the boolean argument is non-zero.
@@ -649,11 +649,11 @@
649 Th_SetResult(interp, g.zLocalRoot, -1);
650 return TH_OK;
651 }
652
653 /*
654 ** TH1 command: trace STRING
655 **
656 ** Generate a TH1 trace message if debugging is enabled.
657 */
658 static int traceCmd(
659 Th_Interp *interp,
@@ -671,11 +671,11 @@
671 Th_SetResult(interp, 0, 0);
672 return TH_OK;
673 }
674
675 /*
676 ** TH1 command: getParameter NAME ?DEFAULT?
677 **
678 ** Return the value of the specified query parameter or the specified default
679 ** value when there is no matching query parameter.
680 */
681 static int getParameterCmd(
@@ -695,11 +695,11 @@
695 Th_SetResult(interp, cgi_parameter(argv[1], zDefault), -1);
696 return TH_OK;
697 }
698
699 /*
700 ** TH1 command: setParameter NAME VALUE
701 **
702 ** Sets the value of the specified query parameter.
703 */
704 static int setParameterCmd(
705 Th_Interp *interp,
@@ -714,11 +714,11 @@
714 cgi_replace_parameter(mprintf("%s", argv[1]), mprintf("%s", argv[2]));
715 return TH_OK;
716 }
717
718 /*
719 ** TH1 command: render STRING
720 **
721 ** Renders the template and writes the results.
722 */
723 static int renderCmd(
724 Th_Interp *interp,
@@ -735,11 +735,11 @@
735 Th_SetResult(interp, 0, 0);
736 return rc;
737 }
738
739 /*
740 ** TH1 command: styleHeader TITLE
741 **
742 ** Render the configured style header.
743 */
744 static int styleHeaderCmd(
745 Th_Interp *interp,
@@ -760,11 +760,11 @@
760 return TH_ERROR;
761 }
762 }
763
764 /*
765 ** TH1 command: styleFooter
766 **
767 ** Render the configured style footer.
768 */
769 static int styleFooterCmd(
770 Th_Interp *interp,
@@ -778,10 +778,44 @@
778 }
779 if( Th_IsRepositoryOpen() ){
780 style_footer();
781 Th_SetResult(interp, 0, 0);
782 return TH_OK;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
783 }else{
784 Th_SetResult(interp, "repository unavailable", -1);
785 return TH_ERROR;
786 }
787 }
@@ -823,11 +857,11 @@
823 }
824 #endif
825 }
826
827 /*
828 ** TH1 command: utime
829 **
830 ** Return the number of microseconds of CPU time consumed by the current
831 ** process in user space.
832 */
833 static int utimeCmd(
@@ -844,11 +878,11 @@
844 Th_SetResult(interp, zUTime, -1);
845 return TH_OK;
846 }
847
848 /*
849 ** TH1 command: stime
850 **
851 ** Return the number of microseconds of CPU time consumed by the current
852 ** process in system space.
853 */
854 static int stimeCmd(
@@ -866,11 +900,11 @@
866 return TH_OK;
867 }
868
869
870 /*
871 ** TH1 command: randhex N
872 **
873 ** Return N*2 random hexadecimal digits with N<50. If N is omitted,
874 ** use a value of 10.
875 */
876 static int randhexCmd(
@@ -900,11 +934,11 @@
900 Th_SetResult(interp, (const char *)zOut, -1);
901 return TH_OK;
902 }
903
904 /*
905 ** TH1 command: query SQL CODE
906 **
907 ** Run the SQL query given by the SQL argument. For each row in the result
908 ** set, run CODE.
909 **
910 ** In SQL, parameters such as $var are filled in using the value of variable
@@ -982,11 +1016,11 @@
982 }
983 return res;
984 }
985
986 /*
987 ** TH1 command: setting name
988 **
989 ** Gets and returns the value of the specified Fossil setting.
990 */
991 #define SETTING_WRONGNUMARGS "setting ?-strict? ?--? name"
992 static int settingCmd(
@@ -1027,11 +1061,11 @@
1027 }
1028 return rc;
1029 }
1030
1031 /*
1032 ** TH1 command: regexp ?-nocase? ?--? exp string
1033 **
1034 ** Checks the string against the specified regular expression and returns
1035 ** non-zero if it matches. If the regular expression is invalid or cannot
1036 ** be compiled, an error will be generated.
1037 */
@@ -1070,11 +1104,11 @@
1070 re_free(pRe);
1071 return rc;
1072 }
1073
1074 /*
1075 ** TH1 command: http ?-asynchronous? ?--? url ?payload?
1076 **
1077 ** Perform an HTTP or HTTPS request for the specified URL. If a
1078 ** payload is present, it will be interpreted as text/plain and
1079 ** the POST method will be used; otherwise, the GET method will
1080 ** be used. Upon success, if the -asynchronous option is used, an
@@ -1244,10 +1278,11 @@
1244 const char *zName;
1245 Th_CommandProc xProc;
1246 void *pContext;
1247 } aCommand[] = {
1248 {"anycap", anycapCmd, 0},
 
1249 {"checkout", checkoutCmd, 0},
1250 {"combobox", comboboxCmd, 0},
1251 {"date", dateCmd, 0},
1252 {"decorate", wikiCmd, (void*)&aFlags[2]},
1253 {"enable_output", enableOutputCmd, 0},
1254
--- src/th_main.c
+++ src/th_main.c
@@ -139,11 +139,11 @@
139 fossil_print("\n------------------- END TRACE LOG -------------------\n");
140 }
141 }
142
143 /*
144 ** TH1 command: httpize STRING
145 **
146 ** Escape all characters of STRING which have special meaning in URI
147 ** components. Return a new string result.
148 */
149 static int httpizeCmd(
@@ -167,11 +167,11 @@
167 ** True if output is enabled. False if disabled.
168 */
169 static int enableOutput = 1;
170
171 /*
172 ** TH1 command: enable_output BOOLEAN
173 **
174 ** Enable or disable the puts and hputs commands.
175 */
176 static int enableOutputCmd(
177 Th_Interp *interp,
@@ -242,12 +242,12 @@
242 sendText(forceCgi || g.cgiOutput ? "</p>" : "\n", -1, 0);
243 enableOutput = savedEnable;
244 }
245
246 /*
247 ** TH1 command: puts STRING
248 ** TH1 command: html STRING
249 **
250 ** Output STRING escaped for HTML (html) or unchanged (puts).
251 */
252 static int putsCmd(
253 Th_Interp *interp,
@@ -262,11 +262,11 @@
262 sendText((char*)argv[1], argl[1], *(unsigned int*)pConvert);
263 return TH_OK;
264 }
265
266 /*
267 ** TH1 command: wiki STRING
268 **
269 ** Render the input string as wiki.
270 */
271 static int wikiCmd(
272 Th_Interp *interp,
@@ -287,11 +287,11 @@
287 }
288 return TH_OK;
289 }
290
291 /*
292 ** TH1 command: htmlize STRING
293 **
294 ** Escape all characters of STRING which have special meaning in HTML.
295 ** Return a new string result.
296 */
297 static int htmlizeCmd(
@@ -310,11 +310,11 @@
310 free(zOut);
311 return TH_OK;
312 }
313
314 /*
315 ** TH1 command: date
316 **
317 ** Return a string which is the current time and date. If the
318 ** -local option is used, the date appears using localtime instead
319 ** of UTC.
320 */
@@ -335,11 +335,11 @@
335 free(zOut);
336 return TH_OK;
337 }
338
339 /*
340 ** TH1 command: hascap STRING...
341 **
342 ** Return true if the user has all of the capabilities listed in STRING.
343 */
344 static int hascapCmd(
345 Th_Interp *interp,
@@ -361,11 +361,11 @@
361 Th_SetResultInt(interp, rc);
362 return TH_OK;
363 }
364
365 /*
366 ** TH1 command: hasfeature STRING
367 **
368 ** Return true if the fossil binary has the given compile-time feature
369 ** enabled. The set of features includes:
370 **
371 ** "ssl" = FOSSIL_ENABLE_SSL
@@ -439,11 +439,11 @@
439 return TH_OK;
440 }
441
442
443 /*
444 ** TH1 command: tclReady
445 **
446 ** Return true if the fossil binary has the Tcl integration feature
447 ** enabled and it is currently available for use by TH1 scripts.
448 **
449 */
@@ -470,11 +470,11 @@
470 return TH_OK;
471 }
472
473
474 /*
475 ** TH1 command: anycap STRING
476 **
477 ** Return true if the user has any one of the capabilities listed in STRING.
478 */
479 static int anycapCmd(
480 Th_Interp *interp,
@@ -497,11 +497,11 @@
497 Th_SetResultInt(interp, rc);
498 return TH_OK;
499 }
500
501 /*
502 ** TH1 command: combobox NAME TEXT-LIST NUMLINES
503 **
504 ** Generate an HTML combobox. NAME is both the name of the
505 ** CGI parameter and the name of a variable that contains the
506 ** currently selected value. TEXT-LIST is a list of possible
507 ** values for the combobox. NUMLINES is 1 for a true combobox.
@@ -557,11 +557,11 @@
557 }
558 return TH_OK;
559 }
560
561 /*
562 ** TH1 command: linecount STRING MAX MIN
563 **
564 ** Return one more than the number of \n characters in STRING. But
565 ** never return less than MIN or more than MAX.
566 */
567 static int linecntCmd(
@@ -592,11 +592,11 @@
592 Th_SetResultInt(interp, n);
593 return TH_OK;
594 }
595
596 /*
597 ** TH1 command: repository ?BOOLEAN?
598 **
599 ** Return the fully qualified file name of the open repository or an empty
600 ** string if one is not currently open. Optionally, it will attempt to open
601 ** the repository if the boolean argument is non-zero.
602 */
@@ -620,11 +620,11 @@
620 Th_SetResult(interp, g.zRepositoryName, -1);
621 return TH_OK;
622 }
623
624 /*
625 ** TH1 command: checkout ?BOOLEAN?
626 **
627 ** Return the fully qualified directory name of the current checkout or an
628 ** empty string if it is not available. Optionally, it will attempt to find
629 ** the current checkout, opening the configuration ("user") database and the
630 ** repository as necessary, if the boolean argument is non-zero.
@@ -649,11 +649,11 @@
649 Th_SetResult(interp, g.zLocalRoot, -1);
650 return TH_OK;
651 }
652
653 /*
654 ** TH1 command: trace STRING
655 **
656 ** Generate a TH1 trace message if debugging is enabled.
657 */
658 static int traceCmd(
659 Th_Interp *interp,
@@ -671,11 +671,11 @@
671 Th_SetResult(interp, 0, 0);
672 return TH_OK;
673 }
674
675 /*
676 ** TH1 command: getParameter NAME ?DEFAULT?
677 **
678 ** Return the value of the specified query parameter or the specified default
679 ** value when there is no matching query parameter.
680 */
681 static int getParameterCmd(
@@ -695,11 +695,11 @@
695 Th_SetResult(interp, cgi_parameter(argv[1], zDefault), -1);
696 return TH_OK;
697 }
698
699 /*
700 ** TH1 command: setParameter NAME VALUE
701 **
702 ** Sets the value of the specified query parameter.
703 */
704 static int setParameterCmd(
705 Th_Interp *interp,
@@ -714,11 +714,11 @@
714 cgi_replace_parameter(mprintf("%s", argv[1]), mprintf("%s", argv[2]));
715 return TH_OK;
716 }
717
718 /*
719 ** TH1 command: render STRING
720 **
721 ** Renders the template and writes the results.
722 */
723 static int renderCmd(
724 Th_Interp *interp,
@@ -735,11 +735,11 @@
735 Th_SetResult(interp, 0, 0);
736 return rc;
737 }
738
739 /*
740 ** TH1 command: styleHeader TITLE
741 **
742 ** Render the configured style header.
743 */
744 static int styleHeaderCmd(
745 Th_Interp *interp,
@@ -760,11 +760,11 @@
760 return TH_ERROR;
761 }
762 }
763
764 /*
765 ** TH1 command: styleFooter
766 **
767 ** Render the configured style footer.
768 */
769 static int styleFooterCmd(
770 Th_Interp *interp,
@@ -778,10 +778,44 @@
778 }
779 if( Th_IsRepositoryOpen() ){
780 style_footer();
781 Th_SetResult(interp, 0, 0);
782 return TH_OK;
783 }else{
784 Th_SetResult(interp, "repository unavailable", -1);
785 return TH_ERROR;
786 }
787 }
788
789 /*
790 ** TH1 command: artifact ID
791 **
792 ** Attempts to locate the specified artifact and return its contents. An
793 ** error is generated if the repository is not open or the artifact cannot
794 ** be found.
795 */
796 static int artifactCmd(
797 Th_Interp *interp,
798 void *p,
799 int argc,
800 const char **argv,
801 int *argl
802 ){
803 if( argc!=2 ){
804 return Th_WrongNumArgs(interp, "artifact ID");
805 }
806 if( Th_IsRepositoryOpen() ){
807 int rid;
808 Blob content;
809 rid = name_to_rid(argv[1]);
810 if( rid!=0 && content_get(rid, &content) ){
811 Th_SetResult(interp, blob_str(&content), blob_size(&content));
812 return TH_OK;
813 }else{
814 Th_SetResult(interp, "artifact not found", -1);
815 return TH_ERROR;
816 }
817 }else{
818 Th_SetResult(interp, "repository unavailable", -1);
819 return TH_ERROR;
820 }
821 }
@@ -823,11 +857,11 @@
857 }
858 #endif
859 }
860
861 /*
862 ** TH1 command: utime
863 **
864 ** Return the number of microseconds of CPU time consumed by the current
865 ** process in user space.
866 */
867 static int utimeCmd(
@@ -844,11 +878,11 @@
878 Th_SetResult(interp, zUTime, -1);
879 return TH_OK;
880 }
881
882 /*
883 ** TH1 command: stime
884 **
885 ** Return the number of microseconds of CPU time consumed by the current
886 ** process in system space.
887 */
888 static int stimeCmd(
@@ -866,11 +900,11 @@
900 return TH_OK;
901 }
902
903
904 /*
905 ** TH1 command: randhex N
906 **
907 ** Return N*2 random hexadecimal digits with N<50. If N is omitted,
908 ** use a value of 10.
909 */
910 static int randhexCmd(
@@ -900,11 +934,11 @@
934 Th_SetResult(interp, (const char *)zOut, -1);
935 return TH_OK;
936 }
937
938 /*
939 ** TH1 command: query SQL CODE
940 **
941 ** Run the SQL query given by the SQL argument. For each row in the result
942 ** set, run CODE.
943 **
944 ** In SQL, parameters such as $var are filled in using the value of variable
@@ -982,11 +1016,11 @@
1016 }
1017 return res;
1018 }
1019
1020 /*
1021 ** TH1 command: setting name
1022 **
1023 ** Gets and returns the value of the specified Fossil setting.
1024 */
1025 #define SETTING_WRONGNUMARGS "setting ?-strict? ?--? name"
1026 static int settingCmd(
@@ -1027,11 +1061,11 @@
1061 }
1062 return rc;
1063 }
1064
1065 /*
1066 ** TH1 command: regexp ?-nocase? ?--? exp string
1067 **
1068 ** Checks the string against the specified regular expression and returns
1069 ** non-zero if it matches. If the regular expression is invalid or cannot
1070 ** be compiled, an error will be generated.
1071 */
@@ -1070,11 +1104,11 @@
1104 re_free(pRe);
1105 return rc;
1106 }
1107
1108 /*
1109 ** TH1 command: http ?-asynchronous? ?--? url ?payload?
1110 **
1111 ** Perform an HTTP or HTTPS request for the specified URL. If a
1112 ** payload is present, it will be interpreted as text/plain and
1113 ** the POST method will be used; otherwise, the GET method will
1114 ** be used. Upon success, if the -asynchronous option is used, an
@@ -1244,10 +1278,11 @@
1278 const char *zName;
1279 Th_CommandProc xProc;
1280 void *pContext;
1281 } aCommand[] = {
1282 {"anycap", anycapCmd, 0},
1283 {"artifact", artifactCmd, 0},
1284 {"checkout", checkoutCmd, 0},
1285 {"combobox", comboboxCmd, 0},
1286 {"date", dateCmd, 0},
1287 {"decorate", wikiCmd, (void*)&aFlags[2]},
1288 {"enable_output", enableOutputCmd, 0},
1289
+1 -1
--- src/tkt.c
+++ src/tkt.c
@@ -474,11 +474,11 @@
474474
475475
style_footer();
476476
}
477477
478478
/*
479
-** TH1 command: append_field FIELD STRING
479
+** TH1 command: append_field FIELD STRING
480480
**
481481
** FIELD is the name of a database column to which we might want
482482
** to append text. STRING is the text to be appended to that
483483
** column. The append does not actually occur until the
484484
** submit_ticket command is run.
485485
--- src/tkt.c
+++ src/tkt.c
@@ -474,11 +474,11 @@
474
475 style_footer();
476 }
477
478 /*
479 ** TH1 command: append_field FIELD STRING
480 **
481 ** FIELD is the name of a database column to which we might want
482 ** to append text. STRING is the text to be appended to that
483 ** column. The append does not actually occur until the
484 ** submit_ticket command is run.
485
--- src/tkt.c
+++ src/tkt.c
@@ -474,11 +474,11 @@
474
475 style_footer();
476 }
477
478 /*
479 ** TH1 command: append_field FIELD STRING
480 **
481 ** FIELD is the name of a database column to which we might want
482 ** to append text. STRING is the text to be appended to that
483 ** column. The append does not actually occur until the
484 ** submit_ticket command is run.
485
--- test/th1.test
+++ test/th1.test
@@ -630,5 +630,31 @@
630630
631631
###############################################################################
632632
633633
fossil test-th-eval "setParameter test4 value4; setParameter test4 value5; getParameter test4 defValue4"
634634
test th1-set-parameter-7 {$RESULT eq {value5}}
635
+
636
+###############################################################################
637
+
638
+fossil test-th-eval "artifact"
639
+test th1-artifact-1 {$RESULT eq \
640
+ {TH_ERROR: wrong # args: should be "artifact ID"}}
641
+
642
+###############################################################################
643
+
644
+fossil test-th-eval "artifact tip"
645
+test th1-artifact-2 {$RESULT eq {TH_ERROR: repository unavailable}}
646
+
647
+###############################################################################
648
+
649
+fossil test-th-eval --th-open-config "artifact tip"
650
+test th1-artifact-3 {[regexp -- {F test/th1\.test [0-9a-f]{40}} $RESULT]}
651
+
652
+###############################################################################
653
+
654
+fossil test-th-eval "artifact 0000000000"
655
+test th1-artifact-4 {$RESULT eq {TH_ERROR: repository unavailable}}
656
+
657
+###############################################################################
658
+
659
+fossil test-th-eval --th-open-config "artifact 0000000000"
660
+test th1-artifact-5 {$RESULT eq {TH_ERROR: artifact not found}}
635661
--- test/th1.test
+++ test/th1.test
@@ -630,5 +630,31 @@
630
631 ###############################################################################
632
633 fossil test-th-eval "setParameter test4 value4; setParameter test4 value5; getParameter test4 defValue4"
634 test th1-set-parameter-7 {$RESULT eq {value5}}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
635
--- test/th1.test
+++ test/th1.test
@@ -630,5 +630,31 @@
630
631 ###############################################################################
632
633 fossil test-th-eval "setParameter test4 value4; setParameter test4 value5; getParameter test4 defValue4"
634 test th1-set-parameter-7 {$RESULT eq {value5}}
635
636 ###############################################################################
637
638 fossil test-th-eval "artifact"
639 test th1-artifact-1 {$RESULT eq \
640 {TH_ERROR: wrong # args: should be "artifact ID"}}
641
642 ###############################################################################
643
644 fossil test-th-eval "artifact tip"
645 test th1-artifact-2 {$RESULT eq {TH_ERROR: repository unavailable}}
646
647 ###############################################################################
648
649 fossil test-th-eval --th-open-config "artifact tip"
650 test th1-artifact-3 {[regexp -- {F test/th1\.test [0-9a-f]{40}} $RESULT]}
651
652 ###############################################################################
653
654 fossil test-th-eval "artifact 0000000000"
655 test th1-artifact-4 {$RESULT eq {TH_ERROR: repository unavailable}}
656
657 ###############################################################################
658
659 fossil test-th-eval --th-open-config "artifact 0000000000"
660 test th1-artifact-5 {$RESULT eq {TH_ERROR: artifact not found}}
661
--- www/changes.wiki
+++ www/changes.wiki
@@ -8,12 +8,12 @@
88
historical check-ins. This only works on systems that support FuseFS.
99
* Support customization of commands and webpages, including the ability to
1010
add new ones, via the "TH1 hooks" feature. Disabled by default. Enabled
1111
via a compile-time option.
1212
* Add the <nowiki>[checkout], [render], [styleHeader], [styleFooter],
13
- [trace], [getParameter], and [setParameter]</nowiki> commands to TH1,
14
- primarily for use by TH1 hooks.
13
+ [trace], [getParameter], [setParameter], and [artifact]</nowiki> commands
14
+ to TH1, primarily for use by TH1 hooks.
1515
* Bring in the latest version of autosetup from upstream.
1616
1717
<h2>Changes For Version 1.29 (2014-06-12)</h2>
1818
* Add the ability to display content, diffs and annotations for UTF16
1919
text files in the web interface.
2020
--- www/changes.wiki
+++ www/changes.wiki
@@ -8,12 +8,12 @@
8 historical check-ins. This only works on systems that support FuseFS.
9 * Support customization of commands and webpages, including the ability to
10 add new ones, via the "TH1 hooks" feature. Disabled by default. Enabled
11 via a compile-time option.
12 * Add the <nowiki>[checkout], [render], [styleHeader], [styleFooter],
13 [trace], [getParameter], and [setParameter]</nowiki> commands to TH1,
14 primarily for use by TH1 hooks.
15 * Bring in the latest version of autosetup from upstream.
16
17 <h2>Changes For Version 1.29 (2014-06-12)</h2>
18 * Add the ability to display content, diffs and annotations for UTF16
19 text files in the web interface.
20
--- www/changes.wiki
+++ www/changes.wiki
@@ -8,12 +8,12 @@
8 historical check-ins. This only works on systems that support FuseFS.
9 * Support customization of commands and webpages, including the ability to
10 add new ones, via the "TH1 hooks" feature. Disabled by default. Enabled
11 via a compile-time option.
12 * Add the <nowiki>[checkout], [render], [styleHeader], [styleFooter],
13 [trace], [getParameter], [setParameter], and [artifact]</nowiki> commands
14 to TH1, primarily for use by TH1 hooks.
15 * Bring in the latest version of autosetup from upstream.
16
17 <h2>Changes For Version 1.29 (2014-06-12)</h2>
18 * Add the ability to display content, diffs and annotations for UTF16
19 text files in the web interface.
20

Keyboard Shortcuts

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