You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by da...@apache.org on 2012/02/06 00:14:43 UTC
svn commit: r1240856 - in /subversion/trunk/subversion/libsvn_repos:
fs-wrap.c hooks.c load-fs-vtable.c repos.c repos.h
Author: danielsh
Date: Sun Feb 5 23:14:43 2012
New Revision: 1240856
URL: http://svn.apache.org/viewvc?rev=1240856&view=rev
Log:
Teach post-commit hooks to receive the txn name.
The txn name is already passed to the pre-commit hook, so this allows the
pre-commit and post-commit hook to easily pass state.
(An svn_fs_* API to answer "What txn did a <given revision> originate in?"
would be easy to implement for FSFS f3 and newer and for BDB, but is beyond
the scope of this commit.)
Suggested by: Trent Nelson <tr...@snakebite.org>
* subversion/libsvn_repos/fs-wrap.c
(svn_repos_fs_commit_txn): Pass TXN_NAME to the post-commit hook.
* subversion/libsvn_repos/load-fs-vtable.c
(close_revision): Reorganize code to pass TXN_NAME to the post-commit hook.
* subversion/libsvn_repos/repos.c
(create_hooks): Add the new paramater to the hook template.
* subversion/libsvn_repos/repos.h
(svn_repos__hooks_post_commit): Grow TXN_NAME parameter.
* subversion/libsvn_repos/hooks.c
(svn_repos__hooks_post_commit): Grow TXN_NAME parameter, and pass it
to the child's argv.
Modified:
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.c
subversion/trunk/subversion/libsvn_repos/repos.h
Modified: subversion/trunk/subversion/libsvn_repos/fs-wrap.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/fs-wrap.c?rev=1240856&r1=1240855&r2=1240856&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/fs-wrap.c (original)
+++ subversion/trunk/subversion/libsvn_repos/fs-wrap.c Sun Feb 5 23:14:43 2012
@@ -61,7 +61,7 @@ svn_repos_fs_commit_txn(const char **con
return err;
/* Run post-commit hooks. */
- if ((err2 = svn_repos__hooks_post_commit(repos, *new_rev, pool)))
+ if ((err2 = svn_repos__hooks_post_commit(repos, *new_rev, txn_name, pool)))
{
err2 = svn_error_create
(SVN_ERR_REPOS_POST_COMMIT_HOOK_FAILED, err2,
Modified: subversion/trunk/subversion/libsvn_repos/hooks.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/hooks.c?rev=1240856&r1=1240855&r2=1240856&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/hooks.c (original)
+++ subversion/trunk/subversion/libsvn_repos/hooks.c Sun Feb 5 23:14:43 2012
@@ -449,6 +449,7 @@ svn_repos__hooks_pre_commit(svn_repos_t
svn_error_t *
svn_repos__hooks_post_commit(svn_repos_t *repos,
svn_revnum_t rev,
+ const char *txn_name,
apr_pool_t *pool)
{
const char *hook = svn_repos_post_commit_hook(repos, pool);
@@ -460,12 +461,13 @@ svn_repos__hooks_post_commit(svn_repos_t
}
else if (hook)
{
- const char *args[4];
+ const char *args[5];
args[0] = hook;
args[1] = svn_dirent_local_style(svn_repos_path(repos, pool), pool);
args[2] = apr_psprintf(pool, "%ld", rev);
- args[3] = NULL;
+ args[3] = txn_name;
+ args[4] = NULL;
SVN_ERR(run_hook_cmd(NULL, SVN_REPOS__HOOK_POST_COMMIT, hook, args,
repos->hooks_env, NULL, pool));
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=1240856&r1=1240855&r2=1240856&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/load-fs-vtable.c (original)
+++ subversion/trunk/subversion/libsvn_repos/load-fs-vtable.c Sun Feb 5 23:14:43 2012
@@ -900,19 +900,28 @@ close_revision(void *baton)
const char *conflict_msg = NULL;
svn_revnum_t committed_rev;
svn_error_t *err;
+ const char *txn_name;
/* 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. */
+ if (pb->use_pre_commit_hook || pb->use_post_commit_hook)
+ {
+ err = svn_fs_txn_name(&txn_name, rb->txn, rb->pool);
+ if (err)
+ {
+ svn_error_clear(svn_fs_abort_txn(rb->txn, rb->pool));
+ return svn_error_trace(err);
+ }
+ }
+
/* Run the pre-commit hook, if so commanded. */
if (pb->use_pre_commit_hook)
{
- const char *txn_name;
- err = svn_fs_txn_name(&txn_name, rb->txn, rb->pool);
- if (! err)
- err = svn_repos__hooks_pre_commit(pb->repos, txn_name, rb->pool);
+ err = svn_repos__hooks_pre_commit(pb->repos, txn_name, rb->pool);
if (err)
{
svn_error_clear(svn_fs_abort_txn(rb->txn, rb->pool));
@@ -945,7 +954,7 @@ close_revision(void *baton)
if (pb->use_post_commit_hook)
{
if ((err = svn_repos__hooks_post_commit(pb->repos, committed_rev,
- rb->pool)))
+ 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.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/repos.c?rev=1240856&r1=1240855&r2=1240856&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/repos.c (original)
+++ subversion/trunk/subversion/libsvn_repos/repos.c Sun Feb 5 23:14:43 2012
@@ -742,6 +742,7 @@ PREWRITTEN_HOOKS_TEXT
"#" NL
"# [1] REPOS-PATH (the path to this repository)" NL
"# [2] REV (the number of the revision just committed)" NL
+"# [3] TXN-NAME (the name of the transaction that has become REV)" NL
"#" NL
"# The default working directory for the invocation is undefined, so" NL
"# the program should set one explicitly if it cares." NL
@@ -771,6 +772,7 @@ PREWRITTEN_HOOKS_TEXT
"" NL
"REPOS=\"$1\"" NL
"REV=\"$2\"" NL
+"TXN_NAME=\"$3\"" NL
NL
"mailer.py commit \"$REPOS\" \"$REV\" /path/to/mailer.conf" NL;
Modified: subversion/trunk/subversion/libsvn_repos/repos.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/repos.h?rev=1240856&r1=1240855&r2=1240856&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/repos.h (original)
+++ subversion/trunk/subversion/libsvn_repos/repos.h Sun Feb 5 23:14:43 2012
@@ -179,6 +179,7 @@ svn_repos__hooks_pre_commit(svn_repos_t
svn_error_t *
svn_repos__hooks_post_commit(svn_repos_t *repos,
svn_revnum_t rev,
+ const char *txn_name,
apr_pool_t *pool);
/* Run the pre-revprop-change hook for REPOS. Use POOL for any