Fossil SCM
Improvement to TH_RETURN handling needed for TH1 hooks. Update and correct TH1 hook tests. Add draft documentation for TH1 hooks.
Commit
36f0e47b3275937da8b73a7376c9eec417066e6f84cc4ffb68304fd5ce31d5a9
Parent
5f37eb84cac00ef…
7 files changed
+2
-2
+1
+3
+1
+20
-2
+2
+6
+2
-2
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -735,11 +735,11 @@ | ||
| 735 | 735 | /* |
| 736 | 736 | ** The TH1 return codes from the hook will be handled as follows: |
| 737 | 737 | ** |
| 738 | 738 | ** TH_OK: The xFunc() and the TH1 notification will both be executed. |
| 739 | 739 | ** |
| 740 | - ** TH_ERROR: The xFunc() will be executed, the TH1 notification will be | |
| 740 | + ** TH_ERROR: The xFunc() will be skipped, the TH1 notification will be | |
| 741 | 741 | ** skipped. If the xFunc() is being hooked, the error message |
| 742 | 742 | ** will be emitted. |
| 743 | 743 | ** |
| 744 | 744 | ** TH_BREAK: The xFunc() and the TH1 notification will both be skipped. |
| 745 | 745 | ** |
| @@ -1664,11 +1664,11 @@ | ||
| 1664 | 1664 | /* |
| 1665 | 1665 | ** The TH1 return codes from the hook will be handled as follows: |
| 1666 | 1666 | ** |
| 1667 | 1667 | ** TH_OK: The xFunc() and the TH1 notification will both be executed. |
| 1668 | 1668 | ** |
| 1669 | - ** TH_ERROR: The xFunc() will be executed, the TH1 notification will be | |
| 1669 | + ** TH_ERROR: The xFunc() will be skipped, the TH1 notification will be | |
| 1670 | 1670 | ** skipped. If the xFunc() is being hooked, the error message |
| 1671 | 1671 | ** will be emitted. |
| 1672 | 1672 | ** |
| 1673 | 1673 | ** TH_BREAK: The xFunc() and the TH1 notification will both be skipped. |
| 1674 | 1674 | ** |
| 1675 | 1675 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -735,11 +735,11 @@ | |
| 735 | /* |
| 736 | ** The TH1 return codes from the hook will be handled as follows: |
| 737 | ** |
| 738 | ** TH_OK: The xFunc() and the TH1 notification will both be executed. |
| 739 | ** |
| 740 | ** TH_ERROR: The xFunc() will be executed, the TH1 notification will be |
| 741 | ** skipped. If the xFunc() is being hooked, the error message |
| 742 | ** will be emitted. |
| 743 | ** |
| 744 | ** TH_BREAK: The xFunc() and the TH1 notification will both be skipped. |
| 745 | ** |
| @@ -1664,11 +1664,11 @@ | |
| 1664 | /* |
| 1665 | ** The TH1 return codes from the hook will be handled as follows: |
| 1666 | ** |
| 1667 | ** TH_OK: The xFunc() and the TH1 notification will both be executed. |
| 1668 | ** |
| 1669 | ** TH_ERROR: The xFunc() will be executed, the TH1 notification will be |
| 1670 | ** skipped. If the xFunc() is being hooked, the error message |
| 1671 | ** will be emitted. |
| 1672 | ** |
| 1673 | ** TH_BREAK: The xFunc() and the TH1 notification will both be skipped. |
| 1674 | ** |
| 1675 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -735,11 +735,11 @@ | |
| 735 | /* |
| 736 | ** The TH1 return codes from the hook will be handled as follows: |
| 737 | ** |
| 738 | ** TH_OK: The xFunc() and the TH1 notification will both be executed. |
| 739 | ** |
| 740 | ** TH_ERROR: The xFunc() will be skipped, the TH1 notification will be |
| 741 | ** skipped. If the xFunc() is being hooked, the error message |
| 742 | ** will be emitted. |
| 743 | ** |
| 744 | ** TH_BREAK: The xFunc() and the TH1 notification will both be skipped. |
| 745 | ** |
| @@ -1664,11 +1664,11 @@ | |
| 1664 | /* |
| 1665 | ** The TH1 return codes from the hook will be handled as follows: |
| 1666 | ** |
| 1667 | ** TH_OK: The xFunc() and the TH1 notification will both be executed. |
| 1668 | ** |
| 1669 | ** TH_ERROR: The xFunc() will be skipped, the TH1 notification will be |
| 1670 | ** skipped. If the xFunc() is being hooked, the error message |
| 1671 | ** will be emitted. |
| 1672 | ** |
| 1673 | ** TH_BREAK: The xFunc() and the TH1 notification will both be skipped. |
| 1674 | ** |
| 1675 |
M
src/th.h
+1
| --- src/th.h | ||
| +++ src/th.h | ||
| @@ -102,10 +102,11 @@ | ||
| 102 | 102 | #define TH_OK 0 |
| 103 | 103 | #define TH_ERROR 1 |
| 104 | 104 | #define TH_BREAK 2 |
| 105 | 105 | #define TH_RETURN 3 |
| 106 | 106 | #define TH_CONTINUE 4 |
| 107 | +#define TH_RETURN2 5 | |
| 107 | 108 | |
| 108 | 109 | /* |
| 109 | 110 | ** Set and get the interpreter result. |
| 110 | 111 | */ |
| 111 | 112 | int Th_SetResult(Th_Interp *, const char *, int); |
| 112 | 113 |
| --- src/th.h | |
| +++ src/th.h | |
| @@ -102,10 +102,11 @@ | |
| 102 | #define TH_OK 0 |
| 103 | #define TH_ERROR 1 |
| 104 | #define TH_BREAK 2 |
| 105 | #define TH_RETURN 3 |
| 106 | #define TH_CONTINUE 4 |
| 107 | |
| 108 | /* |
| 109 | ** Set and get the interpreter result. |
| 110 | */ |
| 111 | int Th_SetResult(Th_Interp *, const char *, int); |
| 112 |
| --- src/th.h | |
| +++ src/th.h | |
| @@ -102,10 +102,11 @@ | |
| 102 | #define TH_OK 0 |
| 103 | #define TH_ERROR 1 |
| 104 | #define TH_BREAK 2 |
| 105 | #define TH_RETURN 3 |
| 106 | #define TH_CONTINUE 4 |
| 107 | #define TH_RETURN2 5 |
| 108 | |
| 109 | /* |
| 110 | ** Set and get the interpreter result. |
| 111 | */ |
| 112 | int Th_SetResult(Th_Interp *, const char *, int); |
| 113 |
+3
| --- src/th_lang.c | ||
| +++ src/th_lang.c | ||
| @@ -432,10 +432,13 @@ | ||
| 432 | 432 | procargs.argl = argl; |
| 433 | 433 | rc = Th_InFrame(interp, proc_call2, (void *)p, (void *)&procargs); |
| 434 | 434 | |
| 435 | 435 | if( rc==TH_RETURN ){ |
| 436 | 436 | rc = TH_OK; |
| 437 | + } | |
| 438 | + if( rc==TH_RETURN2 ){ | |
| 439 | + rc = TH_RETURN; | |
| 437 | 440 | } |
| 438 | 441 | return rc; |
| 439 | 442 | } |
| 440 | 443 | |
| 441 | 444 | /* |
| 442 | 445 |
| --- src/th_lang.c | |
| +++ src/th_lang.c | |
| @@ -432,10 +432,13 @@ | |
| 432 | procargs.argl = argl; |
| 433 | rc = Th_InFrame(interp, proc_call2, (void *)p, (void *)&procargs); |
| 434 | |
| 435 | if( rc==TH_RETURN ){ |
| 436 | rc = TH_OK; |
| 437 | } |
| 438 | return rc; |
| 439 | } |
| 440 | |
| 441 | /* |
| 442 |
| --- src/th_lang.c | |
| +++ src/th_lang.c | |
| @@ -432,10 +432,13 @@ | |
| 432 | procargs.argl = argl; |
| 433 | rc = Th_InFrame(interp, proc_call2, (void *)p, (void *)&procargs); |
| 434 | |
| 435 | if( rc==TH_RETURN ){ |
| 436 | rc = TH_OK; |
| 437 | } |
| 438 | if( rc==TH_RETURN2 ){ |
| 439 | rc = TH_RETURN; |
| 440 | } |
| 441 | return rc; |
| 442 | } |
| 443 | |
| 444 | /* |
| 445 |
+1
| --- src/th_main.c | ||
| +++ src/th_main.c | ||
| @@ -299,10 +299,11 @@ | ||
| 299 | 299 | case TH_OK: return nullIfOk ? 0 : "TH_OK"; |
| 300 | 300 | case TH_ERROR: return "TH_ERROR"; |
| 301 | 301 | case TH_BREAK: return "TH_BREAK"; |
| 302 | 302 | case TH_RETURN: return "TH_RETURN"; |
| 303 | 303 | case TH_CONTINUE: return "TH_CONTINUE"; |
| 304 | + case TH_RETURN2: return "TH_RETURN2"; | |
| 304 | 305 | default: { |
| 305 | 306 | sqlite3_snprintf(sizeof(zRc), zRc, "TH1 return code %d", rc); |
| 306 | 307 | } |
| 307 | 308 | } |
| 308 | 309 | return zRc; |
| 309 | 310 |
| --- src/th_main.c | |
| +++ src/th_main.c | |
| @@ -299,10 +299,11 @@ | |
| 299 | case TH_OK: return nullIfOk ? 0 : "TH_OK"; |
| 300 | case TH_ERROR: return "TH_ERROR"; |
| 301 | case TH_BREAK: return "TH_BREAK"; |
| 302 | case TH_RETURN: return "TH_RETURN"; |
| 303 | case TH_CONTINUE: return "TH_CONTINUE"; |
| 304 | default: { |
| 305 | sqlite3_snprintf(sizeof(zRc), zRc, "TH1 return code %d", rc); |
| 306 | } |
| 307 | } |
| 308 | return zRc; |
| 309 |
| --- src/th_main.c | |
| +++ src/th_main.c | |
| @@ -299,10 +299,11 @@ | |
| 299 | case TH_OK: return nullIfOk ? 0 : "TH_OK"; |
| 300 | case TH_ERROR: return "TH_ERROR"; |
| 301 | case TH_BREAK: return "TH_BREAK"; |
| 302 | case TH_RETURN: return "TH_RETURN"; |
| 303 | case TH_CONTINUE: return "TH_CONTINUE"; |
| 304 | case TH_RETURN2: return "TH_RETURN2"; |
| 305 | default: { |
| 306 | sqlite3_snprintf(sizeof(zRc), zRc, "TH1 return code %d", rc); |
| 307 | } |
| 308 | } |
| 309 | return zRc; |
| 310 |
+20
-2
| --- test/th1-hooks.test | ||
| +++ test/th1-hooks.test | ||
| @@ -70,11 +70,11 @@ | ||
| 70 | 70 | } elseif {$::cmd_name eq "test3"} { |
| 71 | 71 | emit_hook_log |
| 72 | 72 | break "TH_BREAK return code" |
| 73 | 73 | } elseif {$::cmd_name eq "test4"} { |
| 74 | 74 | emit_hook_log |
| 75 | - return -code 2 "TH_RETURN return code" | |
| 75 | + return -code 5 "TH_RETURN return code" | |
| 76 | 76 | } elseif {$::cmd_name eq "timeline"} { |
| 77 | 77 | set length [llength $::cmd_args] |
| 78 | 78 | set length [expr {$length - 1}] |
| 79 | 79 | if {[lindex $::cmd_args $length] eq "custom"} { |
| 80 | 80 | append_hook_log "CUSTOM TIMELINE" |
| @@ -82,10 +82,13 @@ | ||
| 82 | 82 | return "custom timeline" |
| 83 | 83 | } elseif {[lindex $::cmd_args $length] eq "custom2"} { |
| 84 | 84 | emit_hook_log |
| 85 | 85 | puts "+++ some stuff here +++" |
| 86 | 86 | continue "custom2 timeline" |
| 87 | + } elseif {[lindex $::cmd_args $length] eq "custom3"} { | |
| 88 | + emit_hook_log | |
| 89 | + return -code 5 "TH_RETURN return code" | |
| 87 | 90 | } elseif {[lindex $::cmd_args $length] eq "now"} { |
| 88 | 91 | emit_hook_log |
| 89 | 92 | return "now timeline" |
| 90 | 93 | } else { |
| 91 | 94 | emit_hook_log |
| @@ -142,10 +145,18 @@ | ||
| 142 | 145 | +++ some stuff here +++ |
| 143 | 146 | <h1><b>command_hook timeline command_notify timeline</b></h1>}} |
| 144 | 147 | |
| 145 | 148 | ############################################################################### |
| 146 | 149 | |
| 150 | +fossil timeline custom3; # NOTE: Bad "WHEN" argument. | |
| 151 | + | |
| 152 | +test th1-cmd-hooks-1c {[normalize_result] eq \ | |
| 153 | +{<h1><b>command_hook timeline</b></h1> | |
| 154 | +unknown check-in or invalid date: custom3}} | |
| 155 | + | |
| 156 | +############################################################################### | |
| 157 | + | |
| 147 | 158 | fossil timeline |
| 148 | 159 | test th1-cmd-hooks-2a {[first_data_line] eq \ |
| 149 | 160 | {<h1><b>command_hook timeline</b></h1>}} |
| 150 | 161 | |
| 151 | 162 | test th1-cmd-hooks-2b {[second_data_line] eq {ERROR: unsupported timeline}} |
| @@ -185,13 +196,20 @@ | ||
| 185 | 196 | {<h1><b>command_hook test3</b></h1>}} |
| 186 | 197 | |
| 187 | 198 | ############################################################################### |
| 188 | 199 | |
| 189 | 200 | fossil test4 |
| 190 | -test th1-custom-cmd-4a {[string trim $RESULT] eq \ | |
| 201 | + | |
| 202 | +test th1-custom-cmd-4a {[first_data_line] eq \ | |
| 191 | 203 | {<h1><b>command_hook test4</b></h1>}} |
| 192 | 204 | |
| 205 | +test th1-custom-cmd-4b {[regexp -- \ | |
| 206 | + {: unknown command: test4$} [second_data_line]]} | |
| 207 | + | |
| 208 | +test th1-custom-cmd-4d {[regexp -- \ | |
| 209 | + {: use "help" for more information$} [third_data_line]]} | |
| 210 | + | |
| 193 | 211 | ############################################################################### |
| 194 | 212 | |
| 195 | 213 | set RESULT [test_fossil_http $repository $dataFileName /timeline] |
| 196 | 214 | |
| 197 | 215 | test th1-web-hooks-1a {[regexp \ |
| 198 | 216 |
| --- test/th1-hooks.test | |
| +++ test/th1-hooks.test | |
| @@ -70,11 +70,11 @@ | |
| 70 | } elseif {$::cmd_name eq "test3"} { |
| 71 | emit_hook_log |
| 72 | break "TH_BREAK return code" |
| 73 | } elseif {$::cmd_name eq "test4"} { |
| 74 | emit_hook_log |
| 75 | return -code 2 "TH_RETURN return code" |
| 76 | } elseif {$::cmd_name eq "timeline"} { |
| 77 | set length [llength $::cmd_args] |
| 78 | set length [expr {$length - 1}] |
| 79 | if {[lindex $::cmd_args $length] eq "custom"} { |
| 80 | append_hook_log "CUSTOM TIMELINE" |
| @@ -82,10 +82,13 @@ | |
| 82 | return "custom timeline" |
| 83 | } elseif {[lindex $::cmd_args $length] eq "custom2"} { |
| 84 | emit_hook_log |
| 85 | puts "+++ some stuff here +++" |
| 86 | continue "custom2 timeline" |
| 87 | } elseif {[lindex $::cmd_args $length] eq "now"} { |
| 88 | emit_hook_log |
| 89 | return "now timeline" |
| 90 | } else { |
| 91 | emit_hook_log |
| @@ -142,10 +145,18 @@ | |
| 142 | +++ some stuff here +++ |
| 143 | <h1><b>command_hook timeline command_notify timeline</b></h1>}} |
| 144 | |
| 145 | ############################################################################### |
| 146 | |
| 147 | fossil timeline |
| 148 | test th1-cmd-hooks-2a {[first_data_line] eq \ |
| 149 | {<h1><b>command_hook timeline</b></h1>}} |
| 150 | |
| 151 | test th1-cmd-hooks-2b {[second_data_line] eq {ERROR: unsupported timeline}} |
| @@ -185,13 +196,20 @@ | |
| 185 | {<h1><b>command_hook test3</b></h1>}} |
| 186 | |
| 187 | ############################################################################### |
| 188 | |
| 189 | fossil test4 |
| 190 | test th1-custom-cmd-4a {[string trim $RESULT] eq \ |
| 191 | {<h1><b>command_hook test4</b></h1>}} |
| 192 | |
| 193 | ############################################################################### |
| 194 | |
| 195 | set RESULT [test_fossil_http $repository $dataFileName /timeline] |
| 196 | |
| 197 | test th1-web-hooks-1a {[regexp \ |
| 198 |
| --- test/th1-hooks.test | |
| +++ test/th1-hooks.test | |
| @@ -70,11 +70,11 @@ | |
| 70 | } elseif {$::cmd_name eq "test3"} { |
| 71 | emit_hook_log |
| 72 | break "TH_BREAK return code" |
| 73 | } elseif {$::cmd_name eq "test4"} { |
| 74 | emit_hook_log |
| 75 | return -code 5 "TH_RETURN return code" |
| 76 | } elseif {$::cmd_name eq "timeline"} { |
| 77 | set length [llength $::cmd_args] |
| 78 | set length [expr {$length - 1}] |
| 79 | if {[lindex $::cmd_args $length] eq "custom"} { |
| 80 | append_hook_log "CUSTOM TIMELINE" |
| @@ -82,10 +82,13 @@ | |
| 82 | return "custom timeline" |
| 83 | } elseif {[lindex $::cmd_args $length] eq "custom2"} { |
| 84 | emit_hook_log |
| 85 | puts "+++ some stuff here +++" |
| 86 | continue "custom2 timeline" |
| 87 | } elseif {[lindex $::cmd_args $length] eq "custom3"} { |
| 88 | emit_hook_log |
| 89 | return -code 5 "TH_RETURN return code" |
| 90 | } elseif {[lindex $::cmd_args $length] eq "now"} { |
| 91 | emit_hook_log |
| 92 | return "now timeline" |
| 93 | } else { |
| 94 | emit_hook_log |
| @@ -142,10 +145,18 @@ | |
| 145 | +++ some stuff here +++ |
| 146 | <h1><b>command_hook timeline command_notify timeline</b></h1>}} |
| 147 | |
| 148 | ############################################################################### |
| 149 | |
| 150 | fossil timeline custom3; # NOTE: Bad "WHEN" argument. |
| 151 | |
| 152 | test th1-cmd-hooks-1c {[normalize_result] eq \ |
| 153 | {<h1><b>command_hook timeline</b></h1> |
| 154 | unknown check-in or invalid date: custom3}} |
| 155 | |
| 156 | ############################################################################### |
| 157 | |
| 158 | fossil timeline |
| 159 | test th1-cmd-hooks-2a {[first_data_line] eq \ |
| 160 | {<h1><b>command_hook timeline</b></h1>}} |
| 161 | |
| 162 | test th1-cmd-hooks-2b {[second_data_line] eq {ERROR: unsupported timeline}} |
| @@ -185,13 +196,20 @@ | |
| 196 | {<h1><b>command_hook test3</b></h1>}} |
| 197 | |
| 198 | ############################################################################### |
| 199 | |
| 200 | fossil test4 |
| 201 | |
| 202 | test th1-custom-cmd-4a {[first_data_line] eq \ |
| 203 | {<h1><b>command_hook test4</b></h1>}} |
| 204 | |
| 205 | test th1-custom-cmd-4b {[regexp -- \ |
| 206 | {: unknown command: test4$} [second_data_line]]} |
| 207 | |
| 208 | test th1-custom-cmd-4d {[regexp -- \ |
| 209 | {: use "help" for more information$} [third_data_line]]} |
| 210 | |
| 211 | ############################################################################### |
| 212 | |
| 213 | set RESULT [test_fossil_http $repository $dataFileName /timeline] |
| 214 | |
| 215 | test th1-web-hooks-1a {[regexp \ |
| 216 |
+2
| --- www/index.wiki | ||
| +++ www/index.wiki | ||
| @@ -127,10 +127,12 @@ | ||
| 127 | 127 | [http://www.sqliteconcepts.org/THManual.pdf | TH1 scripting language], |
| 128 | 128 | used to customize [./custom_ticket.wiki | ticketing], and several other |
| 129 | 129 | subsystems, including [./customskin.md | theming]. |
| 130 | 130 | * List of [./th1.md | TH1 commands provided by Fossil itself] that expose |
| 131 | 131 | its key functionality to TH1 scripts. |
| 132 | + * List of [./th1-hooks.md | TH1 hooks exposed by Fossil] that enable | |
| 133 | + customization of commands and web pages. | |
| 132 | 134 | * A free hosting server for Fossil repositories is available at |
| 133 | 135 | [http://chiselapp.com/]. |
| 134 | 136 | * How to [./server.wiki | set up a server] for your repository. |
| 135 | 137 | * Customizing the [./custom_ticket.wiki | ticket system]. |
| 136 | 138 | * Methods to [./checkin_names.wiki | identify a specific check-in]. |
| 137 | 139 | |
| 138 | 140 | ADDED www/th1-hooks.md |
| --- www/index.wiki | |
| +++ www/index.wiki | |
| @@ -127,10 +127,12 @@ | |
| 127 | [http://www.sqliteconcepts.org/THManual.pdf | TH1 scripting language], |
| 128 | used to customize [./custom_ticket.wiki | ticketing], and several other |
| 129 | subsystems, including [./customskin.md | theming]. |
| 130 | * List of [./th1.md | TH1 commands provided by Fossil itself] that expose |
| 131 | its key functionality to TH1 scripts. |
| 132 | * A free hosting server for Fossil repositories is available at |
| 133 | [http://chiselapp.com/]. |
| 134 | * How to [./server.wiki | set up a server] for your repository. |
| 135 | * Customizing the [./custom_ticket.wiki | ticket system]. |
| 136 | * Methods to [./checkin_names.wiki | identify a specific check-in]. |
| 137 | |
| 138 | DDED www/th1-hooks.md |
| --- www/index.wiki | |
| +++ www/index.wiki | |
| @@ -127,10 +127,12 @@ | |
| 127 | [http://www.sqliteconcepts.org/THManual.pdf | TH1 scripting language], |
| 128 | used to customize [./custom_ticket.wiki | ticketing], and several other |
| 129 | subsystems, including [./customskin.md | theming]. |
| 130 | * List of [./th1.md | TH1 commands provided by Fossil itself] that expose |
| 131 | its key functionality to TH1 scripts. |
| 132 | * List of [./th1-hooks.md | TH1 hooks exposed by Fossil] that enable |
| 133 | customization of commands and web pages. |
| 134 | * A free hosting server for Fossil repositories is available at |
| 135 | [http://chiselapp.com/]. |
| 136 | * How to [./server.wiki | set up a server] for your repository. |
| 137 | * Customizing the [./custom_ticket.wiki | ticket system]. |
| 138 | * Methods to [./checkin_names.wiki | identify a specific check-in]. |
| 139 | |
| 140 | DDED www/th1-hooks.md |
+6
| --- a/www/th1-hooks.md | ||
| +++ b/www/th1-hooks.md | ||
| @@ -0,0 +1,6 @@ | ||
| 1 | +TH1 Hooks | |
| 2 | +========= | |
| 3 | + | |
| 4 | +<big><big><big><font color="red">** DRAFT **</font></big></big></big> | |
| 5 | + | |
| 6 | +The ** |
| --- a/www/th1-hooks.md | |
| +++ b/www/th1-hooks.md | |
| @@ -0,0 +1,6 @@ | |
| --- a/www/th1-hooks.md | |
| +++ b/www/th1-hooks.md | |
| @@ -0,0 +1,6 @@ | |
| 1 | TH1 Hooks |
| 2 | ========= |
| 3 | |
| 4 | <big><big><big><font color="red">** DRAFT **</font></big></big></big> |
| 5 | |
| 6 | The ** |