You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by cm...@apache.org on 2012/08/22 20:25:52 UTC

svn commit: r1376179 - in /subversion/trunk/subversion: include/svn_repos.h libsvn_repos/fs-wrap.c libsvn_repos/hooks.c libsvn_repos/repos.c libsvn_repos/repos.h tests/cmdline/commit_tests.py tests/cmdline/svntest/actions.py

Author: cmpilato
Date: Wed Aug 22 18:25:51 2012
New Revision: 1376179

URL: http://svn.apache.org/viewvc?rev=1376179&view=rev
Log:
Revert r1375697 and r1375675, removing the new 'init-commit' hook script
feature.

Modified:
    subversion/trunk/subversion/include/svn_repos.h
    subversion/trunk/subversion/libsvn_repos/fs-wrap.c
    subversion/trunk/subversion/libsvn_repos/hooks.c
    subversion/trunk/subversion/libsvn_repos/repos.c
    subversion/trunk/subversion/libsvn_repos/repos.h
    subversion/trunk/subversion/tests/cmdline/commit_tests.py
    subversion/trunk/subversion/tests/cmdline/svntest/actions.py

Modified: subversion/trunk/subversion/include/svn_repos.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_repos.h?rev=1376179&r1=1376178&r2=1376179&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_repos.h (original)
+++ subversion/trunk/subversion/include/svn_repos.h Wed Aug 22 18:25:51 2012
@@ -715,12 +715,6 @@ const char *
 svn_repos_start_commit_hook(svn_repos_t *repos,
                             apr_pool_t *pool);
 
