Fossil

Check-in [cc5466b8d4]
Login

Check-in [cc5466b8d4]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:One more place where failing run_common_script() should not prevent running manifest_crosslink(). If run_common_script() fails, let the following run_script() output its error-message.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | tkt-change-hook
Files: files | file ages | folders
SHA1: cc5466b8d446ff5eed6e8c16c361b4846e6808d1
User & Date: jan.nijtmans 2013-10-13 15:03:21.892
Context
2013-10-13
15:13
Put back ticket-change in JSON part as well ... (check-in: 12c53e1cb6 user: jan.nijtmans tags: tkt-change-hook)
15:03
One more place where failing run_common_script() should not prevent running manifest_crosslink(). If run_common_script() fails, let the following run_script() output its error-message. ... (check-in: cc5466b8d4 user: jan.nijtmans tags: tkt-change-hook)
14:46
add back the original "ticket-change" hook, as it was in trunk ... (check-in: abef3f1957 user: jan.nijtmans tags: tkt-change-hook)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/branch.c.
151
152
153
154
155
156
157

158
159
160
161
162
163
164
165
  }

  brid = content_put_ex(&branch, 0, 0, 0, isPrivate);
  if( brid==0 ){
    fossil_fatal("trouble committing manifest: %s", g.zErrMsg);
  }
  db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", brid);

  if( run_common_script() || manifest_crosslink(brid, &branch)==0 ){
    fossil_fatal("%s\n", g.zErrMsg);
  }
  assert( blob_is_reset(&branch) );
  content_deltify(rootid, brid, 0);
  zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", brid);
  fossil_print("New branch: %s\n", zUuid);
  if( g.argc==3 ){







>
|







151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
  }

  brid = content_put_ex(&branch, 0, 0, 0, isPrivate);
  if( brid==0 ){
    fossil_fatal("trouble committing manifest: %s", g.zErrMsg);
  }
  db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", brid);
  run_common_script();
  if( manifest_crosslink(brid, &branch)==0 ){
    fossil_fatal("%s\n", g.zErrMsg);
  }
  assert( blob_is_reset(&branch) );
  content_deltify(rootid, brid, 0);
  zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", brid);
  fossil_print("New branch: %s\n", zUuid);
  if( g.argc==3 ){
Changes to src/xfer.c.
916
917
918
919
920
921
922

923
924
925
926



927
928
929
930
931
932
933
934
935
936
937
938
939
940




941
942
943
944
945
946
947
** Run the specified TH1 script, if any, and returns 1 on error.
*/
int run_script(const char *zScript, const char *zUuid){
  int result = 0;
  if( !commonScriptRan || !zScript || !(zScript = db_get(zScript, 0))){
    return 0; /* No script or common script didn't run, return success. */
  }

  if( zUuid ){
    Th_SetVar(g.interp, "uuid", -1, zUuid, strlen(zUuid));
  }
  result = Th_Eval(g.interp, 0, zScript, -1) != TH_OK;



  if (result) fossil_error(1, "%s", Th_GetResult(g.interp, 0));
  return result;
}

/*
** Run the pre-transfer TH1 script, if any, and returns the return code.
** Prepare the "http" command for use in other hook scripts.
*/
int run_common_script(void){
  int result = 0;
  if( !commonScriptRan ){
    Th_FossilInit(TH_INIT_DEFAULT); /* Make sure TH1 is ready. */
    commonScriptRan = 1; /* enable run_script to do something */
    result = run_script("xfer-common-script", 0);




    Th_CreateCommand(g.interp, "http", httpCmd, 0, 0);
  }
  return result;
}

/*
** If this variable is set, disable login checks.  Used for debugging







>
|
|
|
|
>
>
>














>
>
>
>







916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
** Run the specified TH1 script, if any, and returns 1 on error.
*/
int run_script(const char *zScript, const char *zUuid){
  int result = 0;
  if( !commonScriptRan || !zScript || !(zScript = db_get(zScript, 0))){
    return 0; /* No script or common script didn't run, return success. */
  }
  if( commonScriptRan == 1 ){
    if( zUuid ){
      Th_SetVar(g.interp, "uuid", -1, zUuid, strlen(zUuid));
    }
    result = Th_Eval(g.interp, 0, zScript, -1) != TH_OK;
  }else{
    result = TH_ERROR;
  }
  if (result) fossil_error(1, "%s", Th_GetResult(g.interp, 0));
  return result;
}

/*
** Run the pre-transfer TH1 script, if any, and returns the return code.
** Prepare the "http" command for use in other hook scripts.
*/
int run_common_script(void){
  int result = 0;
  if( !commonScriptRan ){
    Th_FossilInit(TH_INIT_DEFAULT); /* Make sure TH1 is ready. */
    commonScriptRan = 1; /* enable run_script to do something */
    result = run_script("xfer-common-script", 0);
    if( result == TH_ERROR ){
      /* Error message is left in th interpreter. */
      commonScriptRan = 2;
    }
    Th_CreateCommand(g.interp, "http", httpCmd, 0, 0);
  }
  return result;
}

/*
** If this variable is set, disable login checks.  Used for debugging