def corrupt_and_recover_db_current(sbox, minor_version=None):
    'Build up a MINOR_VERSION sandbox and test different recovery scenarios\n  with missing, out-of-date or even corrupt db/current files.  Recovery should\n  behave the same way with all values of MINOR_VERSION, hence this helper\n  containing the common code that allows us to check it.'
    sbox.build(minor_version=minor_version)
    current_path = os.path.join(sbox.repo_dir, 'db', 'current')
    svntest.main.file_append(os.path.join(sbox.wc_dir, 'iota'), 'newer line\n')
    sbox.simple_commit(message='log msg')
    svntest.main.file_append(os.path.join(sbox.wc_dir, 'iota'), 'newest line\n')
    sbox.simple_commit(message='log msg')
    expected_current_contents = open(current_path).read()
    os.rename(os.path.join(sbox.repo_dir, 'db', 'current'), os.path.join(sbox.repo_dir, 'db', 'was_current'))
    (exit_code, output, errput) = svntest.main.run_svnadmin('recover', sbox.repo_dir)
    if errput:
        raise SVNUnexpectedStderr(errput)
    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)
    svntest.main.file_write(current_path, '2\n')
    (exit_code, output, errput) = svntest.main.run_svnadmin('recover', sbox.repo_dir)
    if errput:
        raise SVNUnexpectedStderr(errput)
    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)
    svntest.main.file_write(current_path, '1\n')
    (exit_code, output, errput) = svntest.main.run_svnadmin('recover', sbox.repo_dir)
    if errput:
        raise SVNUnexpectedStderr(errput)
    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)
    svntest.main.file_write(current_path, 'fish\n')
    (exit_code, output, errput) = svntest.main.run_svnadmin('recover', sbox.repo_dir)
    if errput:
        raise SVNUnexpectedStderr(errput)
    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)
Build up a MINOR_VERSION sandbox and test different recovery scenarios
with missing, out-of-date or even corrupt db/current files.  Recovery should
behave the same way with all values of MINOR_VERSION, hence this helper
containing the common code that allows us to check it.
def corrupt_and_recover_db_current(sbox, minor_version=None):
    'Build up a MINOR_VERSION sandbox and test different recovery scenarios\n  with missing, out-of-date or even corrupt db/current files.  Recovery should\n  behave the same way with all values of MINOR_VERSION, hence this helper\n  containing the common code that allows us to check it.'
    sbox.build(minor_version=minor_version)
    current_path = os.path.join(sbox.repo_dir, 'db', 'current')
    svntest.main.file_append(os.path.join(sbox.wc_dir, 'iota'), 'newer line\n')
    sbox.simple_commit(message='log msg')
    svntest.main.file_append(os.path.join(sbox.wc_dir, 'iota'), 'newest line\n')
    sbox.simple_commit(message='log msg')
    expected_current_contents = open(current_path).read()
    os.rename(os.path.join(sbox.repo_dir, 'db', 'current'), os.path.join(sbox.repo_dir, 'db', 'was_current'))
    (exit_code, output, errput) = svntest.main.run_svnadmin('recover', sbox.repo_dir)
    if errput:
        raise SVNUnexpectedStderr(errput)
    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)
    svntest.main.file_write(current_path, '2\n')
    (exit_code, output, errput) = svntest.main.run_svnadmin('recover', sbox.repo_dir)
    if errput:
        raise SVNUnexpectedStderr(errput)
    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)
    svntest.main.file_write(current_path, '1\n')
    (exit_code, output, errput) = svntest.main.run_svnadmin('recover', sbox.repo_dir)
    if errput:
        raise SVNUnexpectedStderr(errput)
    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)
    svntest.main.file_write(current_path, 'fish\n')
    (exit_code, output, errput) = svntest.main.run_svnadmin('recover', sbox.repo_dir)
    if errput:
        raise SVNUnexpectedStderr(errput)
    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)