Fossil SCM

Restore previous implementation of the common script function. Add inline docs to indicate its usage.

mistachkin 2013-10-15 08:24 UTC tkt-change-hook
Commit 348df8f00fd84b44471b2ccd9a0fdbf34fbece0d
2 files changed +4 -1 +17 -10
+4 -1
--- src/manifest.c
+++ src/manifest.c
@@ -2037,11 +2037,14 @@
20372037
);
20382038
blob_reset(&comment);
20392039
}
20402040
db_end_transaction(0);
20412041
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
+ }
20432046
}
20442047
if( p->type==CFTYPE_MANIFEST ){
20452048
manifest_cache_insert(p);
20462049
}else{
20472050
manifest_destroy(p);
20482051
--- 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 @@
852852
853853
/*
854854
** Run the specified TH1 script, if any, and returns 1 on error.
855855
*/
856856
int xfer_run_script(const char *zScript, const char *zUuid){
857
- static int commonScriptRan = 0;
858857
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
- }
868858
if( !zScript ) return TH_OK;
859
+ Th_FossilInit(TH_INIT_DEFAULT);
869860
if( zUuid ){
870861
result = Th_SetVar(g.interp, "uuid", -1, zUuid, -1);
871862
if( result!=TH_OK ){
872863
fossil_error(1, "%s", Th_GetResult(g.interp, 0));
873864
return result;
@@ -877,10 +868,26 @@
877868
if( result!=TH_OK ){
878869
fossil_error(1, "%s", Th_GetResult(g.interp, 0));
879870
}
880871
return result;
881872
}
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
+}
882889
883890
/*
884891
** If this variable is set, disable login checks. Used for debugging
885892
** only.
886893
*/
887894
--- 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

Keyboard Shortcuts

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