The svntest/main.py code that installs a post-commit hook for --fsfs-packing=N
documents the following shortcoming:
# Note that some tests (currently only commit_tests) create their own
# post-commit hooks, which would override this one. :-(
In general, if a test calls create_python_hook_script() twice with the same
HOOK_PATH argument, all calls but the last are *silently ignored*. That's bad.
I'm attaching a patch for this. I ran tests through merge_reintegrate_tests.py
and it doesn't introduce any failures. I probably won't have time to finish
it, so I'd appreciate it if someone can pick it up, finish it, and commit.
Tests harness: fix a bug whereby a previously-installed hook would be silently
overwritten by a more-recently-installed one.
TODO: before commit, fix commit_tests 15 and 38 under --fsfs-packing
(create_repos): Undocument the bug this commit fixes.
(create_python_hook_script): Abort if the hook script already exists.
There is no provision for callers to disable this behaviour.
(hook_test, post_commit_hook_test): (...)
@@ -37,6 +37,7 @@ import urllib
from urlparse import urlparse
# Python >=3.0
@@ -973,8 +973,6 @@ def create_repos(path, minor_version = None):
file_write(format_file_path, new_contents, 'wb')
- # Note that some tests (currently only commit_tests) create their own
- # post-commit hooks, which would override this one. :-(
# some tests chdir.
abs_path = os.path.abspath(path)
@@ -1080,6 +1081,13 @@ def create_python_hook_script(hook_path, hook_script_code,
"""Create a Python hook script at HOOK_PATH with the specified
+ # Hook scripts belong to a repository. Each repository is handled by at most
+ # one thread at any given time. Therefore, an advance check suffices, i.e.,
+ # open(O_EXCL) is not needed here.
+ if os.path.exists(hook_path):
+ raise OSError(errno.EEXIST,
+ "Won't overwrite hook script at %r" % (hook_path,))
if cmd_alternative is not None:
file_write("%s.bat" % hook_path,
@@ -840,6 +840,7 @@ fp.close()"""
hook_format % "pre_commit_hook")
+ # ### This test and post_commit_hook_test() probably to be changed before commit.
post_commit_hook = svntest.main.get_post_commit_hook_path(repo_dir)
hook_format % "post_commit_hook")
Received on 2014-03-14 05:16:11 CET