Author: gstein
Date: Thu Apr 8 01:41:50 2010
New Revision: 931750
URL: http://svn.apache.org/viewvc?rev=931750&view=rev
Log:
Remove the silly file_read() function
* subversion/tests/cmdline/svntest/main.py:
(file_read): removed
(file_substitute): simplify
(create_repos): just read the file
(create_python_hook_script, canonicalize_url): remove spaces
* cmdline/svntest/actions.py:
(run_and_verify_dump): just read the file
* cmdline/commit_tests.py:
* cmdline/diff_tests.py:
* cmdline/externals_tests.py:
* cmdline/merge_tests.py:
* cmdline/svnadmin_tests.py:
* cmdline/svndumpfilter_tests.py:
* cmdline/trans_tests.py:
* cmdline/update_tests.py:
* cmdline/upgrade_tests.py:
(...): lose the file_read() and just read the file
Modified:
subversion/trunk/subversion/tests/cmdline/commit_tests.py
subversion/trunk/subversion/tests/cmdline/diff_tests.py
subversion/trunk/subversion/tests/cmdline/externals_tests.py
subversion/trunk/subversion/tests/cmdline/merge_tests.py
subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py
subversion/trunk/subversion/tests/cmdline/svndumpfilter_tests.py
subversion/trunk/subversion/tests/cmdline/svntest/actions.py
subversion/trunk/subversion/tests/cmdline/svntest/main.py
subversion/trunk/subversion/tests/cmdline/trans_tests.py
subversion/trunk/subversion/tests/cmdline/update_tests.py
subversion/trunk/subversion/tests/cmdline/upgrade_tests.py
Modified: subversion/trunk/subversion/tests/cmdline/commit_tests.py
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/commit_tests.py?rev=931750&r1=931749&r2=931750&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/commit_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/commit_tests.py Thu Apr 8
01:41:50 2010
@@ -1961,7 +1961,7 @@ def mods_in_schedule_delete(sbox):
None, wc_dir)
# Unversioned file still exists
- actual_contents = svntest.main.file_read(foo_path)
+ actual_contents = open(foo_path).read()
if actual_contents != foo_contents:
raise svntest.Failure
Modified: subversion/trunk/subversion/tests/cmdline/diff_tests.py
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/diff_tests.py?rev=931750&r1=931749&r2=931750&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/diff_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/diff_tests.py Thu Apr 8 01:41:50
2010
@@ -698,8 +698,7 @@ def dont_diff_binary_file(sbox):
wc_dir = sbox.wc_dir
# Add a binary file to the project.
- theta_contents = svntest.main.file_read(
- os.path.join(sys.path[0], "theta.bin"), 'rb')
+ theta_contents = open(os.path.join(sys.path[0], "theta.bin"), 'rb').read()
# Write PNG file data into 'A/theta'.
theta_path = os.path.join(wc_dir, 'A', 'theta')
svntest.main.file_write(theta_path, theta_contents, 'wb')
Modified: subversion/trunk/subversion/tests/cmdline/externals_tests.py
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/externals_tests.py?rev=931750&r1=931749&r2=931750&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/externals_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/externals_tests.py Thu Apr 8
01:41:50 2010
@@ -1177,8 +1177,7 @@ def binary_file_externals(sbox):
wc_dir = sbox.wc_dir
# Add a binary file A/theta, write PNG file data into it.
- theta_contents = svntest.main.file_read(
- os.path.join(sys.path[0], "theta.bin"), 'rb')
+ theta_contents = open(os.path.join(sys.path[0], "theta.bin"), 'rb').read()
theta_path = os.path.join(wc_dir, 'A', 'theta')
svntest.main.file_write(theta_path, theta_contents, 'wb')
Modified: subversion/trunk/subversion/tests/cmdline/merge_tests.py
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/merge_tests.py?rev=931750&r1=931749&r2=931750&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/merge_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/merge_tests.py Thu Apr 8
01:41:50 2010
@@ -334,7 +334,7 @@ def textual_merges_galore(sbox):
other_rho_text = ""
for x in range(1,10):
other_rho_text = other_rho_text + 'Unobtrusive line ' + repr(x) + ' in
rho\n'
- current_other_rho_text = svntest.main.file_read(other_rho_path)
+ current_other_rho_text = open(other_rho_path).read()
svntest.main.file_write(other_rho_path,
other_rho_text + current_other_rho_text)
@@ -1550,8 +1550,7 @@ def merge_binary_file(sbox):
wc_dir = sbox.wc_dir
# Add a binary file to the project
- theta_contents = svntest.main.file_read(
- os.path.join(sys.path[0], "theta.bin"), 'rb')
+ theta_contents = open(os.path.join(sys.path[0], "theta.bin"), 'rb').read()
# Write PNG file data into 'A/theta'.
theta_path = os.path.join(wc_dir, 'A', 'theta')
svntest.main.file_write(theta_path, theta_contents, 'wb')
@@ -1642,8 +1641,7 @@ def three_way_merge_add_of_existing_bina
"-m", "Creating copy-of-A")
# Add a binary file to the WC.
- theta_contents = svntest.main.file_read(
- os.path.join(sys.path[0], "theta.bin"), 'rb')
+ theta_contents = open(os.path.join(sys.path[0], "theta.bin"), 'rb').read()
# Write PNG file data into 'A/theta'.
A_path = os.path.join(wc_dir, 'A')
theta_path = os.path.join(wc_dir, 'A', 'theta')
@@ -2295,8 +2293,7 @@ def merge_binary_with_common_ancestry(sb
svntest.main.run_svn(None, 'mkdir', I_path)
# Add a binary file to the common ancestry path
- theta_contents = svntest.main.file_read(
- os.path.join(sys.path[0], "theta.bin"), 'rb')
+ theta_contents = open(os.path.join(sys.path[0], "theta.bin"), 'rb').read()
theta_I_path = os.path.join(I_path, 'theta')
svntest.main.file_write(theta_I_path, theta_contents)
svntest.main.run_svn(None, 'add', theta_I_path)
Modified: subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py?rev=931750&r1=931749&r2=931750&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py Thu Apr 8
01:41:50 2010
@@ -625,7 +625,7 @@ def recover_fsfs(sbox):
svntest.main.run_svn(None, 'ci', sbox.wc_dir, '--quiet', '-m', 'log msg')
# Remember the contents of the db/current file.
- expected_current_contents = svntest.main.file_read(current_path)
+ expected_current_contents = open(current_path).read()
# Move aside the current file for r3.
os.rename(os.path.join(sbox.repo_dir, 'db','current'),
@@ -637,7 +637,7 @@ def recover_fsfs(sbox):
if errput:
raise SVNUnexpectedStderr(errput)
- actual_current_contents = svntest.main.file_read(current_path)
+ actual_current_contents = open(current_path).read()
svntest.verify.compare_and_display_lines(
"Contents of db/current is unexpected.",
'db/current', expected_current_contents, actual_current_contents)
@@ -651,7 +651,7 @@ def recover_fsfs(sbox):
if errput:
raise SVNUnexpectedStderr(errput)
- actual_current_contents = svntest.main.file_read(current_path)
+ actual_current_contents = open(current_path).read()
svntest.verify.compare_and_display_lines(
"Contents of db/current is unexpected.",
'db/current', expected_current_contents, actual_current_contents)
@@ -665,7 +665,7 @@ def recover_fsfs(sbox):
if errput:
raise SVNUnexpectedStderr(errput)
- actual_current_contents = svntest.main.file_read(current_path)
+ actual_current_contents = open(current_path).read()
svntest.verify.compare_and_display_lines(
"Contents of db/current is unexpected.",
'db/current', expected_current_contents, actual_current_contents)
@@ -684,7 +684,7 @@ def recover_fsfs(sbox):
if errput:
raise SVNUnexpectedStderr(errput)
- actual_current_contents = svntest.main.file_read(current_path)
+ actual_current_contents = open(current_path).read()
svntest.verify.compare_and_display_lines(
"Contents of db/current is unexpected.",
'db/current', expected_current_contents, actual_current_contents)
@@ -700,7 +700,7 @@ def load_with_parent_dir(sbox):
dumpfile_location = os.path.join(os.path.dirname(sys.argv[0]),
'svnadmin_tests_data',
'mergeinfo_included.dump')
- dumpfile = svntest.main.file_read(dumpfile_location)
+ dumpfile = open(dumpfile_location).read()
# Create 'sample' dir in sbox.repo_url, and load the dump stream there.
svntest.actions.run_and_verify_svn(None,
@@ -798,7 +798,7 @@ def reflect_dropped_renumbered_revs(sbox
dumpfile_location = os.path.join(os.path.dirname(sys.argv[0]),
'svndumpfilter_tests_data',
'with_merges.dump')
- dumpfile = svntest.main.file_read(dumpfile_location)
+ dumpfile = open(dumpfile_location).read()
# Create 'toplevel' dir in sbox.repo_url
svntest.actions.run_and_verify_svn(None, ['\n', 'Committed revision 1.\n'],
@@ -1069,17 +1069,15 @@ def drop_mergeinfo_outside_of_dump_strea
# /Projects/Project-X/trunk:10
# Load the skeleton dump:
- dumpfile1 = svntest.main.file_read(
- os.path.join(os.path.dirname(sys.argv[0]),
- 'svnadmin_tests_data',
- 'skeleton_repos.dump'))
+ dumpfile1 = open(os.path.join(os.path.dirname(sys.argv[0]),
+ 'svnadmin_tests_data',
+ 'skeleton_repos.dump')).read()
load_and_verify_dumpstream(sbox, [], [], None, dumpfile1, '--ignore-uuid')
# Load the partial repository with mergeinfo dump:
- dumpfile2 = svntest.main.file_read(
- os.path.join(os.path.dirname(sys.argv[0]),
- 'svnadmin_tests_data',
- 'mergeinfo_included_partial.dump'))
+ dumpfile2 = open(os.path.join(os.path.dirname(sys.argv[0]),
+ 'svnadmin_tests_data',
+ 'mergeinfo_included_partial.dump')).read()
load_and_verify_dumpstream(sbox, [], [], None, dumpfile2, '--ignore-uuid',
'--parent-dir', '/Projects/Project-X')
@@ -1131,10 +1129,9 @@ def dont_drop_valid_mergeinfo_during_inc
#
# Note: The test repository 'mergeinfo_included_full.dump' is the full
# repos diagramed in the test drop_mergeinfo_outside_of_dump_stream.
- dumpfile1 = svntest.main.file_read(
- os.path.join(os.path.dirname(sys.argv[0]),
- 'svnadmin_tests_data',
- 'mergeinfo_included_full.dump'))
+ dumpfile1 = open(os.path.join(os.path.dirname(sys.argv[0]),
+ 'svnadmin_tests_data',
+ 'mergeinfo_included_full.dump')).read()
load_and_verify_dumpstream(sbox, [], [], None, dumpfile1, '--ignore-uuid')
# Check that the mergeinfo is as expected.
@@ -1176,13 +1173,13 @@ def dont_drop_valid_mergeinfo_during_inc
# Load the three incremental dump files in sequence.
load_and_verify_dumpstream(sbox, [], [], None,
- svntest.main.file_read(dump_file_r1_10),
+ open(dump_file_r1_10).read(),
'--ignore-uuid')
load_and_verify_dumpstream(sbox, [], [], None,
- svntest.main.file_read(dump_file_r11_13),
+ open(dump_file_r11_13).read(),
'--ignore-uuid')
load_and_verify_dumpstream(sbox, [], [], None,
- svntest.main.file_read(dump_file_r14_15),
+ open(dump_file_r14_15).read(),
'--ignore-uuid')
# Check the mergeinfo, we use the same expected output as before,
Modified: subversion/trunk/subversion/tests/cmdline/svndumpfilter_tests.py
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svndumpfilter_tests.py?rev=931750&r1=931749&r2=931750&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svndumpfilter_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svndumpfilter_tests.py Thu Apr 8
01:41:50 2010
@@ -74,7 +74,7 @@ def reflect_dropped_renumbered_revs(sbox
dumpfile_location = os.path.join(os.path.dirname(sys.argv[0]),
'svndumpfilter_tests_data',
'with_merges.dump')
- dumpfile = svntest.main.file_read(dumpfile_location)
+ dumpfile = open(dumpfile_location).read()
filtered_out = filter_and_return_output(dumpfile, "include",
"trunk", "branch1",
@@ -124,7 +124,7 @@ def svndumpfilter_loses_mergeinfo(sbox):
dumpfile_location = os.path.join(os.path.dirname(sys.argv[0]),
'svndumpfilter_tests_data',
'with_merges.dump')
- dumpfile = svntest.main.file_read(dumpfile_location)
+ dumpfile = open(dumpfile_location).read()
filtered_out = filter_and_return_output(dumpfile, "include",
"trunk", "branch1", "--quiet")
@@ -203,7 +203,7 @@ def dumpfilter_with_targets(sbox):
dumpfile_location = os.path.join(os.path.dirname(sys.argv[0]),
'svndumpfilter_tests_data',
'greek_tree.dump')
- dumpfile = svntest.main.file_read(dumpfile_location)
+ dumpfile = open(dumpfile_location).read()
(fd, targets_file) = tempfile.mkstemp(dir=svntest.main.temp_dir)
try:
@@ -226,7 +226,7 @@ def dumpfilter_with_patterns(sbox):
dumpfile_location = os.path.join(os.path.dirname(sys.argv[0]),
'svndumpfilter_tests_data',
'greek_tree.dump')
- dumpfile = svntest.main.file_read(dumpfile_location)
+ dumpfile = open(dumpfile_location).read()
_simple_dumpfilter_test(sbox, dumpfile,
'exclude', '--pattern', '/A/D/[GH]*', '/A/[B]/E*')
Modified: subversion/trunk/subversion/tests/cmdline/svntest/actions.py
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svntest/actions.py?rev=931750&r1=931749&r2=931750&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svntest/actions.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svntest/actions.py Thu Apr 8
01:41:50 2010
@@ -287,7 +287,7 @@ def run_and_verify_dump(repo_dir):
def load_repo(sbox, dumpfile_path = None, dump_str = None):
"Loads the dumpfile into sbox"
if not dump_str:
- dump_str = main.file_read(dumpfile_path, "rb")
+ dump_str = open(dumpfile_path, "rb").read()
# Create a virgin repos and working copy
main.safe_rmtree(sbox.repo_dir, 1)
Modified: subversion/trunk/subversion/tests/cmdline/svntest/main.py
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svntest/main.py?rev=931750&r1=931749&r2=931750&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svntest/main.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svntest/main.py Thu Apr 8
01:41:50 2010
@@ -693,25 +693,11 @@ def file_write(path, contents, mode='w')
which is (w)rite by default."""
open(path, mode).write(contents)
-# For reading the contents of a file
-def file_read(path, mode = 'r'):
- """Return the contents of the file at PATH, opening file using MODE,
- which is (r)ead by default."""
- fp = open(path, mode)
- contents = fp.read()
- fp.close()
- return contents
-
# For replacing parts of contents in an existing file, with new content.
def file_substitute(path, contents, new_contents):
"""Replace the CONTENTS in the file at PATH using the NEW_CONTENTS"""
- fp = open(path, 'r')
- fcontent = fp.read()
- fp.close()
- fcontent = fcontent.replace(contents, new_contents)
- fp = open(path, 'w')
- fp.write(fcontent)
- fp.close()
+ fcontent = open(path, 'r').replace(contents, new_contents)
+ open(path, 'w').write(fcontent)
# For creating blank new repositories
def create_repos(path):
@@ -770,7 +756,7 @@ def create_repos(path):
# read it
format_file_path = get_fsfs_format_file_path(path)
- contents = file_read(format_file_path, 'rb')
+ contents = open(format_file_path, 'rb').read()
# tweak it
new_contents = "".join([transform_line(line) + "\n"
@@ -878,7 +864,7 @@ def canonicalize_url(input):
return input
-def create_python_hook_script (hook_path, hook_script_code):
+def create_python_hook_script(hook_path, hook_script_code):
"""Create a Python hook script at HOOK_PATH with the specified
HOOK_SCRIPT_CODE."""
@@ -886,14 +872,14 @@ def create_python_hook_script (hook_path
# Use an absolute path since the working directory is not guaranteed
hook_path = os.path.abspath(hook_path)
# Fill the python file.
- file_write ("%s.py" % hook_path, hook_script_code)
+ file_write("%s.py" % hook_path, hook_script_code)
# Fill the batch wrapper file.
- file_append ("%s.bat" % hook_path,
- "@\"%s\" %s.py %%*\n" % (sys.executable, hook_path))
+ file_append("%s.bat" % hook_path,
+ "@\"%s\" %s.py %%*\n" % (sys.executable, hook_path))
else:
# For all other platforms
- file_write (hook_path, "#!%s\n%s" % (sys.executable, hook_script_code))
- os.chmod (hook_path, 0755)
+ file_write(hook_path, "#!%s\n%s" % (sys.executable, hook_script_code))
+ os.chmod(hook_path, 0755)
def write_restrictive_svnserve_conf(repo_dir, anon_access="none"):
"Create a restrictive authz file ( no anynomous access )."
Modified: subversion/trunk/subversion/tests/cmdline/trans_tests.py
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/trans_tests.py?rev=931750&r1=931749&r2=931750&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/trans_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/trans_tests.py Thu Apr 8
01:41:50 2010
@@ -573,7 +573,7 @@ def eol_change_is_text_mod(sbox):
'ci', '-m', 'log msg', foo_path)
# check 2: do the files have the right contents now?
- contents = svntest.main.file_read(foo_path, 'rb')
+ contents = open(foo_path, 'rb').read()
if svntest.main.windows:
if contents != "1\n2\n3\n4\n5\n6\n7\n8\n9\n":
raise svntest.Failure
@@ -583,7 +583,7 @@ def eol_change_is_text_mod(sbox):
foo_base_path = os.path.join(wc_dir, svntest.main.get_admin_name(),
'text-base', 'foo.svn-base')
- base_contents = svntest.main.file_read(foo_base_path, 'rb')
+ base_contents = open(foo_base_path, 'rb').read()
if contents != base_contents:
raise svntest.Failure
@@ -759,7 +759,7 @@ def propset_commit_checkout_nocrash(sbox
sbox.repo_url,
other_wc_dir)
- mu_other_contents = svntest.main.file_read(mu_other_path)
+ mu_other_contents = open(mu_other_path).read()
if mu_other_contents != "This is the file 'mu'.\n$Rev: 3 $":
print("'%s' does not have the expected contents" % mu_other_path)
raise svntest.Failure
Modified: subversion/trunk/subversion/tests/cmdline/update_tests.py
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/update_tests.py?rev=931750&r1=931749&r2=931750&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/update_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/update_tests.py Thu Apr 8
01:41:50 2010
@@ -83,7 +83,7 @@ def detect_extra_files(node, extra_files
len(os.sep) :]
real_path = os.path.join(wc_dir, real_path)
- real_contents = svntest.main.file_read(real_path)
+ real_contents = open(real_path).read()
if real_contents == contents:
extra_files.pop(extra_files.index(fdata)) # delete pattern from list
return
@@ -100,8 +100,7 @@ def update_binary_file(sbox):
wc_dir = sbox.wc_dir
# Add a binary file to the project.
- theta_contents = svntest.main.file_read(
- os.path.join(sys.path[0], "theta.bin"), 'rb')
+ theta_contents = open(os.path.join(sys.path[0], "theta.bin"), 'rb').read()
# Write PNG file data into 'A/theta'.
theta_path = os.path.join(wc_dir, 'A', 'theta')
svntest.main.file_write(theta_path, theta_contents, 'wb')
@@ -207,8 +206,7 @@ def update_binary_file_2(sbox):
wc_dir = sbox.wc_dir
# Suck up contents of a test .png file.
- theta_contents = svntest.main.file_read(
- os.path.join(sys.path[0], "theta.bin"), 'rb')
+ theta_contents = open(os.path.join(sys.path[0], "theta.bin"), 'rb').read()
# 102400 is svn_txdelta_window_size. We're going to make sure we
# have at least 102401 bytes of data in our second binary file (for
Modified: subversion/trunk/subversion/tests/cmdline/upgrade_tests.py
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/upgrade_tests.py?rev=931750&r1=931749&r2=931750&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/upgrade_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/upgrade_tests.py Thu Apr 8
01:41:50 2010
@@ -233,10 +233,9 @@ def upgrade_wcprops(sbox):
def xml_entries_relocate(path, from_url, to_url):
adm_name = svntest.main.get_admin_name()
entries = os.path.join(path, adm_name, 'entries')
- txt = svntest.main.file_read(entries)
- txt = txt.replace('url="' + from_url, 'url="' + to_url)
+ txt = open(entries).read().replace('url="' + from_url, 'url="' + to_url)
os.chmod(entries, 0777)
- svntest.main.file_write(entries, txt)
+ open(entries, 'w').write(txt)
print('Relocated %s' % path)