Fossil SCM
Restore previous implementation of the common script function. Add inline docs to indicate its usage.
Commit
348df8f00fd84b44471b2ccd9a0fdbf34fbece0d
Parent
de7681780dc6742…
2 files changed
+4
-1
+17
-10
+4
-1
| --- src/manifest.c | ||
| +++ src/manifest.c | ||
| @@ -2037,11 +2037,14 @@ | ||
| 2037 | 2037 | ); |
| 2038 | 2038 | blob_reset(&comment); |
| 2039 | 2039 | } |
| 2040 | 2040 | db_end_transaction(0); |
| 2041 | 2041 | if( flags & MC_PERMIT_HOOKS ){ |
| 2042 | - result = (xfer_run_script(zScript, zUuid)==TH_OK); | |
| 2042 | + result = (xfer_run_common_script()==TH_OK); | |
| 2043 | + if( result ){ | |
| 2044 | + result = (xfer_run_script(zScript, zUuid)==TH_OK); | |
| 2045 | + } | |
| 2043 | 2046 | } |
| 2044 | 2047 | if( p->type==CFTYPE_MANIFEST ){ |
| 2045 | 2048 | manifest_cache_insert(p); |
| 2046 | 2049 | }else{ |
| 2047 | 2050 | manifest_destroy(p); |
| 2048 | 2051 |
| --- src/manifest.c | |
| +++ src/manifest.c | |
| @@ -2037,11 +2037,14 @@ | |
| 2037 | ); |
| 2038 | blob_reset(&comment); |
| 2039 | } |
| 2040 | db_end_transaction(0); |
| 2041 | if( flags & MC_PERMIT_HOOKS ){ |
| 2042 | result = (xfer_run_script(zScript, zUuid)==TH_OK); |
| 2043 | } |
| 2044 | if( p->type==CFTYPE_MANIFEST ){ |
| 2045 | manifest_cache_insert(p); |
| 2046 | }else{ |
| 2047 | manifest_destroy(p); |
| 2048 |
| --- src/manifest.c | |
| +++ src/manifest.c | |
| @@ -2037,11 +2037,14 @@ | |
| 2037 | ); |
| 2038 | blob_reset(&comment); |
| 2039 | } |
| 2040 | db_end_transaction(0); |
| 2041 | if( flags & MC_PERMIT_HOOKS ){ |
| 2042 | result = (xfer_run_common_script()==TH_OK); |
| 2043 | if( result ){ |
| 2044 | result = (xfer_run_script(zScript, zUuid)==TH_OK); |
| 2045 | } |
| 2046 | } |
| 2047 | if( p->type==CFTYPE_MANIFEST ){ |
| 2048 | manifest_cache_insert(p); |
| 2049 | }else{ |
| 2050 | manifest_destroy(p); |
| 2051 |
+17
-10
| --- src/xfer.c | ||
| +++ src/xfer.c | ||
| @@ -852,22 +852,13 @@ | ||
| 852 | 852 | |
| 853 | 853 | /* |
| 854 | 854 | ** Run the specified TH1 script, if any, and returns 1 on error. |
| 855 | 855 | */ |
| 856 | 856 | int xfer_run_script(const char *zScript, const char *zUuid){ |
| 857 | - static int commonScriptRan = 0; | |
| 858 | 857 | int result; |
| 859 | - if( !commonScriptRan ){ | |
| 860 | - Th_FossilInit(TH_INIT_DEFAULT); | |
| 861 | - result = Th_Eval(g.interp, 0, xfer_common_code(), -1); | |
| 862 | - if( result!=TH_OK ){ | |
| 863 | - fossil_error(1, "%s", Th_GetResult(g.interp, 0)); | |
| 864 | - return result; | |
| 865 | - } | |
| 866 | - commonScriptRan = 1; | |
| 867 | - } | |
| 868 | 858 | if( !zScript ) return TH_OK; |
| 859 | + Th_FossilInit(TH_INIT_DEFAULT); | |
| 869 | 860 | if( zUuid ){ |
| 870 | 861 | result = Th_SetVar(g.interp, "uuid", -1, zUuid, -1); |
| 871 | 862 | if( result!=TH_OK ){ |
| 872 | 863 | fossil_error(1, "%s", Th_GetResult(g.interp, 0)); |
| 873 | 864 | return result; |
| @@ -877,10 +868,26 @@ | ||
| 877 | 868 | if( result!=TH_OK ){ |
| 878 | 869 | fossil_error(1, "%s", Th_GetResult(g.interp, 0)); |
| 879 | 870 | } |
| 880 | 871 | return result; |
| 881 | 872 | } |
| 873 | + | |
| 874 | +/* | |
| 875 | +** Runs the pre-transfer TH1 script, if any, and returns its return code. | |
| 876 | +** This script may be run multiple times. If the script performs actions | |
| 877 | +** that cannot be redone, it should use an internal [if] guard similar to | |
| 878 | +** the following: | |
| 879 | +** | |
| 880 | +** if {![info exists common_done]} { | |
| 881 | +** # ... code here | |
| 882 | +** set common_done 1 | |
| 883 | +** } | |
| 884 | +*/ | |
| 885 | +int xfer_run_common_script(void){ | |
| 886 | + Th_FossilInit(TH_INIT_DEFAULT); | |
| 887 | + return xfer_run_script(xfer_common_code(), 0); | |
| 888 | +} | |
| 882 | 889 | |
| 883 | 890 | /* |
| 884 | 891 | ** If this variable is set, disable login checks. Used for debugging |
| 885 | 892 | ** only. |
| 886 | 893 | */ |
| 887 | 894 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -852,22 +852,13 @@ | |
| 852 | |
| 853 | /* |
| 854 | ** Run the specified TH1 script, if any, and returns 1 on error. |
| 855 | */ |
| 856 | int xfer_run_script(const char *zScript, const char *zUuid){ |
| 857 | static int commonScriptRan = 0; |
| 858 | int result; |
| 859 | if( !commonScriptRan ){ |
| 860 | Th_FossilInit(TH_INIT_DEFAULT); |
| 861 | result = Th_Eval(g.interp, 0, xfer_common_code(), -1); |
| 862 | if( result!=TH_OK ){ |
| 863 | fossil_error(1, "%s", Th_GetResult(g.interp, 0)); |
| 864 | return result; |
| 865 | } |
| 866 | commonScriptRan = 1; |
| 867 | } |
| 868 | if( !zScript ) return TH_OK; |
| 869 | if( zUuid ){ |
| 870 | result = Th_SetVar(g.interp, "uuid", -1, zUuid, -1); |
| 871 | if( result!=TH_OK ){ |
| 872 | fossil_error(1, "%s", Th_GetResult(g.interp, 0)); |
| 873 | return result; |
| @@ -877,10 +868,26 @@ | |
| 877 | if( result!=TH_OK ){ |
| 878 | fossil_error(1, "%s", Th_GetResult(g.interp, 0)); |
| 879 | } |
| 880 | return result; |
| 881 | } |
| 882 | |
| 883 | /* |
| 884 | ** If this variable is set, disable login checks. Used for debugging |
| 885 | ** only. |
| 886 | */ |
| 887 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -852,22 +852,13 @@ | |
| 852 | |
| 853 | /* |
| 854 | ** Run the specified TH1 script, if any, and returns 1 on error. |
| 855 | */ |
| 856 | int xfer_run_script(const char *zScript, const char *zUuid){ |
| 857 | int result; |
| 858 | if( !zScript ) return TH_OK; |
| 859 | Th_FossilInit(TH_INIT_DEFAULT); |
| 860 | if( zUuid ){ |
| 861 | result = Th_SetVar(g.interp, "uuid", -1, zUuid, -1); |
| 862 | if( result!=TH_OK ){ |
| 863 | fossil_error(1, "%s", Th_GetResult(g.interp, 0)); |
| 864 | return result; |
| @@ -877,10 +868,26 @@ | |
| 868 | if( result!=TH_OK ){ |
| 869 | fossil_error(1, "%s", Th_GetResult(g.interp, 0)); |
| 870 | } |
| 871 | return result; |
| 872 | } |
| 873 | |
| 874 | /* |
| 875 | ** Runs the pre-transfer TH1 script, if any, and returns its return code. |
| 876 | ** This script may be run multiple times. If the script performs actions |
| 877 | ** that cannot be redone, it should use an internal [if] guard similar to |
| 878 | ** the following: |
| 879 | ** |
| 880 | ** if {![info exists common_done]} { |
| 881 | ** # ... code here |
| 882 | ** set common_done 1 |
| 883 | ** } |
| 884 | */ |
| 885 | int xfer_run_common_script(void){ |
| 886 | Th_FossilInit(TH_INIT_DEFAULT); |
| 887 | return xfer_run_script(xfer_common_code(), 0); |
| 888 | } |
| 889 | |
| 890 | /* |
| 891 | ** If this variable is set, disable login checks. Used for debugging |
| 892 | ** only. |
| 893 | */ |
| 894 |