def locking(sbox):
    'svnadmin lock tests'
    sbox.build(create_wc=False)
    comment_path = os.path.join(svntest.main.temp_dir, 'comment')
    svntest.main.file_write(comment_path, 'dummy comment')
    invalid_comment_path = os.path.join(svntest.main.temp_dir, 'invalid_comment')
    svntest.main.file_write(invalid_comment_path, 'character \x0c is invalid')
    expected_error = '.*svnadmin: E130004:.*'
    svntest.actions.run_and_verify_svnadmin(None, expected_error, 'lock', sbox.repo_dir, 'iota', 'jrandom', invalid_comment_path)
    expected_output = "'/iota' locked by user 'jrandom'."
    svntest.actions.run_and_verify_svnadmin(expected_output, None, 'lock', sbox.repo_dir, 'iota', 'jrandom', comment_path, '--bypass-hooks')
    svntest.actions.run_and_verify_svnadmin(None, None, 'rmlocks', sbox.repo_dir, 'iota')
    expected_output = "'/iota' locked by user 'jrandom'."
    svntest.actions.run_and_verify_svnadmin(expected_output, None, 'lock', sbox.repo_dir, 'iota', 'jrandom', comment_path)
    expected_error = '.*svnadmin: E160035:.*'
    svntest.actions.run_and_verify_svnadmin(None, expected_error, 'lock', sbox.repo_dir, 'iota', 'jrandom', comment_path)
    expected_error = '.*svnadmin: E160013:.*'
    svntest.actions.run_and_verify_svnadmin(None, expected_error, 'lock', sbox.repo_dir, 'non-existent', 'jrandom', comment_path)
    expected_output = "'/A/D/G/rho' locked by user 'jrandom'."
    lock_token = 'opaquelocktoken:01234567-89ab-cdef-89ab-cdef01234567'
    svntest.actions.run_and_verify_svnadmin(expected_output, None, 'lock', sbox.repo_dir, 'A/D/G/rho', 'jrandom', comment_path, lock_token)
    expected_error = '.*svnadmin: E160040:.*'
    wrong_lock_token = 'opaquelocktoken:12345670-9ab8-defc-9ab8-def01234567c'
    svntest.actions.run_and_verify_svnadmin(None, expected_error, 'unlock', sbox.repo_dir, 'A/D/G/rho', 'jrandom', wrong_lock_token)
    expected_output = "'/A/D/G/rho' unlocked by user 'jrandom'."
    svntest.actions.run_and_verify_svnadmin(expected_output, None, 'unlock', sbox.repo_dir, 'A/D/G/rho', 'jrandom', lock_token)
    hook_path = svntest.main.get_pre_lock_hook_path(sbox.repo_dir)
    svntest.main.create_python_hook_script(hook_path, 'import sys; sys.exit(1)')
    hook_path = svntest.main.get_pre_unlock_hook_path(sbox.repo_dir)
    svntest.main.create_python_hook_script(hook_path, 'import sys; sys.exit(1)')
    expected_error = '.*svnadmin: E165001:.*'
    svntest.actions.run_and_verify_svnadmin(None, expected_error, 'lock', sbox.repo_dir, 'iota', 'jrandom', comment_path)
    (exit_code, output, errput) = svntest.main.run_svnadmin('lslocks', sbox.repo_dir, 'iota')
    iota_token = None
    for line in output:
        if line.startswith('UUID Token: opaquelocktoken:'):
            iota_token = line[12:].rstrip()
            break
    if (iota_token is None):
        raise svntest.Failure("Unable to lookup lock token for 'iota'")
    expected_error = '.*svnadmin: E165001:.*'
    svntest.actions.run_and_verify_svnadmin(None, expected_error, 'unlock', sbox.repo_dir, 'iota', 'jrandom', iota_token)
    expected_output = "'/iota' unlocked by user 'jrandom'."
    svntest.actions.run_and_verify_svnadmin(expected_output, None, 'unlock', '--bypass-hooks', sbox.repo_dir, 'iota', 'jrandom', iota_token)
