Fossil SCM

Add 'th1-hooks' setting to control whether or not TH1 hooks are enabled. By default, all TH1 hooks are disabled.

mistachkin 2014-06-11 00:38 UTC th1Hooks
Commit 54e00d7a0aa3063d3a97ce85a511f1a533e4eddd
--- src/configure.c
+++ src/configure.c
@@ -97,10 +97,11 @@
9797
{ "timeline-max-comment", CONFIGSET_SKIN },
9898
{ "timeline-plaintext", CONFIGSET_SKIN },
9999
{ "adunit", CONFIGSET_SKIN },
100100
{ "adunit-omit-if-admin", CONFIGSET_SKIN },
101101
{ "adunit-omit-if-user", CONFIGSET_SKIN },
102
+ { "th1-hooks", CONFIGSET_TH1 },
102103
{ "th1-setup", CONFIGSET_TH1 },
103104
{ "th1-uri-regexp", CONFIGSET_TH1 },
104105
105106
#ifdef FOSSIL_ENABLE_TCL
106107
{ "tcl", CONFIGSET_TH1 },
107108
--- src/configure.c
+++ src/configure.c
@@ -97,10 +97,11 @@
97 { "timeline-max-comment", CONFIGSET_SKIN },
98 { "timeline-plaintext", CONFIGSET_SKIN },
99 { "adunit", CONFIGSET_SKIN },
100 { "adunit-omit-if-admin", CONFIGSET_SKIN },
101 { "adunit-omit-if-user", CONFIGSET_SKIN },
 
102 { "th1-setup", CONFIGSET_TH1 },
103 { "th1-uri-regexp", CONFIGSET_TH1 },
104
105 #ifdef FOSSIL_ENABLE_TCL
106 { "tcl", CONFIGSET_TH1 },
107
--- src/configure.c
+++ src/configure.c
@@ -97,10 +97,11 @@
97 { "timeline-max-comment", CONFIGSET_SKIN },
98 { "timeline-plaintext", CONFIGSET_SKIN },
99 { "adunit", CONFIGSET_SKIN },
100 { "adunit-omit-if-admin", CONFIGSET_SKIN },
101 { "adunit-omit-if-user", CONFIGSET_SKIN },
102 { "th1-hooks", CONFIGSET_TH1 },
103 { "th1-setup", CONFIGSET_TH1 },
104 { "th1-uri-regexp", CONFIGSET_TH1 },
105
106 #ifdef FOSSIL_ENABLE_TCL
107 { "tcl", CONFIGSET_TH1 },
108
+5
--- src/db.c
+++ src/db.c
@@ -2184,10 +2184,11 @@
21842184
{ "ssl-identity", 0, 40, 0, 0, "" },
21852185
#ifdef FOSSIL_ENABLE_TCL
21862186
{ "tcl", 0, 0, 0, 0, "off" },
21872187
{ "tcl-setup", 0, 40, 1, 1, "" },
21882188
#endif
2189
+ { "th1-hooks", 0, 0, 0, 0, "off" },
21892190
{ "th1-setup", 0, 40, 1, 1, "" },
21902191
{ "th1-uri-regexp", 0, 40, 1, 0, "" },
21912192
{ "web-browser", 0, 32, 0, 0, "" },
21922193
{ "white-foreground", 0, 0, 0, 0, "off" },
21932194
{ 0,0,0,0,0,0 }
@@ -2385,10 +2386,14 @@
23852386
** expressions and scripts. Default: off.
23862387
**
23872388
** tcl-setup This is the setup script to be evaluated after creating
23882389
** (versionable) and initializing the Tcl interpreter. By default, this
23892390
** is empty and no extra setup is performed.
2391
+**
2392
+** th1-hooks If enabled (and Fossil was compiled with support for TH1
2393
+** hooks), special TH1 commands will be called before and
2394
+** after any Fossil command or web page. Default: off.
23902395
**
23912396
** th1-setup This is the setup script to be evaluated after creating
23922397
** (versionable) and initializing the TH1 interpreter. By default, this
23932398
** is empty and no extra setup is performed.
23942399
**
23952400
--- src/db.c
+++ src/db.c
@@ -2184,10 +2184,11 @@
2184 { "ssl-identity", 0, 40, 0, 0, "" },
2185 #ifdef FOSSIL_ENABLE_TCL
2186 { "tcl", 0, 0, 0, 0, "off" },
2187 { "tcl-setup", 0, 40, 1, 1, "" },
2188 #endif
 