-/** Return the path to @a repos's init-commit hook, allocated in @a pool.
- * @since New in 1.8 */
-const char *
-svn_repos_init_commit_hook(svn_repos_t *repos,
-                           apr_pool_t *pool);
-
 /** Return the path to @a repos's pre-commit hook, allocated in @a pool. */
 const char *
 svn_repos_pre_commit_hook(svn_repos_t *repos,

Modified: subversion/trunk/subversion/libsvn_repos/fs-wrap.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/fs-wrap.c?rev=1376179&r1=1376178&r2=1376179&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/fs-wrap.c (original)
+++ subversion/trunk/subversion/libsvn_repos/fs-wrap.c Wed Aug 22 18:25:51 2012
@@ -83,11 +83,9 @@ svn_repos_fs_begin_txn_for_commit2(svn_f
                                    apr_hash_t *revprop_table,
                                    apr_pool_t *pool)
 {
-  apr_array_header_t *revprops;
-  const char *txn_name;
-  svn_string_t *author = apr_hash_get(revprop_table,
-                                      SVN_PROP_REVISION_AUTHOR,
+  svn_string_t *author = apr_hash_get(revprop_table, SVN_PROP_REVISION_AUTHOR,
                                       APR_HASH_KEY_STRING);
+  apr_array_header_t *revprops;
 
   /* Run start-commit hooks. */
   SVN_ERR(svn_repos__hooks_start_commit(repos, author ? author->data : NULL,
@@ -96,15 +94,12 @@ svn_repos_fs_begin_txn_for_commit2(svn_f
   /* Begin the transaction, ask for the fs to do on-the-fly lock checks. */
   SVN_ERR(svn_fs_begin_txn2(txn_p, repos->fs, rev,
                             SVN_FS_TXN_CHECK_LOCKS, pool));
-  SVN_ERR(svn_fs_txn_name(&txn_name, *txn_p, pool));
 
   /* We pass the revision properties to the filesystem by adding them
      as properties on the txn.  Later, when we commit the txn, these
      properties will be copied into the newly created revision. */
   revprops = svn_prop_hash_to_array(revprop_table, pool);
-  SVN_ERR(svn_repos_fs_change_txn_props(*txn_p, revprops, pool));
-
-  return svn_error_trace(svn_repos__hooks_init_commit(repos, txn_name, pool));
+  return svn_repos_fs_change_txn_props(*txn_p, revprops, pool);
 }
 
 

Modified: subversion/trunk/subversion/libsvn_repos/hooks.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/hooks.c?rev=1376179&r1=1376178&r2=1376179&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/hooks.c (original)
+++ subversion/trunk/subversion/libsvn_repos/hooks.c Wed Aug 22 18:25:51 2012
@@ -124,7 +124,6 @@ check_hook_result(const char *name, cons
     {
       const char *action;
       if (strcmp(name, "start-commit") == 0
-          || strcmp(name, "init-commit") == 0
           || strcmp(name, "pre-commit") == 0)
         action = _("Commit");
       else if (strcmp(name, "pre-revprop-change") == 0)
@@ -398,34 +397,6 @@ svn_repos__hooks_start_commit(svn_repos_
   return SVN_NO_ERROR;
 }
 
-svn_error_t *
-svn_repos__hooks_init_commit(svn_repos_t *repos,
-                             const char *txn_name,
-                             apr_pool_t *pool)
-{
-  const char *hook = svn_repos_init_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[4];
-
-      args[0] = hook;
-      args[1] = svn_dirent_local_style(svn_repos_path(repos, pool), pool);
-      args[2] = txn_name;
-      args[3] = NULL;
-
-      SVN_ERR(run_hook_cmd(NULL, SVN_REPOS__HOOK_INIT_COMMIT, hook, args,
-                           repos->hooks_env, NULL, pool));
-    }
-
-  return SVN_NO_ERROR;
-}
-
 /* Set *HANDLE to an open filehandle for a temporary file (i.e.,
    automatically deleted when closed), into which the LOCK_TOKENS have
    been written out in the format described in the pre-commit hook

Modified: subversion/trunk/subversion/libsvn_repos/repos.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/repos.c?rev=1376179&r1=1376178&r2=1376179&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/repos.c (original)
+++ subversion/trunk/subversion/libsvn_repos/repos.c Wed Aug 22 18:25:51 2012
@@ -111,13 +111,6 @@ svn_repos_start_commit_hook(svn_repos_t 
 
 
 const char *
-svn_repos_init_commit_hook(svn_repos_t *repos, apr_pool_t *pool)
-{
-  return svn_dirent_join(repos->hook_path, SVN_REPOS__HOOK_INIT_COMMIT, pool);
-}
-
-
-const char *
 svn_repos_pre_commit_hook(svn_repos_t *repos, apr_pool_t *pool)
 {
   return svn_dirent_join(repos->hook_path, SVN_REPOS__HOOK_PRE_COMMIT, pool);
@@ -382,93 +375,6 @@ PREWRITTEN_HOOKS_TEXT
     SVN_ERR(svn_io_set_file_executable(this_path, TRUE, FALSE, pool));
   }  /* end start-commit hook */
 
-  /* Init-commit hook. */
-  {
-    this_path = apr_psprintf(pool, "%s%s",
-                             svn_repos_init_commit_hook(repos, pool),
-                             SVN_REPOS__HOOK_DESC_EXT);
-
-#define SCRIPT_NAME SVN_REPOS__HOOK_INIT_COMMIT
-
-    contents =
-"#!/bin/sh"                                                                  NL
-""                                                                           NL
-"# INIT-COMMIT HOOK"                                                         NL
-"#"                                                                          NL
-"# The init-commit hook is invoked immediate after a Subversion commit txn"  NL
-"# is created and initialized.  Subversion runs this hook by invoking a"     NL
-"# program (script, executable, binary, etc.) named '"SCRIPT_NAME"' (for"    NL
-"# which this file is a template), with the following ordered arguments:"    NL
-"#"                                                                          NL
-"#   [1] REPOS-PATH   (the path to this repository)"                         NL
-"#   [2] TXN-NAME     (the name of the commit txn just created)"             NL
-"#"                                                                          NL
-"# The default working directory for the invocation is undefined, so"        NL
-"# the program should set one explicitly if it cares."                       NL
-"#"                                                                          NL
-"# If the hook program exits with success, the commit txn remains active;"   NL
-"# but if it exits with failure (non-zero), the txn is aborted, no commit"   NL
-"# takes place, and STDERR is returned to the client.   The hook"            NL
-"# program can use the 'svnlook' utility to help it examine the txn."        NL
-"#"                                                                          NL
-"# On a Unix system, the normal procedure is to have '"SCRIPT_NAME"'"        NL
-"# invoke other programs to do the real work, though it may do the"          NL
-"# work itself too."                                                         NL
-"#"                                                                          NL
-"#   ***  NOTE: THE HOOK PROGRAM MUST NOT MODIFY THE TXN, EXCEPT  ***"       NL
-"#   ***  FOR REVISION PROPERTIES (like svn:log or svn:author).   ***"       NL
-"#"                                                                          NL
-"#   This is why we recommend using the read-only 'svnlook' utility."        NL
-"#   In the future, Subversion may enforce the rule that pre-commit"         NL
-"#   hooks should not modify the versioned data in txns, or else come"       NL
-"#   up with a mechanism to make it safe to do so (by informing the"         NL
-"#   committing client of the changes).  However, right now neither"         NL
-"#   mechanism is implemented, so hook writers just have to be careful."     NL
-"#"                                                                          NL
-"# Note that '"SCRIPT_NAME"' must be executable by the user(s) who will"     NL
-"# invoke it (typically the user httpd runs as), and that user must"         NL
-"# have filesystem-level permission to access the repository."               NL
-"#"                                                                          NL
-"# On a Windows system, you should name the hook program"                    NL
-"# '"SCRIPT_NAME".bat' or '"SCRIPT_NAME".exe',"                              NL
-"# but the basic idea is the same."                                          NL
-"#"                                                                          NL
-"# WARNING: The degree of txn \"initialization\" may differ depending on"    NL
-"# how the commit process is being driven.  For example, some older"         NL
-"# Subversion clients (notably pre-1.7 clients committing over HTTP) will"   NL
-"# not have yet attached some metadata -- such as the commit log message --" NL
-"# to the txn by the time this hook runs.  Hook authors should therefore"    NL
-"# not assume that a txn which lacks a log message at this stage of the  "   NL
-"# commit will necessarily still lack a log message by the time the commit"  NL
-"# completes."                                                               NL
-"#"                                                                          NL
-HOOKS_ENVIRONMENT_TEXT
-"# "                                                                         NL
-"# Here is an example hook script, for a Unix /bin/sh interpreter."          NL
-PREWRITTEN_HOOKS_TEXT
-""                                                                           NL
-""                                                                           NL
-"REPOS=\"$1\""                                                               NL
-"TXN=\"$2\""                                                                 NL
-""                                                                           NL
-"# If a log message is present, make sure it mentions an issue tracker id."  NL
-"SVNLOOK=" SVN_BINDIR "/svnlook"                                             NL
-"if $SVNLOOK log -t \"$TXN\" \"$REPOS\" | \\"                                NL
-"   grep \"[a-zA-Z0-9]\" > /dev/null; then \\"                               NL
-"       $SVNLOOK log -t \"$TXN\" \"$REPOS\" | \\"                            NL
-"           grep -E \"issue [0-9]+\" > /dev/null || exit 1; fi"              NL
-""                                                                           NL
-"# All checks passed, so allow the commit to proceed."                       NL
-"exit 0"                                                                     NL;
-
-#undef SCRIPT_NAME
-    SVN_ERR_W(svn_io_file_create(this_path, contents, pool),
-              _("Creating init-commit hook"));
-
-    SVN_ERR(svn_io_set_file_executable(this_path, TRUE, FALSE, pool));
-  }  /* end init-commit hook */
-
-
   /* Pre-commit hook. */
   {
     this_path = apr_psprintf(pool, "%s%s",

Modified: subversion/trunk/subversion/libsvn_repos/repos.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/repos.h?rev=1376179&r1=1376178&r2=1376179&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/repos.h (original)
+++ subversion/trunk/subversion/libsvn_repos/repos.h Wed Aug 22 18:25:51 2012
@@ -70,7 +70,6 @@ extern "C" {
 
 /* In the repository hooks directory, look for these files. */
 #define SVN_REPOS__HOOK_START_COMMIT    "start-commit"
-#define SVN_REPOS__HOOK_INIT_COMMIT     "init-commit"
 #define SVN_REPOS__HOOK_PRE_COMMIT      "pre-commit"
 #define SVN_REPOS__HOOK_POST_COMMIT     "post-commit"
 #define SVN_REPOS__HOOK_READ_SENTINEL   "read-sentinels"
@@ -164,15 +163,6 @@ svn_repos__hooks_start_commit(svn_repos_
                               const apr_array_header_t *capabilities,
                               apr_pool_t *pool);
 
-/* Run the init-commit hook for REPOS.  Use POOL for any temporary
-   allocations.  If the hook fails, return SVN_ERR_REPOS_HOOK_FAILURE.
-
-   TXN_NAME is the name of the transaction that is being committed.  */
-svn_error_t *
-svn_repos__hooks_init_commit(svn_repos_t *repos,
-                             const char *txn_name,
-                             apr_pool_t *pool);
-
 /* Run the pre-commit hook for REPOS.  Use POOL for any temporary
    allocations.  If the hook fails, return SVN_ERR_REPOS_HOOK_FAILURE.
 

Modified: subversion/trunk/subversion/tests/cmdline/commit_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/commit_tests.py?rev=1376179&r1=1376178&r2=1376179&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/commit_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/commit_tests.py Wed Aug 22 18:25:51 2012
@@ -2940,47 +2940,7 @@ def commit_moved_dir_with_nested_mod_in_
               'Last Changed Rev'  : '2',
              }
   svntest.actions.run_and_verify_info([expected], E_copied)
-
-#----------------------------------------------------------------------
-def init_commit_hook_test(sbox):
-  "init-commit hook failure case testing"
-
-  sbox.build()
-
-  # Get paths to the working copy and repository
-  wc_dir = sbox.wc_dir
-  repo_dir = sbox.repo_dir
-
-  # Create a hook that outputs a message to stderr and returns exit code 1
-  # Include a non-XML-safe message as history shows there've been
-  # problems with such in hooks (see issue #3553).
-  error_msg = "Text with <angle brackets> & ampersand"
-  svntest.actions.create_failing_hook(repo_dir, "init-commit", error_msg)
-
-  # Modify iota just so there is something to commit.
-  iota_path = sbox.ospath('iota')
-  svntest.main.file_append(iota_path, "More stuff in iota")
-
-  # Commit, expect error code 1
-  exit_code, actual_stdout, actual_stderr = svntest.main.run_svn(
-    1, 'ci', '--quiet', '-m', 'log msg', wc_dir)
-
-  # No stdout expected
-  svntest.verify.compare_and_display_lines('Init-commit hook test',
-                                           'STDOUT', [], actual_stdout)
-
-  # Compare only the last two lines of stderr since the preceding ones
-  # contain source code file and line numbers.
-  if len(actual_stderr) > 2:
-    actual_stderr = actual_stderr[-2:]
-  expected_stderr = [ "svn: E165001: " +
-                        svntest.actions.hook_failure_message('init-commit'),
-                      error_msg + "\n",
-                    ]
-  svntest.verify.compare_and_display_lines('Init-commit hook test',
-                                           'STDERR',
-                                           expected_stderr, actual_stderr)
-
+  
   
 ########################################################################
 # Run the tests
@@ -3053,7 +3013,6 @@ test_list = [ None,
               commit_add_subadd,
               commit_danglers,
               commit_moved_dir_with_nested_mod_in_subdir,
-              init_commit_hook_test,
              ]
 
 if __name__ == '__main__':

Modified: subversion/trunk/subversion/tests/cmdline/svntest/actions.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svntest/actions.py?rev=1376179&r1=1376178&r2=1376179&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svntest/actions.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svntest/actions.py Wed Aug 22 18:25:51 2012
@@ -1837,7 +1837,7 @@ def hook_failure_message(hook_name):
   if svntest.main.options.server_minor_version < 5:
     return "'%s' hook failed with error output:\n" % hook_name
   else:
-    if hook_name in ["start-commit", "pre-commit", "init-commit"]:
+    if hook_name in ["start-commit", "pre-commit"]:
       action = "Commit"
     elif hook_name == "pre-revprop-change":
       action = "Revprop change"