svnadmin lock tests
def locking(sbox):
    
    sbox.build(create_wc=False)
    comment_path = os.path.join(svntest.main.temp_dir, 'comment')
    svntest.main.file_write(comment_path, 'dummy comment')
    invalid_comment_path = os.path.join(svntest.main.temp_dir, 'invalid_comment')
    svntest.main.file_write(invalid_comment_path, 'character \x0c is invalid')
    expected_error = '.*svnadmin: E130004:.*'
    svntest.actions.run_and_verify_svnadmin(None, expected_error, 'lock', sbox.repo_dir, 'iota', 'jrandom', invalid_comment_path)
    expected_output = "'/iota' locked by user 'jrandom'."
    svntest.actions.run_and_verify_svnadmin(expected_output, None, 'lock', sbox.repo_dir, 'iota', 'jrandom', comment_path, '--bypass-hooks')
    svntest.actions.run_and_verify_svnadmin(None, None, 'rmlocks', sbox.repo_dir, 'iota')
    expected_output = "'/iota' locked by user 'jrandom'."
    svntest.actions.run_and_verify_svnadmin(expected_output, None, 'lock', sbox.repo_dir, 'iota', 'jrandom', comment_path)
    expected_error = '.*svnadmin: E160035:.*'
    svntest.actions.run_and_verify_svnadmin(None, expected_error, 'lock', sbox.repo_dir, 'iota', 'jrandom', comment_path)
    expected_error = '.*svnadmin: E160013:.*'
    svntest.actions.run_and_verify_svnadmin(None, expected_error, 'lock', sbox.repo_dir, 'non-existent', 'jrandom', comment_path)
    expected_output = "'/A/D/G/rho' locked by user 'jrandom'."
    lock_token = 'opaquelocktoken:01234567-89ab-cdef-89ab-cdef01234567'
    svntest.actions.run_and_verify_svnadmin(expected_output, None, 'lock', sbox.repo_dir, 'A/D/G/rho', 'jrandom', comment_path, lock_token)
    expected_error = '.*svnadmin: E160040:.*'
    wrong_lock_token = 'opaquelocktoken:12345670-9ab8-defc-9ab8-def01234567c'
    svntest.actions.run_and_verify_svnadmin(None, expected_error, 'unlock', sbox.repo_dir, 'A/D/G/rho', 'jrandom', wrong_lock_token)
    expected_output = "'/A/D/G/rho' unlocked by user 'jrandom'."
    svntest.actions.run_and_verify_svnadmin(expected_output, None, 'unlock', sbox.repo_dir, 'A/D/G/rho', 'jrandom', lock_token)
    hook_path = svntest.main.get_pre_lock_hook_path(sbox.repo_dir)
    svntest.main.create_python_hook_script(hook_path, 'import sys; sys.exit(1)')
    hook_path = svntest.main.get_pre_unlock_hook_path(sbox.repo_dir)
    svntest.main.create_python_hook_script(hook_path, 'import sys; sys.exit(1)')
    expected_error = '.*svnadmin: E165001:.*'
    svntest.actions.run_and_verify_svnadmin(None, expected_error, 'lock', sbox.repo_dir, 'iota', 'jrandom', comment_path)
    (exit_code, output, errput) = svntest.main.run_svnadmin('lslocks', sbox.repo_dir, 'iota')
    iota_token = None
    for line in output:
        if line.startswith('UUID Token: opaquelocktoken:'):
            iota_token = line[12:].rstrip()
            break
    if (iota_token is None):
        raise svntest.Failure("Unable to lookup lock token for 'iota'")
    expected_error = '.*svnadmin: E165001:.*'
    svntest.actions.run_and_verify_svnadmin(None, expected_error, 'unlock', sbox.repo_dir, 'iota', 'jrandom', iota_token)
    expected_output = "'/iota' unlocked by user 'jrandom'."
    svntest.actions.run_and_verify_svnadmin(expected_output, None, 'unlock', '--bypass-hooks', sbox.repo_dir, 'iota', 'jrandom', iota_token)