2189 { "th1-setup", 0, 40, 1, 1, "" },
2190 { "th1-uri-regexp", 0, 40, 1, 0, "" },
2191 { "web-browser", 0, 32, 0, 0, "" },
2192 { "white-foreground", 0, 0, 0, 0, "off" },
2193 { 0,0,0,0,0,0 }
@@ -2385,10 +2386,14 @@
2385 ** expressions and scripts. Default: off.
2386 **
2387 ** tcl-setup This is the setup script to be evaluated after creating
2388 ** (versionable) and initializing the Tcl interpreter. By default, this
2389 ** is empty and no extra setup is performed.
 
 
 
 
2390 **
2391 ** th1-setup This is the setup script to be evaluated after creating
2392 ** (versionable) and initializing the TH1 interpreter. By default, this
2393 ** is empty and no extra setup is performed.
2394 **
2395
--- src/db.c
+++ src/db.c
@@ -2184,10 +2184,11 @@
2184 { "ssl-identity", 0, 40, 0, 0, "" },
2185 #ifdef FOSSIL_ENABLE_TCL
2186 { "tcl", 0, 0, 0, 0, "off" },
2187 { "tcl-setup", 0, 40, 1, 1, "" },
2188 #endif
2189 { "th1-hooks", 0, 0, 0, 0, "off" },
2190 { "th1-setup", 0, 40, 1, 1, "" },
2191 { "th1-uri-regexp", 0, 40, 1, 0, "" },
2192 { "web-browser", 0, 32, 0, 0, "" },
2193 { "white-foreground", 0, 0, 0, 0, "off" },
2194 { 0,0,0,0,0,0 }
@@ -2385,10 +2386,14 @@
2386 ** expressions and scripts. Default: off.
2387 **
2388 ** tcl-setup This is the setup script to be evaluated after creating
2389 ** (versionable) and initializing the Tcl interpreter. By default, this
2390 ** is empty and no extra setup is performed.
2391 **
2392 ** th1-hooks If enabled (and Fossil was compiled with support for TH1
2393 ** hooks), special TH1 commands will be called before and
2394 ** after any Fossil command or web page. Default: off.
2395 **
2396 ** th1-setup This is the setup script to be evaluated after creating
2397 ** (versionable) and initializing the TH1 interpreter. By default, this
2398 ** is empty and no extra setup is performed.
2399 **
2400
+14 -2
--- src/th_main.c
+++ src/th_main.c
@@ -1236,10 +1236,13 @@
12361236
const char *zName,
12371237
char cmdFlags
12381238
){
12391239
int rc = TH_OK;
12401240
Th_FossilInit(TH_INIT_HOOK);
1241
+ if( fossil_getenv("TH1_ENABLE_HOOKS")==0 && !db_get_boolean("th1-hooks", 0) ){
1242
+ return rc;
1243
+ }
12411244
Th_Store("cmd_name", zName);
12421245
Th_StoreList("cmd_args", g.argv, g.argc);
12431246
Th_StoreInt("cmd_flags", cmdFlags);
12441247
rc = Th_Eval(g.interp, 0, "command_hook", -1);
12451248
if( rc==TH_ERROR ){
@@ -1276,12 +1279,15 @@
12761279
*/
12771280
int Th_CommandNotify(
12781281
const char *zName,
12791282
char cmdFlags
12801283
){
1281
- int rc;
1284
+ int rc = TH_OK;
12821285
Th_FossilInit(TH_INIT_HOOK);
1286
+ if( fossil_getenv("TH1_ENABLE_HOOKS")==0 && !db_get_boolean("th1-hooks", 0) ){
1287
+ return rc;
1288
+ }
12831289
Th_Store("cmd_name", zName);
12841290
Th_StoreList("cmd_args", g.argv, g.argc);
12851291
Th_StoreInt("cmd_flags", cmdFlags);
12861292
rc = Th_Eval(g.interp, 0, "command_notify", -1);
12871293
if( g.thTrace ){
@@ -1301,10 +1307,13 @@
13011307
const char *zName,
13021308
char cmdFlags
13031309
){
13041310
int rc = TH_OK;
13051311
Th_FossilInit(TH_INIT_HOOK);
1312
+ if( fossil_getenv("TH1_ENABLE_HOOKS")==0 && !db_get_boolean("th1-hooks", 0) ){
1313
+ return rc;
1314
+ }
13061315
Th_Store("web_name", zName);
13071316
Th_StoreList("web_args", g.argv, g.argc);
13081317
Th_StoreInt("web_flags", cmdFlags);
13091318
rc = Th_Eval(g.interp, 0, "webpage_hook", -1);
13101319
if( rc==TH_ERROR ){
@@ -1341,12 +1350,15 @@
13411350
*/
13421351
int Th_WebpageNotify(
13431352
const char *zName,
13441353
char cmdFlags
13451354
){
1346
- int rc;
1355
+ int rc = TH_OK;
13471356
Th_FossilInit(TH_INIT_HOOK);
1357
+ if( fossil_getenv("TH1_ENABLE_HOOKS")==0 && !db_get_boolean("th1-hooks", 0) ){
1358
+ return rc;
1359
+ }
13481360
Th_Store("web_name", zName);
13491361
Th_StoreList("web_args", g.argv, g.argc);
13501362
Th_StoreInt("web_flags", cmdFlags);
13511363
rc = Th_Eval(g.interp, 0, "webpage_notify", -1);
13521364
if( g.thTrace ){
13531365
--- src/th_main.c
+++ src/th_main.c
@@ -1236,10 +1236,13 @@
1236 const char *zName,
1237 char cmdFlags
1238 ){
1239 int rc = TH_OK;
1240 Th_FossilInit(TH_INIT_HOOK);
 
 
 
1241 Th_Store("cmd_name", zName);
1242 Th_StoreList("cmd_args", g.argv, g.argc);
1243 Th_StoreInt("cmd_flags", cmdFlags);
1244 rc = Th_Eval(g.interp, 0, "command_hook", -1);
1245 if( rc==TH_ERROR ){
@@ -1276,12 +1279,15 @@
1276 */
1277 int Th_CommandNotify(
1278 const char *zName,
1279 char cmdFlags
1280 ){
1281 int rc;
1282 Th_FossilInit(TH_INIT_HOOK);
 
 
 
1283 Th_Store("cmd_name", zName);
1284 Th_StoreList("cmd_args", g.argv, g.argc);
1285 Th_StoreInt("cmd_flags", cmdFlags);
1286 rc = Th_Eval(g.interp, 0, "command_notify", -1);
1287 if( g.thTrace ){
@@ -1301,10 +1307,13 @@
1301 const char *zName,
1302 char cmdFlags
1303 ){
1304 int rc = TH_OK;
1305 Th_FossilInit(TH_INIT_HOOK);
 
 
 
1306 Th_Store("web_name", zName);
1307 Th_StoreList("web_args", g.argv, g.argc);
1308 Th_StoreInt("web_flags", cmdFlags);
1309 rc = Th_Eval(g.interp, 0, "webpage_hook", -1);
1310 if( rc==TH_ERROR ){
@@ -1341,12 +1350,15 @@
1341 */
1342 int Th_WebpageNotify(
1343 const char *zName,
1344 char cmdFlags
1345 ){
1346 int rc;
1347 Th_FossilInit(TH_INIT_HOOK);
 
 
 
1348 Th_Store("web_name", zName);
1349 Th_StoreList("web_args", g.argv, g.argc);
1350 Th_StoreInt("web_flags", cmdFlags);
1351 rc = Th_Eval(g.interp, 0, "webpage_notify", -1);
1352 if( g.thTrace ){
1353
--- src/th_main.c
+++ src/th_main.c
@@ -1236,10 +1236,13 @@
1236 const char *zName,
1237 char cmdFlags
1238 ){
1239 int rc = TH_OK;
1240 Th_FossilInit(TH_INIT_HOOK);
1241 if( fossil_getenv("TH1_ENABLE_HOOKS")==0 && !db_get_boolean("th1-hooks", 0) ){
1242 return rc;
1243 }
1244 Th_Store("cmd_name", zName);
1245 Th_StoreList("cmd_args", g.argv, g.argc);
1246 Th_StoreInt("cmd_flags", cmdFlags);
1247 rc = Th_Eval(g.interp, 0, "command_hook", -1);
1248 if( rc==TH_ERROR ){
@@ -1276,12 +1279,15 @@
1279 */
1280 int Th_CommandNotify(
1281 const char *zName,
1282 char cmdFlags
1283 ){
1284 int rc = TH_OK;
1285 Th_FossilInit(TH_INIT_HOOK);
1286 if( fossil_getenv("TH1_ENABLE_HOOKS")==0 && !db_get_boolean("th1-hooks", 0) ){
1287 return rc;
1288 }
1289 Th_Store("cmd_name", zName);
1290 Th_StoreList("cmd_args", g.argv, g.argc);
1291 Th_StoreInt("cmd_flags", cmdFlags);
1292 rc = Th_Eval(g.interp, 0, "command_notify", -1);
1293 if( g.thTrace ){
@@ -1301,10 +1307,13 @@
1307 const char *zName,
1308 char cmdFlags
1309 ){
1310 int rc = TH_OK;
1311 Th_FossilInit(TH_INIT_HOOK);
1312 if( fossil_getenv("TH1_ENABLE_HOOKS")==0 && !db_get_boolean("th1-hooks", 0) ){
1313 return rc;
1314 }
1315 Th_Store("web_name", zName);
1316 Th_StoreList("web_args", g.argv, g.argc);
1317 Th_StoreInt("web_flags", cmdFlags);
1318 rc = Th_Eval(g.interp, 0, "webpage_hook", -1);
1319 if( rc==TH_ERROR ){
@@ -1341,12 +1350,15 @@
1350 */
1351 int Th_WebpageNotify(
1352 const char *zName,
1353 char cmdFlags
1354 ){
1355 int rc = TH_OK;
1356 Th_FossilInit(TH_INIT_HOOK);
1357 if( fossil_getenv("TH1_ENABLE_HOOKS")==0 && !db_get_boolean("th1-hooks", 0) ){
1358 return rc;
1359 }
1360 Th_Store("web_name", zName);
1361 Th_StoreList("web_args", g.argv, g.argc);
1362 Th_StoreInt("web_flags", cmdFlags);
1363 rc = Th_Eval(g.interp, 0, "webpage_notify", -1);
1364 if( g.thTrace ){
1365
--- test/th1-hooks.test
+++ test/th1-hooks.test
@@ -21,10 +21,14 @@
2121
fossil test-th-eval "hasfeature th1Hooks"
2222
2323
if {$::RESULT ne "1"} then {
2424
puts "Fossil was not compiled with TH1 hooks support."; return
2525
}
26
+
27
+###############################################################################
28
+
29
+set env(TH1_ENABLE_HOOKS) 1; # TH1 hooks must be enabled for this test.
2630
2731
###############################################################################
2832
2933
proc fossil_th1_hook_http { repository url } {
3034
set suffix [appendArgs [pid] - [clock seconds] .txt]
3135
--- test/th1-hooks.test
+++ test/th1-hooks.test
@@ -21,10 +21,14 @@
21 fossil test-th-eval "hasfeature th1Hooks"
22
23 if {$::RESULT ne "1"} then {
24 puts "Fossil was not compiled with TH1 hooks support."; return
25 }
 
 
 
 
26
27 ###############################################################################
28
29 proc fossil_th1_hook_http { repository url } {
30 set suffix [appendArgs [pid] - [clock seconds] .txt]
31
--- test/th1-hooks.test
+++ test/th1-hooks.test
@@ -21,10 +21,14 @@
21 fossil test-th-eval "hasfeature th1Hooks"
22
23 if {$::RESULT ne "1"} then {
24 puts "Fossil was not compiled with TH1 hooks support."; return
25 }
26
27 ###############################################################################
28
29 set env(TH1_ENABLE_HOOKS) 1; # TH1 hooks must be enabled for this test.
30
31 ###############################################################################
32
33 proc fossil_th1_hook_http { repository url } {
34 set suffix [appendArgs [pid] - [clock seconds] .txt]
35

Keyboard Shortcuts

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