Exemple #1
0
svn_error_t *
svn_repos__hooks_start_commit(svn_repos_t *repos,
                              apr_hash_t *hooks_env,
                              const char *user,
                              const apr_array_header_t *capabilities,
                              const char *txn_name,
                              apr_pool_t *pool)
{
  const char *hook = svn_repos_start_commit_hook(repos, pool);
  svn_boolean_t broken_link;

  if ((hook = check_hook_cmd(hook, &broken_link, pool)) && broken_link)
    {
      return hook_symlink_error(hook);
    }
  else if (hook)
    {
      const char *args[6];
      char *capabilities_string;

      if (capabilities)
        {
          capabilities_string = svn_cstring_join(capabilities, ":", pool);

          /* Get rid of that annoying final colon. */
          if (capabilities_string[0])
            capabilities_string[strlen(capabilities_string) - 1] = '\0';
        }
      else
        {
          capabilities_string = apr_pstrdup(pool, "");
        }

      args[0] = hook;
      args[1] = svn_dirent_local_style(svn_repos_path(repos, pool), pool);
      args[2] = user ? user : "";
      args[3] = capabilities_string;
      args[4] = txn_name;
      args[5] = NULL;

      SVN_ERR(run_hook_cmd(NULL, SVN_REPOS__HOOK_START_COMMIT, hook, args,
                           hooks_env, NULL, pool));
    }

  return SVN_NO_ERROR;
}
Exemple #2
0
svn_error_t  *
svn_repos__hooks_post_unlock(svn_repos_t *repos,
                             apr_hash_t *hooks_env,
                             const apr_array_header_t *paths,
                             const char *username,
                             apr_pool_t *pool)
{
  const char *hook = svn_repos_post_unlock_hook(repos, pool);
  svn_boolean_t broken_link;

  if ((hook = check_hook_cmd(hook, &broken_link, pool)) && broken_link)
    {
      return hook_symlink_error(hook);
    }
  else if (hook)
    {
      const char *args[5];
      apr_file_t *stdin_handle = NULL;
      svn_string_t *paths_str = svn_string_create(svn_cstring_join
                                                  (paths, "\n", pool),
                                                  pool);

      SVN_ERR(create_temp_file(&stdin_handle, paths_str, pool));

      args[0] = hook;
      args[1] = svn_dirent_local_style(svn_repos_path(repos, pool), pool);
      args[2] = username ? username : "";
      args[3] = NULL;
      args[4] = NULL;

      SVN_ERR(run_hook_cmd(NULL, SVN_REPOS__HOOK_POST_UNLOCK, hook, args,
                           hooks_env, stdin_handle, pool));

      SVN_ERR(svn_io_file_close(stdin_handle, pool));
    }

  return SVN_NO_ERROR;
}
Exemple #3
0
/* fonction callback pour l'appel a svn_client_log4 */
svn_error_t* log_callback(void *baton, svn_log_entry_t *log_entry, apr_pool_t *pool)
{  
  apr_hash_t *revprops = log_entry->revprops;
  int rev = (int)log_entry->revision;
  svn_string_t *author_s, *date_s,  *message_s;
  svn_stringbuf_t *revnum, *author, *day, *parsed_time, *parsed_message;
  const char *date, *day_tmp, *time, *parsed_time_tmp, *message, *parsed_message_tmp;
  apr_array_header_t *date_array, *time_array, *message_array;
  
  // -- Recuperation du champ "revision" --
  char *n = apr_psprintf(pool,"%d\n",rev);
  revnum = svn_stringbuf_create(n,pool); 
 
  // -- Recuperation du champ "auteur" --
  if ((author_s = apr_hash_get(revprops, 
			       SVN_PROP_REVISION_AUTHOR,
			       APR_HASH_KEY_STRING))) {
    author = stringbuf_endline_utf8(author_s->data,pool);
  }
  else
    author = svn_stringbuf_create("Unknown author\n",pool);
   
  // -- Recuperation & traitement du champ "date" --
  if ((date_s = apr_hash_get(revprops, 
			     SVN_PROP_REVISION_DATE,
			     APR_HASH_KEY_STRING))){
    date = date_s->data;
    date_array = svn_cstring_split(date,"T",TRUE,pool);
    day_tmp = ((const char**)date_array->elts)[0];
    day = stringbuf_endline_utf8(day_tmp,pool);
    time = ((const char**)date_array->elts)[1];
    time_array = svn_cstring_split(time,".",TRUE,pool);
    parsed_time_tmp = ((const char**)time_array->elts)[0];
    parsed_time = stringbuf_endline_utf8(parsed_time_tmp,pool);
  }  
  else {
    day = svn_stringbuf_create("???\n",pool);
    parsed_time = svn_stringbuf_create("???\n",pool);
  }
  // -- Recuperation & traitement du champ "message" --
  if ((message_s = apr_hash_get(revprops, 
				SVN_PROP_REVISION_LOG,
				APR_HASH_KEY_STRING))){
    message = message_s->data;
    if (strcmp(message,"") == 0) {
      parsed_message = svn_stringbuf_create(" \n",pool);
    }
    else {
      message_array = svn_cstring_split(message,"\n",TRUE,pool);
      parsed_message_tmp = svn_cstring_join(message_array,"<br/>",pool);
      parsed_message = stringbuf_endline_utf8(parsed_message_tmp,pool);
    }
  }
  else{
    parsed_message = svn_stringbuf_create(" \n",pool);
  }   
   
  svn_stringbuf_appendstr((svn_stringbuf_t *)baton,(const svn_stringbuf_t *)revnum);
  svn_stringbuf_appendstr((svn_stringbuf_t *)baton,(const svn_stringbuf_t *)author);
  svn_stringbuf_appendstr((svn_stringbuf_t *)baton,(const svn_stringbuf_t *)day);
  svn_stringbuf_appendstr((svn_stringbuf_t *)baton,(const svn_stringbuf_t *)parsed_time);
  svn_stringbuf_appendstr((svn_stringbuf_t *)baton,(const svn_stringbuf_t *)parsed_message);
  return SVN_NO_ERROR;
}