I can’t really see it using just the context in this patch, but doesn’t this undo the don’t parse if no hook script exists patch from Ivan?
Bert
From: cmpilato_at_apache.org
Sent: Wednesday, April 3, 2013 7:51 PM
To: commits_at_subversion.apache.org
Author: cmpilato
Date: Wed Apr 3 17:51:56 2013
New Revision: 1464122
URL: http://svn.apache.org/r1464122
Log:
Avoid parsing the hooks-env file multiple times for closely-knit hook
invocations, specifically the pre-/post- pairs for commit, revprop
change, lock, and unlock operations.
* subversion/libsvn_repos/repos.h,
* subversion/libsvn_repos/hooks.c
(svn_repos__parse_hooks_env): Was parse_hooks_env().
(svn_repos__hooks_start_commit,
svn_repos__hooks_pre_commit,
svn_repos__hooks_post_commit,
svn_repos__hooks_pre_revprop_change,
svn_repos__hooks_post_revprop_change,
svn_repos__hooks_pre_lock,
svn_repos__hooks_post_lock,
svn_repos__hooks_pre_unlock,
svn_repos__hooks_post_unlock): Add 'hooks_env' parameter, used now
instead of calling parse_hooks_env() from within.
* subversion/libsvn_repos/commit.c
(complete_cb, svn_repos__get_commit_ev2): Call
svn_repos__parse_hooks_env(), and update calls to hook wrapper
functions.
* subversion/libsvn_repos/fs-wrap.c
(svn_repos_fs_commit_txn, svn_repos_fs_begin_txn_for_commit2,
svn_repos_fs_change_rev_prop4, svn_repos_fs_lock, svn_repos_fs_unlock):
Call svn_repos__parse_hooks_env(), and update calls to hook wrapper
functions.
* subversion/libsvn_repos/load-fs-vtable.c
(close_revision): Call svn_repos__parse_hooks_env(), and update
calls to hook wrapper functions.
Modified:
subversion/trunk/subversion/libsvn_repos/commit.c
subversion/trunk/subversion/libsvn_repos/fs-wrap.c
subversion/trunk/subversion/libsvn_repos/hooks.c
subversion/trunk/subversion/libsvn_repos/load-fs-vtable.c
subversion/trunk/subversion/libsvn_repos/repos.h
Modified: subversion/trunk/subversion/libsvn_repos/commit.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/commit.c?rev=1464122&r1=1464121&r2=1464122&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/commit.c (original)
+++ subversion/trunk/subversion/libsvn_repos/commit.c Wed Apr 3 17:51:56 2013
@@ -1295,10 +1295,16 @@ complete_cb(void *baton,
const char *conflict_path;
svn_error_t *err;
const char *post_commit_errstr;
+ apr_hash_t *hooks_env;
+
+ /* Parse the hooks-env file (if any). */
+ SVN_ERR(svn_repos__parse_hooks_env(&hooks_env, eb->repos->hooks_env_path,
+ scratch_pool, scratch_pool));
/* The transaction has been fully edited. Let the pre-commit hook
have a look at the thing. */
- SVN_ERR(svn_repos__hooks_pre_commit(eb->repos, eb->txn_name, scratch_pool));
+ SVN_ERR(svn_repos__hooks_pre_commit(eb->repos, hooks_env,
+ eb->txn_name, scratch_pool));
/* Hook is done. Let's do the actual commit. */
SVN_ERR(svn_fs__editor_commit(&revision, &post_commit_err, &conflict_path,
@@ -1314,8 +1320,8 @@ complete_cb(void *baton,
Other errors may have occurred within the FS (specified by the
POST_COMMIT_ERR localvar), but we need to run the hooks. */
SVN_ERR_ASSERT(SVN_IS_VALID_REVNUM(revision));
- err = svn_repos__hooks_post_commit(eb->repos, revision, eb->txn_name,
- scratch_pool);
+ err = svn_repos__hooks_post_commit(eb->repos, hooks_env, revision,
+ eb->txn_name, scratch_pool);
if (err)
err = svn_error_create(SVN_ERR_REPOS_POST_COMMIT_HOOK_FAILED, err,
_("Commit succeeded, but post-commit hook failed"));
@@ -1405,6 +1411,11 @@ svn_repos__get_commit_ev2(svn_editor_t *
};
struct ev2_baton *eb;
const svn_string_t *author;
+ apr_hash_t *hooks_env;
+
+ /* Parse the hooks-env file (if any). */
+ SVN_ERR(svn_repos__parse_hooks_env(&hooks_env, repos->hooks_env_path,
+ scratch_pool, scratch_pool));
/* Can the user modify the repository at all? */
/* ### check against AUTHZ. */
@@ -1428,7 +1439,8 @@ svn_repos__get_commit_ev2(svn_editor_t *
SVN_ERR(apply_revprops(repos->fs, eb->txn_name, revprops, scratch_pool));
/* Okay... some access is allowed. Let's run the start-commit hook. */
- SVN_ERR(svn_repos__hooks_start_commit(repos, author ? author->data : NULL,
+ SVN_ERR(svn_repos__hooks_start_commit(repos, hooks_env,
+ author ? author->data : NULL,
repos->client_capabilities,
eb->txn_name, scratch_pool));
Modified: subversion/trunk/subversion/libsvn_repos/fs-wrap.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/fs-wrap.c?rev=1464122&r1=1464121&r2=1464122&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/fs-wrap.c (original)
+++ subversion/trunk/subversion/libsvn_repos/fs-wrap.c Wed Apr 3 17:51:56 2013
@@ -54,12 +54,17 @@ svn_repos_fs_commit_txn(const char **con
apr_hash_t *props;
apr_pool_t *iterpool;
apr_hash_index_t *hi;
+ apr_hash_t *hooks_env;
*new_rev = SVN_INVALID_REVNUM;
+ /* Parse the hooks-env file (if any). */
+ SVN_ERR(svn_repos__parse_hooks_env(&hooks_env, repos->hooks_env_path,
+ pool, pool));
+
/* Run pre-commit hooks. */
SVN_ERR(svn_fs_txn_name(&txn_name, txn, pool));
- SVN_ERR(svn_repos__hooks_pre_commit(repos, txn_name, pool));
+ SVN_ERR(svn_repos__hooks_pre_commit(repos, hooks_env, txn_name, pool));
/* Remove any ephemeral transaction properties. */
SVN_ERR(svn_fs_txn_proplist(&props, txn, pool));
@@ -85,7 +90,8 @@ svn_repos_fs_commit_txn(const char **con
return err;
/* Run post-commit hooks. */
- if ((err2 = svn_repos__hooks_post_commit(repos, *new_rev, txn_name, pool)))
+ if ((err2 = svn_repos__hooks_post_commit(repos, hooks_env,
+ *new_rev, txn_name, pool)))
{
err2 = svn_error_create
(SVN_ERR_REPOS_POST_COMMIT_HOOK_FAILED, err2,
@@ -110,6 +116,11 @@ svn_repos_fs_begin_txn_for_commit2(svn_f
apr_array_header_t *revprops;
const char *txn_name;
svn_string_t *author = svn_hash_gets(revprop_table, SVN_PROP_REVISION_AUTHOR);
+ apr_hash_t *hooks_env;
+
+ /* Parse the hooks-env file (if any). */
+ SVN_ERR(svn_repos__parse_hooks_env(&hooks_env, repos->hooks_env_path,
+ pool, pool));
/* Begin the transaction, ask for the fs to do on-the-fly lock checks.
We fetch its name, too, so the start-commit hook can use it. */
@@ -124,7 +135,8 @@ svn_repos_fs_begin_txn_for_commit2(svn_f
SVN_ERR(svn_repos_fs_change_txn_props(*txn_p, revprops, pool));
/* Run start-commit hooks. */
- SVN_ERR(svn_repos__hooks_start_commit(repos, author ? author->data : NULL,
+ SVN_ERR(svn_repos__hooks_start_commit(repos, hooks_env,
+ author ? author->data : NULL,
repos->client_capabilities, txn_name,
pool));
return SVN_NO_ERROR;
@@ -317,6 +329,7 @@ svn_repos_fs_change_rev_prop4(svn_repos_
{
const svn_string_t *old_value;
char action;
+ apr_hash_t *hooks_env = NULL;
SVN_ERR(svn_repos__validate_prop(name, new_value, pool));
@@ -343,17 +356,24 @@ svn_repos_fs_change_rev_prop4(svn_repos_
else
action = 'M';
+ /* Parse the hooks-env file (if any, and if to be used). */
+ if (use_post_revprop_change_hook || use_post_revprop_change_hook)
+ SVN_ERR(svn_repos__parse_hooks_env(&hooks_env, repos->hooks_env_path,
+ pool, pool));
+
/* ### currently not passing the old_value to hooks */
if (use_pre_revprop_change_hook)
- SVN_ERR(svn_repos__hooks_pre_revprop_change(repos, rev, author, name,
- new_value, action, pool));
+ SVN_ERR(svn_repos__hooks_pre_revprop_change(repos, hooks_env, rev,
+ author, name, new_value,
+ action, pool));
SVN_ERR(svn_fs_change_rev_prop2(repos->fs, rev, name,
&old_value, new_value, pool));
if (use_post_revprop_change_hook)
- SVN_ERR(svn_repos__hooks_post_revprop_change(repos, rev, author, name,
- old_value, action, pool));
+ SVN_ERR(svn_repos__hooks_post_revprop_change(repos, hooks_env, rev,
+ author, name, old_value,
+ action, pool));
}
else /* rev is either unreadable or only partially readable */
{
@@ -472,6 +492,11 @@ svn_repos_fs_lock(svn_lock_t **lock,
const char *username = NULL;
const char *new_token;
apr_array_header_t *paths;
+ apr_hash_t *hooks_env;
+
+ /* Parse the hooks-env file (if any). */
+ SVN_ERR(svn_repos__parse_hooks_env(&hooks_env, repos->hooks_env_path,
+ pool, pool));
/* Setup an array of paths in anticipation of the ra layers handling
multiple locks in one request (1.3 most likely). This is only
@@ -490,8 +515,8 @@ svn_repos_fs_lock(svn_lock_t **lock,
/* Run pre-lock hook. This could throw error, preventing
svn_fs_lock() from happening. */
- SVN_ERR(svn_repos__hooks_pre_lock(repos, &new_token, path, username, comment,
- steal_lock, pool));
+ SVN_ERR(svn_repos__hooks_pre_lock(repos, hooks_env, &new_token, path,
+ username, comment, steal_lock, pool));
if (*new_token)
token = new_token;
@@ -500,7 +525,8 @@ svn_repos_fs_lock(svn_lock_t **lock,
expiration_date, current_rev, steal_lock, pool));
/* Run post-lock hook. */
- if ((err = svn_repos__hooks_post_lock(repos, paths, username, pool)))
+ if ((err = svn_repos__hooks_post_lock(repos, hooks_env,
+ paths, username, pool)))
return svn_error_create
(SVN_ERR_REPOS_POST_LOCK_HOOK_FAILED, err,
"Lock succeeded, but post-lock hook failed");
@@ -519,10 +545,17 @@ svn_repos_fs_unlock(svn_repos_t *repos,
svn_error_t *err;
svn_fs_access_t *access_ctx = NULL;
const char *username = NULL;
+ apr_array_header_t *paths;
+ apr_hash_t *hooks_env;
+
+ /* Parse the hooks-env file (if any). */
+ SVN_ERR(svn_repos__parse_hooks_env(&hooks_env, repos->hooks_env_path,
+ pool, pool));
+
/* Setup an array of paths in anticipation of the ra layers handling
multiple locks in one request (1.3 most likely). This is only
used by svn_repos__hooks_post_lock. */
- apr_array_header_t *paths = apr_array_make(pool, 1, sizeof(const char *));
+ paths = apr_array_make(pool, 1, sizeof(const char *));
APR_ARRAY_PUSH(paths, const char *) = path;
SVN_ERR(svn_fs_get_access(&access_ctx, repos->fs));
@@ -537,14 +570,15 @@ svn_repos_fs_unlock(svn_repos_t *repos,
/* Run pre-unlock hook. This could throw error, preventing
svn_fs_unlock() from happening. */
- SVN_ERR(svn_repos__hooks_pre_unlock(repos, path, username, token,
+ SVN_ERR(svn_repos__hooks_pre_unlock(repos, hooks_env, path, username, token,
break_lock, pool));
/* Unlock. */
SVN_ERR(svn_fs_unlock(repos->fs, path, token, break_lock, pool));
/* Run post-unlock hook. */
- if ((err = svn_repos__hooks_post_unlock(repos, paths, username, pool)))
+ if ((err = svn_repos__hooks_post_unlock(repos, hooks_env, paths,
+ username, pool)))
return svn_error_create
(SVN_ERR_REPOS_POST_UNLOCK_HOOK_FAILED, err,
_("Unlock succeeded, but post-unlock hook failed"));
Modified: subversion/trunk/subversion/libsvn_repos/hooks.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/hooks.c?rev=1464122&r1=1464121&r2=1464122&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/hooks.c (original)
+++ subversion/trunk/subversion/libsvn_repos/hooks.c Wed Apr 3 17:51:56 2013
@@ -410,12 +410,11 @@ parse_hooks_env_section(const char *name
return TRUE;
}
-/* Parse the hooks env file for this repository. */
-static svn_error_t *
-parse_hooks_env(apr_hash_t **hooks_env_p,
- const char *local_abspath,
- apr_pool_t *result_pool,
- apr_pool_t *scratch_pool)
+svn_error_t *
+svn_repos__parse_hooks_env(apr_hash_t **hooks_env_p,
+ const char *local_abspath,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool)
{
svn_config_t *cfg;
struct parse_hooks_env_section_baton b;
@@ -448,6 +447,7 @@ hook_symlink_error(const char *hook)
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,
@@ -464,7 +464,6 @@ svn_repos__hooks_start_commit(svn_repos_
{
const char *args[6];
char *capabilities_string;
- apr_hash_t *hooks_env;
if (capabilities)
{
@@ -479,8 +478,6 @@ svn_repos__hooks_start_commit(svn_repos_
capabilities_string = apr_pstrdup(pool, "");
}
- SVN_ERR(parse_hooks_env(&hooks_env, repos->hooks_env_path, pool, pool));
-
args[0] = hook;
args[1] = svn_dirent_local_style(svn_repos_path(repos, pool), pool);
args[2] = user ? user : "";
@@ -533,6 +530,7 @@ lock_token_content(apr_file_t **handle,
svn_error_t *
svn_repos__hooks_pre_commit(svn_repos_t *repos,
+ apr_hash_t *hooks_env,
const char *txn_name,
apr_pool_t *pool)
{
@@ -548,7 +546,6 @@ svn_repos__hooks_pre_commit(svn_repos_t
const char *args[4];
svn_fs_access_t *access_ctx;
apr_file_t *stdin_handle = NULL;
- apr_hash_t *hooks_env;
args[0] = hook;
args[1] = svn_dirent_local_style(svn_repos_path(repos, pool), pool);
@@ -568,8 +565,6 @@ svn_repos__hooks_pre_commit(svn_repos_t
SVN_ERR(svn_io_file_open(&stdin_handle, SVN_NULL_DEVICE_NAME,
APR_READ, APR_OS_DEFAULT, pool));
- SVN_ERR(parse_hooks_env(&hooks_env, repos->hooks_env_path, pool, pool));
-
SVN_ERR(run_hook_cmd(NULL, SVN_REPOS__HOOK_PRE_COMMIT, hook, args,
hooks_env, stdin_handle, pool));
}
@@ -580,6 +575,7 @@ svn_repos__hooks_pre_commit(svn_repos_t
svn_error_t *
svn_repos__hooks_post_commit(svn_repos_t *repos,
+ apr_hash_t *hooks_env,
svn_revnum_t rev,
const char *txn_name,
apr_pool_t *pool)
@@ -594,9 +590,6 @@ svn_repos__hooks_post_commit(svn_repos_t
else if (hook)
{
const char *args[5];
- apr_hash_t *hooks_env;
-
- SVN_ERR(parse_hooks_env(&hooks_env, repos->hooks_env_path, pool, pool));
args[0] = hook;
args[1] = svn_dirent_local_style(svn_repos_path(repos, pool), pool);
@@ -614,6 +607,7 @@ svn_repos__hooks_post_commit(svn_repos_t
svn_error_t *
svn_repos__hooks_pre_revprop_change(svn_repos_t *repos,
+ apr_hash_t *hooks_env,
svn_revnum_t rev,
const char *author,
const char *name,
@@ -633,7 +627,6 @@ svn_repos__hooks_pre_revprop_change(svn_
const char *args[7];
apr_file_t *stdin_handle = NULL;
char action_string[2];
- apr_hash_t *hooks_env;
/* Pass the new value as stdin to hook */
if (new_value)
@@ -642,8 +635,6 @@ svn_repos__hooks_pre_revprop_change(svn_
SVN_ERR(svn_io_file_open(&stdin_handle, SVN_NULL_DEVICE_NAME,
APR_READ, APR_OS_DEFAULT, pool));
- SVN_ERR(parse_hooks_env(&hooks_env, repos->hooks_env_path, pool, pool));
-
action_string[0] = action;
action_string[1] = '\0';
@@ -679,6 +670,7 @@ svn_repos__hooks_pre_revprop_change(svn_
svn_error_t *
svn_repos__hooks_post_revprop_change(svn_repos_t *repos,
+ apr_hash_t *hooks_env,
svn_revnum_t rev,
const char *author,
const char *name,
@@ -698,7 +690,6 @@ svn_repos__hooks_post_revprop_change(svn
const char *args[7];
apr_file_t *stdin_handle = NULL;
char action_string[2];
- apr_hash_t *hooks_env;
/* Pass the old value as stdin to hook */
if (old_value)
@@ -707,8 +698,6 @@ svn_repos__hooks_post_revprop_change(svn
SVN_ERR(svn_io_file_open(&stdin_handle, SVN_NULL_DEVICE_NAME,
APR_READ, APR_OS_DEFAULT, pool));
- SVN_ERR(parse_hooks_env(&hooks_env, repos->hooks_env_path, pool, pool));
-
action_string[0] = action;
action_string[1] = '\0';
@@ -732,6 +721,7 @@ svn_repos__hooks_post_revprop_change(svn
svn_error_t *
svn_repos__hooks_pre_lock(svn_repos_t *repos,
+ apr_hash_t *hooks_env,
const char **token,
const char *path,
const char *username,
@@ -750,9 +740,7 @@ svn_repos__hooks_pre_lock(svn_repos_t *r
{
const char *args[7];
svn_string_t *buf;
- apr_hash_t *hooks_env;
- SVN_ERR(parse_hooks_env(&hooks_env, repos->hooks_env_path, pool, pool));
args[0] = hook;
args[1] = svn_dirent_local_style(svn_repos_path(repos, pool), pool);
@@ -779,6 +767,7 @@ svn_repos__hooks_pre_lock(svn_repos_t *r
svn_error_t *
svn_repos__hooks_post_lock(svn_repos_t *repos,
+ apr_hash_t *hooks_env,
const apr_array_header_t *paths,
const char *username,
apr_pool_t *pool)
@@ -794,15 +783,12 @@ svn_repos__hooks_post_lock(svn_repos_t *
{
const char *args[5];
apr_file_t *stdin_handle = NULL;
- apr_hash_t *hooks_env;
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));
- SVN_ERR(parse_hooks_env(&hooks_env, repos->hooks_env_path, pool, pool));
-
args[0] = hook;
args[1] = svn_dirent_local_style(svn_repos_path(repos, pool), pool);
args[2] = username;
@@ -821,6 +807,7 @@ svn_repos__hooks_post_lock(svn_repos_t *
svn_error_t *
svn_repos__hooks_pre_unlock(svn_repos_t *repos,
+ apr_hash_t *hooks_env,
const char *path,
const char *username,
const char *token,
@@ -837,9 +824,6 @@ svn_repos__hooks_pre_unlock(svn_repos_t
else if (hook)
{
const char *args[7];
- apr_hash_t *hooks_env;
-
- SVN_ERR(parse_hooks_env(&hooks_env, repos->hooks_env_path, pool, pool));
args[0] = hook;
args[1] = svn_dirent_local_style(svn_repos_path(repos, pool), pool);
@@ -859,6 +843,7 @@ svn_repos__hooks_pre_unlock(svn_repos_t
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)
@@ -874,15 +859,12 @@ svn_repos__hooks_post_unlock(svn_repos_t
{
const char *args[5];
apr_file_t *stdin_handle = NULL;
- apr_hash_t *hooks_env;
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));
- SVN_ERR(parse_hooks_env(&hooks_env, repos->hooks_env_path, pool, pool));
-
args[0] = hook;
args[1] = svn_dirent_local_style(svn_repos_path(repos, pool), pool);
args[2] = username ? username : "";
Modified: subversion/trunk/subversion/libsvn_repos/load-fs-vtable.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/load-fs-vtable.c?rev=1464122&r1=1464121&r2=1464122&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/load-fs-vtable.c (original)
+++ subversion/trunk/subversion/libsvn_repos/load-fs-vtable.c Wed Apr 3 17:51:56 2013
@@ -912,16 +912,20 @@ close_revision(void *baton)
const char *conflict_msg = NULL;
svn_revnum_t committed_rev;
svn_error_t *err;
- const char *txn_name;
+ const char *txn_name = NULL;
+ apr_hash_t *hooks_env = NULL;
/* If we're skipping this revision or it has an invalid revision
number, we're done here. */
if (rb->skipped || (rb->rev <= 0))
return SVN_NO_ERROR;
- /* Get the txn name, if it will be needed. */
+ /* Get the txn name and hooks environment if they will be needed. */
if (pb->use_pre_commit_hook || pb->use_post_commit_hook)
{
+ SVN_ERR(svn_repos__parse_hooks_env(&hooks_env, pb->repos->hooks_env_path,
+ rb->pool, rb->pool));
+
err = svn_fs_txn_name(&txn_name, rb->txn, rb->pool);
if (err)
{
@@ -933,7 +937,8 @@ close_revision(void *baton)
/* Run the pre-commit hook, if so commanded. */
if (pb->use_pre_commit_hook)
{
- err = svn_repos__hooks_pre_commit(pb->repos, txn_name, rb->pool);
+ err = svn_repos__hooks_pre_commit(pb->repos, hooks_env,
+ txn_name, rb->pool);
if (err)
{
svn_error_clear(svn_fs_abort_txn(rb->txn, rb->pool));
@@ -965,8 +970,9 @@ close_revision(void *baton)
/* Run post-commit hook, if so commanded. */
if (pb->use_post_commit_hook)
{
- if ((err = svn_repos__hooks_post_commit(pb->repos, committed_rev,
- txn_name, rb->pool)))
+ if ((err = svn_repos__hooks_post_commit(pb->repos, hooks_env,
+ committed_rev, txn_name,
+ rb->pool)))
return svn_error_create
(SVN_ERR_REPOS_POST_COMMIT_HOOK_FAILED, err,
_("Commit succeeded, but post-commit hook failed"));
Modified: subversion/trunk/subversion/libsvn_repos/repos.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/repos.h?rev=1464122&r1=1464121&r2=1464122&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/repos.h (original)
+++ subversion/trunk/subversion/libsvn_repos/repos.h Wed Apr 3 17:51:56 2013
@@ -161,9 +161,25 @@ struct svn_repos_t
/*** Hook-running Functions ***/
+/* Set *HOOKS_ENV_P to the parsed contents of the hooks-env file
+ LOCAL_ABSPATH, allocated in RESULT_POOL. (This result is suitable
+ for delivery to the various hook wrapper functions which accept a
+ 'hooks_env' parameter.)
+
+ Use SCRATCH_POOL for temporary allocations. */
+svn_error_t *
+svn_repos__parse_hooks_env(apr_hash_t **hooks_env_p,
+ const char *local_abspath,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool);
+
/* Run the start-commit hook for REPOS. Use POOL for any temporary
allocations. If the hook fails, return SVN_ERR_REPOS_HOOK_FAILURE.
+ HOOKS_ENV is a hash of hook script environment information returned
+ via svn_repos__parse_hooks_env() (or NULL if no such information is
+ available).
+
USER is the authenticated name of the user starting the commit.
CAPABILITIES is a list of 'const char *' capability names (using
@@ -175,6 +191,7 @@ struct svn_repos_t
created. */
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,
@@ -183,18 +200,28 @@ svn_repos__hooks_start_commit(svn_repos_
/* Run the pre-commit hook for REPOS. Use POOL for any temporary
allocations. If the hook fails, return SVN_ERR_REPOS_HOOK_FAILURE.
+ HOOKS_ENV is a hash of hook script environment information returned
+ via svn_repos__parse_hooks_env() (or NULL if no such information is
+ available).
+
TXN_NAME is the name of the transaction that is being committed. */
svn_error_t *
svn_repos__hooks_pre_commit(svn_repos_t *repos,
+ apr_hash_t *hooks_env,
const char *txn_name,
apr_pool_t *pool);
/* Run the post-commit hook for REPOS. Use POOL for any temporary
allocations. If the hook fails, run SVN_ERR_REPOS_HOOK_FAILURE.
+ HOOKS_ENV is a hash of hook script environment information returned
+ via svn_repos__parse_hooks_env() (or NULL if no such information is
+ available).
+
REV is the revision that was created as a result of the commit. */
svn_error_t *
svn_repos__hooks_post_commit(svn_repos_t *repos,
+ apr_hash_t *hooks_env,
svn_revnum_t rev,
const char *txn_name,
apr_pool_t *pool);
@@ -203,6 +230,10 @@ svn_repos__hooks_post_commit(svn_repos_t
temporary allocations. If the hook fails, return
SVN_ERR_REPOS_HOOK_FAILURE.
+ HOOKS_ENV is a hash of hook script environment information returned
+ via svn_repos__parse_hooks_env() (or NULL if no such information is
+ available).
+
REV is the revision whose property is being changed.
AUTHOR is the authenticated name of the user changing the prop.
NAME is the name of the property being changed.
@@ -215,6 +246,7 @@ svn_repos__hooks_post_commit(svn_repos_t
will be written. */
svn_error_t *
svn_repos__hooks_pre_revprop_change(svn_repos_t *repos,
+ apr_hash_t *hooks_env,
svn_revnum_t rev,
const char *author,
const char *name,
@@ -226,6 +258,10 @@ svn_repos__hooks_pre_revprop_change(svn_
temporary allocations. If the hook fails, return
SVN_ERR_REPOS_HOOK_FAILURE.
+ HOOKS_ENV is a hash of hook script environment information returned
+ via svn_repos__parse_hooks_env() (or NULL if no such information is
+ available).
+
REV is the revision whose property was changed.
AUTHOR is the authenticated name of the user who changed the prop.
NAME is the name of the property that was changed, and OLD_VALUE is
@@ -237,6 +273,7 @@ svn_repos__hooks_pre_revprop_change(svn_
the property is being created, no data will be written. */
svn_error_t *
svn_repos__hooks_post_revprop_change(svn_repos_t *repos,
+ apr_hash_t *hooks_env,
svn_revnum_t rev,
const char *author,
const char *name,
@@ -247,6 +284,10 @@ svn_repos__hooks_post_revprop_change(svn
/* Run the pre-lock hook for REPOS. Use POOL for any temporary
allocations. If the hook fails, return SVN_ERR_REPOS_HOOK_FAILURE.
+ HOOKS_ENV is a hash of hook script environment information returned
+ via svn_repos__parse_hooks_env() (or NULL if no such information is
+ available).
+
PATH is the path being locked, USERNAME is the person doing it,
COMMENT is the comment of the lock, and is treated as an empty
string when NULL is given. STEAL-LOCK is a flag if the user is
@@ -259,6 +300,7 @@ svn_repos__hooks_post_revprop_change(svn
svn_error_t *
svn_repos__hooks_pre_lock(svn_repos_t *repos,
+ apr_hash_t *hooks_env,
const char **token,
const char *path,
const char *username,
@@ -269,10 +311,15 @@ svn_repos__hooks_pre_lock(svn_repos_t *r
/* Run the post-lock hook for REPOS. Use POOL for any temporary
allocations. If the hook fails, return SVN_ERR_REPOS_HOOK_FAILURE.
+ HOOKS_ENV is a hash of hook script environment information returned
+ via svn_repos__parse_hooks_env() (or NULL if no such information is
+ available).
+
PATHS is an array of paths being locked, USERNAME is the person
who did it. */
svn_error_t *
svn_repos__hooks_post_lock(svn_repos_t *repos,
+ apr_hash_t *hooks_env,
const apr_array_header_t *paths,
const char *username,
apr_pool_t *pool);
@@ -280,11 +327,16 @@ svn_repos__hooks_post_lock(svn_repos_t *
/* Run the pre-unlock hook for REPOS. Use POOL for any temporary
allocations. If the hook fails, return SVN_ERR_REPOS_HOOK_FAILURE.
+ HOOKS_ENV is a hash of hook script environment information returned
+ via svn_repos__parse_hooks_env() (or NULL if no such information is
+ available).
+
PATH is the path being unlocked, USERNAME is the person doing it,
TOKEN is the lock token to be unlocked which should not be NULL,
and BREAK-LOCK is a flag if the user is breaking the lock. */
svn_error_t *
svn_repos__hooks_pre_unlock(svn_repos_t *repos,
+ apr_hash_t *hooks_env,
const char *path,
const char *username,
const char *token,
@@ -294,10 +346,15 @@ svn_repos__hooks_pre_unlock(svn_repos_t
/* Run the post-unlock hook for REPOS. Use POOL for any temporary
allocations. If the hook fails, return SVN_ERR_REPOS_HOOK_FAILURE.
+ HOOKS_ENV is a hash of hook script environment information returned
+ via svn_repos__parse_hooks_env() (or NULL if no such information is
+ available).
+
PATHS is an array of paths being unlocked, USERNAME is the person
who did it. */
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);
Received on 2013-04-03 21:17:27 CEST