import sys, os, re
import svntest
from svntest import wc
Skip = svntest.testcase.Skip_deco
SkipUnless = svntest.testcase.SkipUnless_deco
XFail = svntest.testcase.XFail_deco
Issues = svntest.testcase.Issues_deco
Issue = svntest.testcase.Issue_deco
Wimp = svntest.testcase.Wimp_deco
Item = svntest.wc.StateItem
from svntest.main import server_has_revprop_commit, \
server_gets_client_capabilities
from svntest.actions import inject_conflict_into_wc
def is_non_posix_os_or_cygwin_platform():
return (not svntest.main.is_posix_os()) or sys.platform == 'cygwin'
def get_standard_state(wc_dir):
"""Return a status list reflecting the local mods made by
make_standard_slew_of_changes()."""
state = svntest.actions.get_virginal_state(wc_dir, 1)
state.tweak('', 'A/D', 'A/D/G/pi', status=' M')
state.tweak('A/B/lambda', status='M ')
state.tweak('A/B/E', 'A/D/H/chi', status='R ')
state.tweak('A/B/E/alpha', 'A/B/E/beta', 'A/C', 'A/D/gamma',
'A/D/G/rho', status='D ')
state.tweak('A/D/H/omega', status='MM')
state.add({
'Q' : Item(status='A ', wc_rev=0),
'Q/floo' : Item(status='A ', wc_rev=0),
'A/D/H/gloo' : Item(status='A ', wc_rev=0),
'A/B/E/bloo' : Item(status='A ', wc_rev=0),
})
return state
def make_standard_slew_of_changes(wc_dir):
"""Make a specific set of local mods to WC_DIR. These will be used
by every commit-test. Verify the 'svn status' output, and return the
(pre-commit) status tree."""
was_cwd = os.getcwd()
os.chdir(wc_dir)
os.mkdir('Q')
svntest.main.run_svn(None, 'add', 'Q')
A_B_E = os.path.join('A', 'B', 'E')
svntest.main.run_svn(None, 'rm', A_B_E)
svntest.main.run_svn(None, 'rm', os.path.join('A', 'C'))
if not os.path.exists(A_B_E):
os.mkdir(A_B_E)
svntest.main.run_svn(None, 'add', A_B_E)
svntest.main.run_svn(None, 'propset', 'foo', 'bar', os.curdir)
svntest.main.run_svn(None, 'propset', 'foo2', 'bar2', os.path.join('A', 'D'))
svntest.main.file_append(os.path.join('A', 'B', 'E', 'bloo'), "hi")
svntest.main.file_append(os.path.join('A', 'D', 'H', 'gloo'), "hello")
svntest.main.file_append(os.path.join('Q', 'floo'), "yo")
svntest.main.run_svn(None, 'add', os.path.join('A', 'B', 'E', 'bloo'))
svntest.main.run_svn(None, 'add', os.path.join('A', 'D', 'H', 'gloo'))
svntest.main.run_svn(None, 'add', os.path.join('Q', 'floo'))
svntest.main.run_svn(None, 'rm', os.path.join('A', 'D', 'G', 'rho'))
svntest.main.run_svn(None, 'rm', os.path.join('A', 'D', 'H', 'chi'))
svntest.main.run_svn(None, 'rm', os.path.join('A', 'D', 'gamma'))
svntest.main.file_append(os.path.join('A', 'D', 'H', 'chi'), "chi")
svntest.main.run_svn(None, 'add', os.path.join('A', 'D', 'H', 'chi'))
svntest.main.file_append(os.path.join('A', 'B', 'lambda'), "new ltext")
svntest.main.file_append(os.path.join('A', 'D', 'H', 'omega'), "new otext")
svntest.main.run_svn(None, 'propset', 'blue', 'azul',
os.path.join('A', 'D', 'H', 'omega'))
svntest.main.run_svn(None, 'propset', 'green', 'verde',
os.path.join('Q', 'floo'))
svntest.main.run_svn(None, 'propset', 'red', 'rojo',
os.path.join('A', 'D', 'G', 'pi'))
os.chdir(was_cwd)
expected_status = get_standard_state(wc_dir)
svntest.actions.run_and_verify_status(wc_dir, expected_status)
return expected_status
def commit_one_file(sbox):
"commit one file"
sbox.build()
wc_dir = sbox.wc_dir
expected_status = make_standard_slew_of_changes(wc_dir)
omega_path = os.path.join(wc_dir, 'A', 'D', 'H', 'omega')
expected_output = svntest.wc.State(wc_dir, {
'A/D/H/omega' : Item(verb='Sending'),
})
expected_status.tweak('A/D/H/omega', wc_rev=2, status=' ')
svntest.actions.run_and_verify_commit(wc_dir,
expected_output,
expected_status,
None,
omega_path)
def commit_one_new_file(sbox):
"commit one newly added file"
sbox.build()
wc_dir = sbox.wc_dir
expected_status = make_standard_slew_of_changes(wc_dir)
gloo_path = os.path.join(wc_dir, 'A', 'D', 'H', 'gloo')
expected_output = svntest.wc.State(wc_dir, {
'A/D/H/gloo' : Item(verb='Adding'),
})
expected_status.tweak('A/D/H/gloo', wc_rev=2, status=' ')
svntest.actions.run_and_verify_commit(wc_dir,
expected_output,
expected_status,
None,
gloo_path)
def commit_one_new_binary_file(sbox):
"commit one newly added binary file"
sbox.build()
wc_dir = sbox.wc_dir
expected_status = make_standard_slew_of_changes(wc_dir)
gloo_path = os.path.join(wc_dir, 'A', 'D', 'H', 'gloo')
svntest.main.run_svn(None, 'propset', 'svn:mime-type',
'application/octet-stream', gloo_path)
expected_output = svntest.wc.State(wc_dir, {
'A/D/H/gloo' : Item(verb='Adding (bin)'),
})
expected_status.tweak('A/D/H/gloo', wc_rev=2, status=' ')
svntest.actions.run_and_verify_commit(wc_dir,
expected_output,
expected_status,
None,
gloo_path)
def commit_multiple_targets(sbox):
"commit multiple targets"
sbox.build()
wc_dir = sbox.wc_dir
AB_path = os.path.join(wc_dir, 'A', 'B')
lambda_path = os.path.join(wc_dir, 'A', 'B', 'lambda')
rho_path = os.path.join(wc_dir, 'A', 'D', 'G', 'rho')
pi_path = os.path.join(wc_dir, 'A', 'D', 'G', 'pi')
omega_path = os.path.join(wc_dir, 'A', 'D', 'H', 'omega')
psi_path = os.path.join(wc_dir, 'A', 'D', 'H', 'psi')
svntest.main.file_append(lambda_path, 'new appended text for lambda')
svntest.main.file_append(rho_path, 'new appended text for rho')
svntest.main.file_append(pi_path, 'new appended text for pi')
svntest.main.file_append(omega_path, 'new appended text for omega')
svntest.main.file_append(psi_path, 'new appended text for psi')
ADG_path = os.path.join(wc_dir, 'A', 'D', 'G')
svntest.main.run_svn(None, 'propset', 'foo', 'bar', ADG_path)
expected_output = svntest.wc.State(wc_dir, {
'A/D/H/psi' : Item(verb='Sending'),
'A/B/lambda' : Item(verb='Sending'),
'A/D/G/pi' : Item(verb='Sending'),
})
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
expected_status.tweak('A/D/H/psi', 'A/B/lambda', 'A/D/G/pi', wc_rev=2)
expected_status.tweak('A/D/G/rho', 'A/D/H/omega', status='M ')
expected_status.tweak('A/D/G', status=' M')
svntest.actions.run_and_verify_commit(wc_dir,
expected_output,
expected_status,
None,
psi_path, AB_path, pi_path)
def commit_multiple_targets_2(sbox):
"commit multiple targets, 2nd variation"
sbox.build()
wc_dir = sbox.wc_dir
AB_path = os.path.join(wc_dir, 'A', 'B')
lambda_path = os.path.join(wc_dir, 'A', 'B', 'lambda')
rho_path = os.path.join(wc_dir, 'A', 'D', 'G', 'rho')
pi_path = os.path.join(wc_dir, 'A', 'D', 'G', 'pi')
omega_path = os.path.join(wc_dir, 'A', 'D', 'H', 'omega')
psi_path = os.path.join(wc_dir, 'A', 'D', 'H', 'psi')
svntest.main.file_append(lambda_path, 'new appended text for lambda')
svntest.main.file_append(rho_path, 'new appended text for rho')
svntest.main.file_append(pi_path, 'new appended text for pi')
svntest.main.file_append(omega_path, 'new appended text for omega')
svntest.main.file_append(psi_path, 'new appended text for psi')
ADG_path = os.path.join(wc_dir, 'A', 'D', 'G')
svntest.main.run_svn(None, 'propset', 'foo', 'bar', ADG_path)
expected_output = svntest.wc.State(wc_dir, {
'A/D/H/psi' : Item(verb='Sending'),
'A/B/lambda' : Item(verb='Sending'),
'A/D/H/omega' : Item(verb='Sending'),
'A/D/G/pi' : Item(verb='Sending'),
})
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
expected_status.tweak('A/D/H/psi', 'A/B/lambda', 'A/D/G/pi', 'A/D/H/omega',
wc_rev=2)
expected_status.tweak('A/D/G/rho', status='M ')
expected_status.tweak('A/D/G', status=' M')
svntest.actions.run_and_verify_commit(wc_dir,
expected_output,
expected_status,
None,
psi_path, AB_path,
omega_path, pi_path)
def commit_inclusive_dir(sbox):
"commit wc_dir/A/D -- includes D. (anchor=A, tgt=D)"
sbox.build()
wc_dir = sbox.wc_dir
expected_status = make_standard_slew_of_changes(wc_dir)
D_path = os.path.join(wc_dir, 'A', 'D')
expected_output = svntest.wc.State(wc_dir, {
'A/D' : Item(verb='Sending'),
'A/D/G/pi' : Item(verb='Sending'),
'A/D/G/rho' : Item(verb='Deleting'),
'A/D/H/gloo' : Item(verb='Adding'),
'A/D/H/chi' : Item(verb='Replacing'),
'A/D/H/omega' : Item(verb='Sending'),
'A/D/gamma' : Item(verb='Deleting'),
})
expected_status.remove('A/D/G/rho', 'A/D/gamma')
expected_status.tweak('A/D', 'A/D/G/pi', 'A/D/H/omega',
wc_rev=2, status=' ')
expected_status.tweak('A/D/H/chi', 'A/D/H/gloo', wc_rev=2, status=' ')
svntest.actions.run_and_verify_commit(wc_dir,
expected_output,
expected_status,
None,
D_path)
def commit_top_dir(sbox):
"commit wc_dir -- (anchor=wc_dir, tgt={})"
sbox.build()
wc_dir = sbox.wc_dir
expected_status = make_standard_slew_of_changes(wc_dir)
expected_output = svntest.wc.State(wc_dir, {
'' : Item(verb='Sending'),
'Q' : Item(verb='Adding'),
'Q/floo' : Item(verb='Adding'),
'A/B/E' : Item(verb='Replacing'),
'A/B/E/bloo' : Item(verb='Adding'),
'A/B/lambda' : Item(verb='Sending'),
'A/C' : Item(verb='Deleting'),
'A/D' : Item(verb='Sending'),
'A/D/G/pi' : Item(verb='Sending'),
'A/D/G/rho' : Item(verb='Deleting'),
'A/D/H/gloo' : Item(verb='Adding'),
'A/D/H/chi' : Item(verb='Replacing'),
'A/D/H/omega' : Item(verb='Sending'),
'A/D/gamma' : Item(verb='Deleting'),
})
expected_status.remove('A/D/G/rho', 'A/D/gamma', 'A/C',
'A/B/E/alpha', 'A/B/E/beta')
expected_status.tweak('A/D', 'A/D/G/pi', 'A/D/H/omega', 'Q/floo', '',
wc_rev=2, status=' ')
expected_status.tweak('A/D/H/chi', 'Q', 'A/B/E', 'A/B/E/bloo', 'A/B/lambda',
'A/D/H/gloo', wc_rev=2, status=' ')
svntest.actions.run_and_verify_commit(wc_dir,
expected_output,
expected_status,
None,
wc_dir)
def commit_unversioned_thing(sbox):
"committing unversioned object produces error"
sbox.build()
wc_dir = sbox.wc_dir
svntest.main.file_append(os.path.join(wc_dir, 'blorg'), "nothing to see")
svntest.actions.run_and_verify_commit(wc_dir,
None,
None,
"is not under version control",
os.path.join(wc_dir,'blorg'))
def nested_dir_replacements(sbox):
"replace two nested dirs, verify empty contents"
sbox.build()
wc_dir = sbox.wc_dir
A_D = os.path.join(wc_dir, 'A', 'D')
svntest.main.run_svn(None, 'rm', A_D)
if not os.path.exists(A_D):
os.mkdir(A_D)
os.mkdir(os.path.join(A_D, 'H'))
svntest.main.run_svn(None, 'add', '--depth=empty', A_D)
svntest.main.run_svn(None, 'add', '--depth=empty', os.path.join(A_D, 'H'))
svntest.main.file_append(os.path.join(A_D, 'bloo'), "hi")
svntest.main.run_svn(None, 'add', os.path.join(A_D, 'bloo'))
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
expected_status.tweak('A/D', status='R ', wc_rev=1)
expected_status.tweak('A/D/H', status='A ', wc_rev='-',
entry_status='R ', entry_rev='1')
expected_status.add({
'A/D/bloo' : Item(status='A ', wc_rev=0),
})
expected_status.tweak('A/D/G', 'A/D/G/pi', 'A/D/G/rho', 'A/D/G/tau',
'A/D/H/chi', 'A/D/H/omega', 'A/D/H/psi', 'A/D/gamma',
status='D ')
svntest.actions.run_and_verify_status(wc_dir, expected_status)
expected_output = svntest.wc.State(wc_dir, {
'A/D' : Item(verb='Replacing'),
'A/D/H' : Item(verb='Adding'),
'A/D/bloo' : Item(verb='Adding'),
})
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
expected_status.tweak('A/D', 'A/D/H', wc_rev=2)
expected_status.add({
'A/D/bloo' : Item(status=' ', wc_rev=2),
})
expected_status.remove('A/D/G', 'A/D/G/pi', 'A/D/G/rho', 'A/D/G/tau',
'A/D/H/chi', 'A/D/H/omega', 'A/D/H/psi', 'A/D/gamma')
svntest.actions.run_and_verify_commit(wc_dir,
expected_output,
expected_status,
None,
wc_dir)
def hudson_part_1(sbox):
"hudson prob 1.0: delete file, commit, update"
sbox.build()
wc_dir = sbox.wc_dir
gamma_path = os.path.join(wc_dir, 'A', 'D', 'gamma')
svntest.main.run_svn(None, 'rm', gamma_path)
expected_output = svntest.wc.State(wc_dir, {
'A/D/gamma' : Item(verb='Deleting'),
})
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
expected_status.remove('A/D/gamma')
svntest.actions.run_and_verify_commit(wc_dir,
expected_output,
expected_status,
None, wc_dir)
expected_output = svntest.wc.State(wc_dir, {})
expected_disk = svntest.main.greek_state.copy()
expected_disk.remove('A/D/gamma')
expected_status = svntest.actions.get_virginal_state(wc_dir, 2)
expected_status.remove('A/D/gamma')
svntest.actions.run_and_verify_update(wc_dir,
expected_output,
expected_disk,
expected_status)
def hudson_part_1_variation_1(sbox):
"hudson prob 1.1: delete dir, commit, update"
sbox.build()
wc_dir = sbox.wc_dir
H_path = os.path.join(wc_dir, 'A', 'D', 'H')
svntest.main.run_svn(None, 'rm', H_path)
expected_output = svntest.wc.State(wc_dir, {
'A/D/H' : Item(verb='Deleting'),
})
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
expected_status.remove('A/D/H', 'A/D/H/chi', 'A/D/H/omega', 'A/D/H/psi')
svntest.actions.run_and_verify_commit(wc_dir,
expected_output,
expected_status,
None, wc_dir)
expected_output = svntest.wc.State(wc_dir, {})
expected_disk = svntest.main.greek_state.copy()
expected_disk.remove('A/D/H', 'A/D/H/chi', 'A/D/H/omega', 'A/D/H/psi')
expected_status = svntest.actions.get_virginal_state(wc_dir, 2)
expected_status.remove('A/D/H', 'A/D/H/chi', 'A/D/H/omega', 'A/D/H/psi')
svntest.actions.run_and_verify_update(wc_dir,
expected_output,
expected_disk,
expected_status)
def hudson_part_1_variation_2(sbox):
"hudson prob 1.2: delete, commit, re-add, commit"
sbox.build()
wc_dir = sbox.wc_dir
gamma_path = os.path.join(wc_dir, 'A', 'D', 'gamma')
svntest.main.run_svn(None, 'rm', gamma_path)
expected_output = svntest.wc.State(wc_dir, {
'A/D/gamma' : Item(verb='Deleting'),
})
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
expected_status.remove('A/D/gamma')
svntest.actions.run_and_verify_commit(wc_dir,
expected_output,
expected_status,
None, wc_dir)
svntest.main.file_append(gamma_path, "added gamma")
svntest.main.run_svn(None, 'add', gamma_path)
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
expected_status.tweak('A/D/gamma', wc_rev=0, status='A ')
svntest.actions.run_and_verify_status(wc_dir, expected_status)
expected_output = svntest.wc.State(wc_dir, {
'A/D/gamma' : Item(verb='Adding'),
})
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
expected_status.tweak('A/D/gamma', wc_rev=3)
svntest.actions.run_and_verify_commit(wc_dir,
expected_output,
expected_status,
None, wc_dir)
def hudson_part_2(sbox):
"hudson prob 2.0: prop commit on old dir fails"
sbox.build()
wc_dir = sbox.wc_dir
D_path = os.path.join(wc_dir, 'A', 'D')
gamma_path = os.path.join(wc_dir, 'A', 'D', 'gamma')
svntest.main.run_svn(None, 'rm', gamma_path)
expected_output = svntest.wc.State(wc_dir, {
'A/D/gamma' : Item(verb='Deleting'),
})
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
expected_status.remove('A/D/gamma')
svntest.actions.run_and_verify_commit(wc_dir,
expected_output,
expected_status,
None, wc_dir)
svntest.main.run_svn(None, 'ps', 'foo', 'bar', D_path)
svntest.actions.run_and_verify_commit(wc_dir,
None,
None,
"[Oo]ut.of.date",
wc_dir)
def hudson_part_2_1(sbox):
"hudson prob 2.1: move files, update empty dir"
sbox.build()
wc_dir = sbox.wc_dir
H_path = os.path.join(wc_dir, 'A', 'D', 'H')
G_path = os.path.join(wc_dir, 'A', 'D', 'G')
chi_path = os.path.join(H_path, 'chi')
psi_path = os.path.join(H_path, 'psi')
omega_path = os.path.join(H_path, 'omega')
svntest.main.run_svn(None, 'mv', chi_path, G_path)
svntest.main.run_svn(None, 'mv', psi_path, G_path)
svntest.main.run_svn(None, 'mv', omega_path, G_path)
expected_output = svntest.wc.State(wc_dir, {
'A/D/H/chi' : Item(verb='Deleting'),
'A/D/H/omega' : Item(verb='Deleting'),
'A/D/H/psi' : Item(verb='Deleting'),
'A/D/G/chi' : Item(verb='Adding'),
'A/D/G/omega' : Item(verb='Adding'),
'A/D/G/psi' : Item(verb='Adding'),
})
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
expected_status.remove('A/D/H/chi')
expected_status.remove('A/D/H/omega')
expected_status.remove('A/D/H/psi')
expected_status.add({ 'A/D/G/chi' :
Item(wc_rev=2, status=' ') })
expected_status.add({ 'A/D/G/omega' :
Item(wc_rev=2, status=' ') })
expected_status.add({ 'A/D/G/psi' :
Item(wc_rev=2, status=' ') })
svntest.actions.run_and_verify_commit(wc_dir,
expected_output,
expected_status,
None, wc_dir)
expected_output = svntest.wc.State(wc_dir, { })
expected_status.tweak(wc_rev=2)
expected_disk = svntest.main.greek_state.copy()
expected_disk.remove('A/D/H/chi', 'A/D/H/omega', 'A/D/H/psi')
expected_disk.add({
'A/D/G/chi' : Item("This is the file 'chi'.\n"),
})
expected_disk.add({
'A/D/G/omega' : Item("This is the file 'omega'.\n"),
})
expected_disk.add({
'A/D/G/psi' : Item("This is the file 'psi'.\n"),
})
svntest.actions.run_and_verify_update(wc_dir,
expected_output,
expected_disk,
expected_status)
def hook_test(sbox):
"hook testing"
sbox.build()
wc_dir = sbox.wc_dir
repo_dir = sbox.repo_dir
hook_format = """import sys
fp = open(sys.argv[1] + '/hooks.log', 'a')
fp.write("%s\\n")
fp.close()"""
start_commit_hook = svntest.main.get_start_commit_hook_path(repo_dir)
svntest.main.create_python_hook_script(start_commit_hook,
hook_format % "start_commit_hook")
pre_commit_hook = svntest.main.get_pre_commit_hook_path(repo_dir)
svntest.main.create_python_hook_script(pre_commit_hook,
hook_format % "pre_commit_hook")
post_commit_hook = svntest.main.get_post_commit_hook_path(repo_dir)
svntest.main.create_python_hook_script(post_commit_hook,
hook_format % "post_commit_hook")
iota_path = os.path.join(wc_dir, "iota")
svntest.main.file_append(iota_path, "More stuff in iota")
svntest.actions.run_and_verify_svn(None, [], [],
'ci', '--quiet',
'-m', 'log msg', wc_dir)
expected_data = [ 'start_commit_hook\n', 'pre_commit_hook\n', 'post_commit_hook\n' ]
logfilename = os.path.join(repo_dir, "hooks.log")
if os.path.exists(logfilename):
fp = open(logfilename)
else:
raise svntest.verify.SVNUnexpectedOutput("hook logfile %s not found")\
% logfilename
actual_data = fp.readlines()
fp.close()
os.unlink(logfilename)
svntest.verify.compare_and_display_lines('wrong hook logfile content',
'STDERR',
expected_data, actual_data)
def merge_mixed_revisions(sbox):
"commit mixed-rev wc (no erroneous merge error)"
sbox.build()
wc_dir = sbox.wc_dir
iota_path = os.path.join(wc_dir, 'iota')
H_path = os.path.join(wc_dir, 'A', 'D', 'H')
chi_path = os.path.join(wc_dir, 'A', 'D', 'H', 'chi')
omega_path = os.path.join(wc_dir, 'A', 'D', 'H', 'omega')
svntest.main.file_append(iota_path, "moo")
svntest.main.file_append(chi_path, "moo")
expected_output = svntest.wc.State(wc_dir, {
'iota' : Item(verb='Sending'),
'A/D/H/chi' : Item(verb='Sending'),
})
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
expected_status.tweak('iota', 'A/D/H/chi', wc_rev=2)
svntest.actions.run_and_verify_commit(wc_dir,
expected_output,
expected_status,
None, wc_dir)
expected_status = svntest.wc.State(wc_dir, {
'A/D/H' : Item(status=' ', wc_rev=2),
'A/D/H/chi' : Item(status=' ', wc_rev=2),
'A/D/H/omega' : Item(status=' ', wc_rev=2),
'A/D/H/psi' : Item(status=' ', wc_rev=2),
})
expected_disk = svntest.wc.State('', {
'omega' : Item("This is the file 'omega'.\n"),
'chi' : Item("This is the file 'chi'.\nmoo"),
'psi' : Item("This is the file 'psi'.\n"),
})
expected_output = svntest.wc.State(wc_dir, { })
svntest.actions.run_and_verify_update(H_path,
expected_output,
expected_disk,
expected_status)
svntest.main.file_append(iota_path, "moo2")
expected_output = svntest.wc.State(wc_dir, {
'iota' : Item(verb='Sending'),
})
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
expected_status.tweak('A/D/H', 'A/D/H/omega', 'A/D/H/chi', 'A/D/H/psi',
wc_rev=2)
expected_status.tweak('iota', wc_rev=3)
svntest.actions.run_and_verify_commit(wc_dir,
expected_output,
expected_status,
None, wc_dir)
svntest.main.file_append(chi_path, "moo3")
expected_output = svntest.wc.State(wc_dir, {
'A/D/H/chi' : Item(verb='Sending'),
})
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
expected_status.tweak('A/D/H/chi', wc_rev=4)
expected_status.tweak('A/D/H', 'A/D/H/omega', 'A/D/H/psi', wc_rev=2)
expected_status.tweak('iota', wc_rev=3)
svntest.actions.run_and_verify_commit(wc_dir,
expected_output,
expected_status,
None, wc_dir)
svntest.main.file_append(iota_path, "moomoo")
expected_output = svntest.wc.State(wc_dir, {
'iota' : Item(verb='Sending'),
})
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
expected_status.tweak('A/D/H', 'A/D/H/omega', 'A/D/H/psi', wc_rev=2)
expected_status.tweak('A/D/H/chi', wc_rev=4)
expected_status.tweak('iota', wc_rev=5)
svntest.actions.run_and_verify_commit(wc_dir,
expected_output,
expected_status,
None, wc_dir)
svntest.main.file_append(iota_path, "finalmoo")
svntest.main.file_append(omega_path, "finalmoo")
expected_output = svntest.wc.State(wc_dir, {
'iota' : Item(verb='Sending'),
'A/D/H/omega' : Item(verb='Sending'),
})
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
expected_status.tweak('iota', 'A/D/H/omega', wc_rev=6)
expected_status.tweak('A/D/H', 'A/D/H/psi', wc_rev=2)
expected_status.tweak('A/D/H/chi', wc_rev=4)
svntest.actions.run_and_verify_commit(wc_dir,
expected_output,
expected_status,
None, wc_dir)
def commit_uri_unsafe(sbox):
"commit files and dirs with URI-unsafe characters"
sbox.build()
wc_dir = sbox.wc_dir
if svntest.main.windows or sys.platform == 'cygwin':
angle_name = '_angle_'
nasty_name = '#![]{}()__%'
else:
angle_name = '<angle>'
nasty_name = '#![]{}()<>%'
hash_dir = os.path.join(wc_dir, '#hash#')
nasty_dir = os.path.join(wc_dir, nasty_name)
space_path = os.path.join(wc_dir, 'A', 'D', 'space path')
bang_path = os.path.join(wc_dir, 'A', 'D', 'H', 'bang!')
bracket_path = os.path.join(wc_dir, 'A', 'D', 'H', 'bra[ket')
brace_path = os.path.join(wc_dir, 'A', 'D', 'H', 'bra{e')
angle_path = os.path.join(wc_dir, 'A', 'D', 'H', angle_name)
paren_path = os.path.join(wc_dir, 'A', 'D', 'pare)(theses')
percent_path = os.path.join(wc_dir, '#hash#', 'percen%')
nasty_path = os.path.join(wc_dir, 'A', nasty_name)
os.mkdir(hash_dir)
os.mkdir(nasty_dir)
svntest.main.file_append(space_path, "This path has a space in it.")
svntest.main.file_append(bang_path, "This path has a bang in it.")
svntest.main.file_append(bracket_path, "This path has a bracket in it.")
svntest.main.file_append(brace_path, "This path has a brace in it.")
svntest.main.file_append(angle_path, "This path has angle brackets in it.")
svntest.main.file_append(paren_path, "This path has parentheses in it.")
svntest.main.file_append(percent_path, "This path has a percent in it.")
svntest.main.file_append(nasty_path, "This path has all sorts of ick in it.")
add_list = [hash_dir,
nasty_dir, space_path,
bang_path,
bracket_path,
brace_path,
angle_path, paren_path,
percent_path,
nasty_path, ]
for item in add_list:
svntest.main.run_svn(None, 'add', '--depth=empty', item)
expected_output = svntest.wc.State(wc_dir, {
'#hash#' : Item(verb='Adding'),
nasty_name : Item(verb='Adding'),
'A/D/space path' : Item(verb='Adding'),
'A/D/H/bang!' : Item(verb='Adding'),
'A/D/H/bra[ket' : Item(verb='Adding'),
'A/D/H/bra{e' : Item(verb='Adding'),
'A/D/H/' + angle_name : Item(verb='Adding'),
'A/D/pare)(theses' : Item(verb='Adding'),
'#hash#/percen%' : Item(verb='Adding'),
'A/' + nasty_name : Item(verb='Adding'),
})
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
for item in expected_output.desc.keys():
expected_status.add({ item : Item(wc_rev=2, status=' ') })
svntest.actions.run_and_verify_commit(wc_dir,
expected_output,
expected_status,
None, wc_dir)
def commit_deleted_edited(sbox):
"commit deleted yet edited files"
sbox.build()
wc_dir = sbox.wc_dir
iota_path = os.path.join(wc_dir, 'iota')
mu_path = os.path.join(wc_dir, 'A', 'mu')
svntest.main.file_append(iota_path, "This file has been edited.")
svntest.main.file_append(mu_path, "This file has been edited.")
svntest.main.run_svn(None, 'remove', '--force', iota_path)
svntest.main.run_svn(None, 'remove', '--force', mu_path)
expected_output = svntest.wc.State(wc_dir, {
'iota' : Item(verb='Deleting'),
'A/mu' : Item(verb='Deleting'),
})
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
expected_status.remove('iota', 'A/mu')
svntest.actions.run_and_verify_commit(wc_dir,
expected_output,
expected_status,
None, wc_dir)
def commit_in_dir_scheduled_for_addition(sbox):
"commit a file inside dir scheduled for addition"
sbox.build()
wc_dir = sbox.wc_dir
A_path = os.path.join(wc_dir, 'A')
Z_path = os.path.join(wc_dir, 'Z')
Z_abspath = os.path.abspath(Z_path)
mu_path = os.path.join(wc_dir, 'Z', 'mu')
svntest.main.run_svn(None, 'move', A_path, Z_path)
svntest.main.file_write(mu_path, "xxxx")
svntest.actions.run_and_verify_commit(wc_dir,
None,
None,
"svn: E200009: '" +
re.escape(Z_abspath) +
"' is not known to exist in the",
mu_path)
Q_path = os.path.join(wc_dir, 'Q')
Q_abspath = os.path.abspath(Q_path)
bloo_path = os.path.join(Q_path, 'bloo')
os.mkdir(Q_path)
svntest.main.file_append(bloo_path, "New contents.")
svntest.main.run_svn(None, 'add', Q_path)
svntest.actions.run_and_verify_commit(wc_dir,
None,
None,
"svn: E200009: '" +
re.escape(Q_abspath) +
"' is not known to exist in the",
bloo_path)
R_path = sbox.ospath('Z/B/R')
sbox.simple_mkdir('Z/B/R')
svntest.actions.run_and_verify_commit(wc_dir,
None,
None,
"svn: E200009: '" +
re.escape(Z_abspath) +
"' is not known to exist in the.*",
R_path)
def commit_rmd_and_deleted_file(sbox):
"commit deleted (and missing) file"
sbox.build()
wc_dir = sbox.wc_dir
mu_path = os.path.join(wc_dir, 'A', 'mu')
svntest.main.run_svn(None, 'rm', mu_path)
svntest.actions.run_and_verify_svn("Output on stderr where none expected",
svntest.verify.AnyOutput, [],
'commit', '-m', 'logmsg', mu_path)
@Issue(644)
def commit_add_file_twice(sbox):
"issue 644 attempt to add a file twice"
sbox.build()
wc_dir = sbox.wc_dir
gloo_path = os.path.join(wc_dir, 'A', 'D', 'H', 'gloo')
svntest.main.file_append(gloo_path, "hello")
svntest.main.run_svn(None, 'add', gloo_path)
expected_output = svntest.wc.State(wc_dir, {
'A/D/H/gloo' : Item(verb='Adding'),
})
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
expected_status.add({
'A/D/H/gloo' : Item(status=' ', wc_rev=2),
})
svntest.actions.run_and_verify_commit(wc_dir,
expected_output,
expected_status,
None,
wc_dir)
svntest.main.run_svn(None, 'up', '-r', '1', wc_dir)
svntest.main.file_append(gloo_path, "hello")
svntest.main.run_svn(None, 'add', gloo_path)
svntest.actions.run_and_verify_commit(wc_dir,
None,
None,
"already exists",
wc_dir)
def commit_from_long_dir(sbox):
"commit from a dir with a longer name than the wc"
sbox.build()
wc_dir = sbox.wc_dir
was_dir = os.getcwd()
abs_wc_dir = os.path.realpath(os.path.join(was_dir, wc_dir))
svntest.main.file_append(os.path.join(wc_dir, 'iota'), "modified iota")
expected_output = svntest.wc.State('', {
'iota' : Item(verb='Sending'),
})
extra_name = 'xx'
os.chdir(wc_dir)
os.mkdir(extra_name)
os.chdir(extra_name)
svntest.actions.run_and_verify_commit(abs_wc_dir,
expected_output,
None,
None,
abs_wc_dir)
def commit_with_lock(sbox):
"try to commit when directory is locked"
sbox.build()
wc_dir = sbox.wc_dir
D_path = os.path.join(wc_dir, 'A', 'D')
gamma_path = os.path.join(D_path, 'gamma')
svntest.main.file_append(gamma_path, "modified gamma")
svntest.actions.lock_admin_dir(D_path)
svntest.actions.run_and_verify_commit(wc_dir,
None,
None,
'svn: E155004: '
'Working copy \'.*\' locked',
wc_dir)
svntest.actions.run_and_verify_svn("Output on stderr where none expected",
[], [],
'cleanup', D_path)
expected_output = svntest.wc.State(wc_dir, {
'A/D/gamma' : Item(verb='Sending'),
})
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
expected_status.tweak('A/D/gamma', wc_rev=2)
svntest.actions.run_and_verify_commit(wc_dir,
expected_output,
expected_status,
None,
wc_dir)
def commit_current_dir(sbox):
"commit the current directory"
sbox.build()
wc_dir = sbox.wc_dir
svntest.main.run_svn(None, 'propset', 'pname', 'pval', wc_dir)
was_cwd = os.getcwd()
os.chdir(wc_dir)
expected_output = svntest.wc.State('.', {
'.' : Item(verb='Sending'),
})
svntest.actions.run_and_verify_commit('.',
expected_output,
None,
None,
'.')
os.chdir(was_cwd)
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
expected_status.tweak('', wc_rev=2, status=' ')
svntest.actions.run_and_verify_status(wc_dir, expected_status)
def failed_commit(sbox):
"commit with conflicts and check txn in repo"
sbox.build()
wc_dir = sbox.wc_dir
other_wc_dir = sbox.add_wc_path('other')
svntest.actions.duplicate_dir(wc_dir, other_wc_dir)
iota_path = os.path.join(wc_dir, "iota")
svntest.main.file_append(iota_path, "More stuff in iota")
other_iota_path = os.path.join(other_wc_dir, "iota")
svntest.main.file_append(other_iota_path, "More different stuff in iota")
svntest.actions.run_and_verify_svn("Output on stderr where none expected",
svntest.verify.AnyOutput, [],
'commit', '-m', 'log', wc_dir)
svntest.actions.run_and_verify_svn("Output on stderr expected",
None, svntest.verify.AnyOutput,
'commit', '-m', 'log', other_wc_dir)
exit_code, output, errput = svntest.main.run_svnadmin('lstxns',
sbox.repo_dir)
svntest.verify.compare_and_display_lines(
"Error running 'svnadmin lstxns'.",
'STDERR', [], errput)
svntest.verify.compare_and_display_lines(
"Output of 'svnadmin lstxns' is unexpected.",
'STDOUT', [], output)
@Issue(2381)
def commit_multiple_wc_nested(sbox):
"commit from two nested working copies"
sbox.build()
wc_dir = sbox.wc_dir
wc2_dir = os.path.join(wc_dir, 'A', 'wc2')
url = sbox.repo_url
svntest.actions.run_and_verify_svn("Output on stderr where none expected",
svntest.verify.AnyOutput, [],
'checkout',
url, wc2_dir)
mu_path = os.path.join(wc_dir, 'A', 'mu')
svntest.main.file_append(mu_path, 'appended mu text')
lambda2_path = os.path.join(wc2_dir, 'A', 'B', 'lambda')
svntest.main.file_append(lambda2_path, 'appended lambda2 text')
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
expected_status.tweak('A/mu', status='M ')
svntest.actions.run_and_verify_status(wc_dir, expected_status)
expected_status2 = svntest.actions.get_virginal_state(wc2_dir, 1)
expected_status2.tweak('A/B/lambda', status='M ')
svntest.actions.run_and_verify_status(wc2_dir, expected_status2)
svntest.actions.run_and_verify_svn("Ouput on stderr where none expected",
svntest.verify.AnyOutput, [],
'commit', '-m', 'log',
wc_dir, wc2_dir)
expected_status.tweak('A/mu', status=' ', wc_rev=2)
expected_status2.tweak('A/B/lambda', status=' ', wc_rev=2)
svntest.actions.run_and_verify_status(wc_dir, expected_status)
svntest.actions.run_and_verify_status(wc2_dir, expected_status2)
@Issue(2381)
def commit_multiple_wc(sbox):
"commit from two working copies"
sbox.build()
wc_dir = sbox.wc_dir
svntest.sandbox._cleanup_test_path(wc_dir)
wc1_dir = os.path.join(wc_dir, 'wc1')
wc2_dir = os.path.join(wc_dir, 'wc2')
url = sbox.repo_url
svntest.actions.run_and_verify_svn("Output on stderr where none expected",
svntest.verify.AnyOutput, [],
'checkout',
url, wc1_dir)
svntest.actions.run_and_verify_svn("Output on stderr where none expected",
svntest.verify.AnyOutput, [],
'checkout',
url, wc2_dir)
mu1_path = os.path.join(wc1_dir, 'A', 'mu')
svntest.main.file_append(mu1_path, 'appended mu1 text')
lambda2_path = os.path.join(wc2_dir, 'A', 'B', 'lambda')
svntest.main.file_append(lambda2_path, 'appended lambda2 text')
expected_status1 = svntest.actions.get_virginal_state(wc1_dir, 1)
expected_status1.tweak('A/mu', status='M ')
svntest.actions.run_and_verify_status(wc1_dir, expected_status1)
expected_status2 = svntest.actions.get_virginal_state(wc2_dir, 1)
expected_status2.tweak('A/B/lambda', status='M ')
svntest.actions.run_and_verify_status(wc2_dir, expected_status2)
svntest.actions.run_and_verify_svn("Output on stderr where none expected",
svntest.verify.AnyOutput, [],
'commit', '-m', 'log',
wc1_dir, wc2_dir)
expected_status1.tweak('A/mu', status=' ', wc_rev=2)
expected_status2.tweak('A/B/lambda', status=' ', wc_rev=2)
svntest.actions.run_and_verify_status(wc1_dir, expected_status1)
svntest.actions.run_and_verify_status(wc2_dir, expected_status2)
@Issue(2381)
def commit_multiple_wc_multiple_repos(sbox):
"committing two WCs from different repos fails"
sbox.build()
wc_dir = sbox.wc_dir
repo2, url2 = sbox.add_repo_path("repo2")
svntest.main.copy_repos(sbox.repo_dir, repo2, 1, 1)
svntest.sandbox._cleanup_test_path(wc_dir)
wc1_dir = os.path.join(wc_dir, 'wc1')
wc2_dir = os.path.join(wc_dir, 'wc2')
svntest.actions.run_and_verify_svn("Output on stderr where none expected",
svntest.verify.AnyOutput, [],
'checkout',
sbox.repo_url, wc1_dir)
svntest.actions.run_and_verify_svn("Output on stderr where none expected",
svntest.verify.AnyOutput, [],
'checkout',
url2, wc2_dir)
mu1_path = os.path.join(wc1_dir, 'A', 'mu')
svntest.main.file_append(mu1_path, 'appended mu1 text')
lambda2_path = os.path.join(wc2_dir, 'A', 'B', 'lambda')
svntest.main.file_append(lambda2_path, 'appended lambda2 text')
expected_status1 = svntest.actions.get_virginal_state(wc1_dir, 1)
expected_status1.tweak('A/mu', status='M ')
svntest.actions.run_and_verify_status(wc1_dir, expected_status1)
expected_status2 = svntest.actions.get_virginal_state(wc2_dir, 1)
expected_status2.tweak('A/B/lambda', status='M ')
svntest.actions.run_and_verify_status(wc2_dir, expected_status2)
error_re = ( ".*(is not a working copy" +
"|Are all targets part of the same working copy" +
"|was not found).*" )
svntest.actions.run_and_verify_svn("Expected output on stderr doesn't match",
[], error_re,
'commit', '-m', 'log',
wc1_dir, wc2_dir)
svntest.actions.run_and_verify_status(wc1_dir, expected_status1)
svntest.actions.run_and_verify_status(wc2_dir, expected_status2)
@Issues(1195,1239)
def commit_nonrecursive(sbox):
"commit named targets with -N"
sbox.build()
wc_dir = sbox.wc_dir
file1_path = 'file1'
dir1_path = 'dir1'
file2_path = os.path.join('dir1', 'file2')
file3_path = os.path.join('dir1', 'file3')
dir2_path = os.path.join('dir1', 'dir2')
file4_path = os.path.join('dir1', 'dir2', 'file4')
svntest.main.file_append(os.path.join(wc_dir, file1_path), 'this is file1')
os.mkdir(os.path.join(wc_dir, dir1_path))
svntest.main.file_append(os.path.join(wc_dir, file2_path), 'this is file2')
svntest.main.file_append(os.path.join(wc_dir, file3_path), 'this is file3')
os.mkdir(os.path.join(wc_dir, dir2_path))
svntest.main.file_append(os.path.join(wc_dir, file4_path), 'this is file4')
svntest.actions.run_and_verify_svn(None, svntest.verify.AnyOutput, [],
'add', '--depth=empty',
os.path.join(wc_dir, file1_path),
os.path.join(wc_dir, dir1_path),
os.path.join(wc_dir, file2_path),
os.path.join(wc_dir, file3_path),
os.path.join(wc_dir, dir2_path),
os.path.join(wc_dir, file4_path))
expected_output = svntest.wc.State(
wc_dir,
{ file1_path : Item(verb='Adding'),
dir1_path : Item(verb='Adding'),
file2_path : Item(verb='Adding'),
file3_path : Item(verb='Adding'),
dir2_path : Item(verb='Adding'),
file4_path : Item(verb='Adding'),
}
)
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
expected_status.add({
file1_path : Item(status=' ', wc_rev=2),
dir1_path : Item(status=' ', wc_rev=2),
file2_path : Item(status=' ', wc_rev=2),
file3_path : Item(status=' ', wc_rev=2),
dir2_path : Item(status=' ', wc_rev=2),
file4_path : Item(status=' ', wc_rev=2),
})
svntest.actions.run_and_verify_commit(wc_dir,
expected_output,
expected_status,
None,
'-N',
os.path.join(wc_dir, file1_path),
os.path.join(wc_dir, dir1_path),
os.path.join(wc_dir, file2_path),
os.path.join(wc_dir, file3_path),
os.path.join(wc_dir, dir2_path),
os.path.join(wc_dir, file4_path))
dirA_path = 'dirA'
fileA_path = os.path.join('dirA', 'fileA')
fileB_path = os.path.join('dirA', 'fileB')
dirB_path = os.path.join('dirA', 'dirB')
nope_1_path = os.path.join(dirB_path, 'nope_1')
nope_2_path = os.path.join(dirB_path, 'nope_2')
os.mkdir(os.path.join(wc_dir, dirA_path))
svntest.main.file_append(os.path.join(wc_dir, fileA_path), 'fileA')
svntest.main.file_append(os.path.join(wc_dir, fileB_path), 'fileB')
os.mkdir(os.path.join(wc_dir, dirB_path))
svntest.main.file_append(os.path.join(wc_dir, nope_1_path), 'nope_1')
svntest.main.file_append(os.path.join(wc_dir, nope_2_path), 'nope_2')
svntest.actions.run_and_verify_svn(None, svntest.verify.AnyOutput, [],
'add', '-N',
os.path.join(wc_dir, dirA_path),
os.path.join(wc_dir, fileA_path),
os.path.join(wc_dir, dirB_path),
os.path.join(wc_dir, nope_1_path),
)
expected_output = svntest.wc.State(
wc_dir,
{ dirA_path : Item(verb='Adding'),
}
)
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
expected_status.add({
file1_path : Item(status=' ', wc_rev=2),
dir1_path : Item(status=' ', wc_rev=2),
file2_path : Item(status=' ', wc_rev=2),
file3_path : Item(status=' ', wc_rev=2),
dir2_path : Item(status=' ', wc_rev=2),
file4_path : Item(status=' ', wc_rev=2),
})
expected_status.add({
dirA_path : Item(status=' ', wc_rev=3),
fileA_path : Item(status='A ', wc_rev=0),
dirB_path : Item(status='A ', wc_rev=0),
nope_1_path : Item(status='A ', wc_rev=0),
})
svntest.actions.run_and_verify_commit(wc_dir,
expected_output,
expected_status,
None,
'-N', os.path.join(wc_dir, dirA_path))
def commit_out_of_date_deletions(sbox):
"commit deletion of out-of-date file or dir"
sbox.build()
wc_dir = sbox.wc_dir
I_path = os.path.join(wc_dir, 'A', 'I')
os.mkdir(I_path)
svntest.main.run_svn(None, 'add', I_path)
svntest.main.run_svn(None, 'ci', '-m', 'prep', wc_dir)
svntest.main.run_svn(None, 'up', wc_dir)
wc_backup = sbox.add_wc_path('backup')
svntest.actions.duplicate_dir(wc_dir, wc_backup)
C_path = os.path.join(wc_dir, 'A', 'C')
omega_path = os.path.join(wc_dir, 'A', 'D', 'H', 'omega')
alpha_path = os.path.join(wc_dir, 'A', 'B', 'E', 'alpha')
svntest.main.run_svn(None, 'propset', 'fooprop', 'foopropval', C_path)
svntest.main.file_append(omega_path, 'appended omega text')
svntest.main.run_svn(None, 'propset', 'fooprop', 'foopropval', alpha_path)
I_path = os.path.join(wc_dir, 'A', 'I')
F_path = os.path.join(wc_dir, 'A', 'B', 'F')
chi_path = os.path.join(wc_dir, 'A', 'D', 'H', 'chi')
beta_path = os.path.join(wc_dir, 'A', 'B', 'E', 'beta')
psi_path = os.path.join(wc_dir, 'A', 'D', 'H', 'psi')
svntest.main.run_svn(None, 'rm', I_path, F_path, chi_path, beta_path,
psi_path)
expected_output = svntest.wc.State(wc_dir, {
'A/C' : Item(verb='Sending'),
'A/I' : Item(verb='Deleting'),
'A/B/F' : Item(verb='Deleting'),
'A/D/H/omega' : Item(verb='Sending'),
'A/B/E/alpha' : Item(verb='Sending'),
'A/D/H/chi' : Item(verb='Deleting'),
'A/B/E/beta' : Item(verb='Deleting'),
'A/D/H/psi' : Item(verb='Deleting'),
})
expected_status = svntest.actions.get_virginal_state(wc_dir, 2)
expected_status.tweak('A/C', 'A/D/H/omega', 'A/B/E/alpha', wc_rev=3,
status=' ')
expected_status.remove('A/B/F', 'A/D/H/chi', 'A/B/E/beta', 'A/D/H/psi')
commit = svntest.actions.run_and_verify_commit
commit(wc_dir, expected_output, expected_status, None, wc_dir)
I_path = os.path.join(wc_backup, 'A', 'I')
chi_path = os.path.join(wc_backup, 'A', 'D', 'H', 'chi')
beta_path = os.path.join(wc_backup, 'A', 'B', 'E','beta')
svntest.main.run_svn(None, 'propset', 'fooprop', 'foopropval', I_path)
svntest.main.file_append(chi_path, 'appended chi text')
svntest.main.run_svn(None, 'propset', 'fooprop', 'foopropval', beta_path)
C_path = os.path.join(wc_backup, 'A', 'C')
F_path = os.path.join(wc_backup, 'A', 'B', 'F')
omega_path = os.path.join(wc_backup, 'A', 'D', 'H', 'omega')
alpha_path = os.path.join(wc_backup, 'A', 'B', 'E', 'alpha')
psi_path = os.path.join(wc_backup, 'A', 'D', 'H', 'psi')
svntest.main.run_svn(None, 'rm', C_path, F_path, omega_path, alpha_path,
psi_path)
error_re = "(out of date|not found)"
commit(wc_backup, None, None, error_re, C_path)
commit(wc_backup, None, None, error_re, I_path)
commit(wc_backup, None, None, error_re, F_path)
commit(wc_backup, None, None, error_re, omega_path)
commit(wc_backup, None, None, error_re, alpha_path)
commit(wc_backup, None, None, error_re, chi_path)
commit(wc_backup, None, None, error_re, beta_path)
commit(wc_backup, None, None, error_re, psi_path)
def commit_with_bad_log_message(sbox):
"commit with a log message containing bad data"
sbox.build()
wc_dir = sbox.wc_dir
iota_path = os.path.join(wc_dir, 'iota')
log_msg_path = os.path.join(wc_dir, 'log-message')
svntest.main.file_append(iota_path, 'fish')
svntest.main.file_append(log_msg_path, '\x00')
svntest.actions.run_and_verify_commit(wc_dir,
None, None,
"contains a zero byte",
'-F', log_msg_path,
iota_path)
def commit_with_mixed_line_endings(sbox):
"commit with log message with mixed EOL"
sbox.build()
wc_dir = sbox.wc_dir
expected_status = make_standard_slew_of_changes(wc_dir)
iota_path = os.path.join(wc_dir, 'iota')
log_msg_path = os.path.join(wc_dir, 'log-message')
svntest.main.file_append(iota_path, 'kebab')
svntest.main.file_append(log_msg_path, "test\nthis\n\rcase\r\n--This line, and those below, will be ignored--\n")
svntest.actions.run_and_verify_commit(wc_dir,
None, None,
"Error normalizing log message to internal format",
'-F', log_msg_path,
iota_path)
def commit_with_mixed_line_endings_in_ignored_part(sbox):
"commit with log message with mixed EOL in tail"
sbox.build()
wc_dir = sbox.wc_dir
expected_status = make_standard_slew_of_changes(wc_dir)
iota_path = os.path.join(wc_dir, 'iota')
log_msg_path = os.path.join(wc_dir, 'log-message')
svntest.main.file_append(iota_path, 'cheeseburger')
svntest.main.file_append(log_msg_path, "test\n--This line, and those below, will be ignored--\nfoo\r\nbar\nbaz\n\r")
expected_output = svntest.wc.State(wc_dir, {
'iota' : Item(verb='Sending'),
})
expected_status.tweak('iota', wc_rev=2, status=' ')
svntest.actions.run_and_verify_commit(wc_dir,
expected_output,
expected_status,
None,
iota_path)
def from_wc_top_with_bad_editor(sbox):
"commit with invalid external editor cmd"
sbox.build()
wc_dir = sbox.wc_dir
svntest.actions.run_and_verify_svn("Unexpected failure from propset.",
svntest.verify.AnyOutput, [],
'pset', 'fish', 'food', wc_dir)
os.chdir(wc_dir)
exit_code, out, err = svntest.actions.run_and_verify_svn(
"Commit succeeded when should have failed.",
None, svntest.verify.AnyOutput,
'ci', '--editor-cmd', 'no_such-editor')
err = " ".join([x.strip() for x in err])
if not (re.match(".*no_such-editor.*", err)
and re.match(".*Commit failed.*", err)):
print("Commit failed, but not in the way expected.")
raise svntest.Failure
def mods_in_schedule_delete(sbox):
"commit with mods in schedule delete"
sbox.build()
wc_dir = sbox.wc_dir
C_path = os.path.join(wc_dir, 'A', 'C')
svntest.actions.run_and_verify_svn(None, svntest.verify.AnyOutput, [],
'rm', C_path)
if not os.path.exists(C_path):
os.mkdir(C_path)
foo_path = os.path.join(C_path, 'foo')
foo_contents = 'zig\nzag\n'
svntest.main.file_append(foo_path, foo_contents)
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
expected_status.remove('A/C')
expected_output = svntest.wc.State(wc_dir, {
'A/C' : Item(verb='Deleting'),
})
svntest.actions.run_and_verify_commit(wc_dir,
expected_output, expected_status,
None, wc_dir)
actual_contents = open(foo_path).read()
if actual_contents != foo_contents:
raise svntest.Failure
@Skip(is_non_posix_os_or_cygwin_platform)
@Issue(1954)
def tab_test(sbox):
"tabs in paths"
sbox.build()
wc_dir = sbox.wc_dir
tab_file = os.path.join(wc_dir, 'A', "tab\tfile")
tab_dir = os.path.join(wc_dir, 'A', "tab\tdir")
source_url = sbox.repo_url + "/source_dir"
tab_url = sbox.repo_url + "/tab%09dir"
svntest.main.file_append(tab_file, "This file has a tab in it.")
os.mkdir(tab_dir)
def match_bad_tab_path(path, errlines):
match_re = ".*: Invalid control character '0x09' in path .*"
for line in errlines:
if re.match (match_re, line):
break
else:
raise svntest.Failure("Failed to find match_re in " + str(errlines))
exit_code, outlines, errlines = svntest.main.run_svn(1, 'add', tab_file)
match_bad_tab_path(tab_file, errlines)
exit_code, outlines, errlines = svntest.main.run_svn(1, 'add', tab_dir)
match_bad_tab_path(tab_dir, errlines)
exit_code, outlines, errlines = svntest.main.run_svn(1, 'mkdir',
'-m', 'msg', tab_url)
match_bad_tab_path(tab_dir, errlines)
svntest.main.run_svn(1,
'mkdir', '-m', 'msg', source_url)
exit_code, outlines, errlines = svntest.main.run_svn(1, 'copy',
'-m', 'msg',
source_url, tab_url)
match_bad_tab_path(tab_dir, errlines)
exit_code, outlines, errlines = svntest.main.run_svn(1, 'mv', '-m', 'msg',
source_url, tab_url)
match_bad_tab_path(tab_dir, errlines)
@Issue(2285)
def local_mods_are_not_commits(sbox):
"local ops should not be treated like commits"
sbox.build()
wc_dir = sbox.wc_dir
expected_error = '.*Local, non-commit operations do not take a log message.*'
svntest.actions.run_and_verify_svn(None, None, expected_error,
'cp', '-m', 'log msg',
os.path.join(wc_dir, 'iota'),
os.path.join(wc_dir, 'iota2'))
svntest.actions.run_and_verify_svn(None, None, expected_error,
'cp', '-m', 'log msg',
sbox.repo_url + "/iota",
os.path.join(wc_dir, 'iota2'))
svntest.actions.run_and_verify_svn(None, None, expected_error,
'rm', '-m', 'log msg',
os.path.join(wc_dir, 'A', 'D', 'gamma'))
svntest.actions.run_and_verify_svn(None, None, expected_error,
'mkdir', '-m', 'log msg',
os.path.join(wc_dir, 'newdir'))
svntest.actions.run_and_verify_svn(None, None, expected_error,
'cp', '-m', 'log msg',
os.path.join(wc_dir, 'A', 'mu'),
os.path.join(wc_dir, 'A', 'yu'))
@Issue(3553)
def post_commit_hook_test(sbox):
"post commit hook failure case testing"
sbox.build()
wc_dir = sbox.wc_dir
repo_dir = sbox.repo_dir
error_msg = "Text with <angle brackets> & ampersand"
svntest.actions.create_failing_hook(repo_dir, "post-commit", error_msg)
iota_path = os.path.join(wc_dir, "iota")
svntest.main.file_append(iota_path, "lakalakalakalaka")
expected_output = [ "Sending "+ iota_path + "\n",
"Transmitting file data .\n",
"Committed revision 2.\n",
"\n",
"Warning: " +
svntest.actions.hook_failure_message('post-commit'),
error_msg + "\n",
]
svntest.actions.run_and_verify_svn(None, expected_output, [],
'ci', '-m', 'log msg', iota_path)
def commit_same_folder_in_targets(sbox):
"commit two targets, both the same folder"
sbox.build()
wc_dir = sbox.wc_dir
iota_path = os.path.join(wc_dir, 'iota')
svntest.main.file_append(iota_path, "added extra line to file iota")
expected_output = svntest.wc.State(wc_dir, {
'iota' : Item(verb='Sending'),
})
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
expected_status.tweak('iota', wc_rev=2)
svntest.actions.run_and_verify_commit(wc_dir,
expected_output,
expected_status,
None,
'-N',
wc_dir,
iota_path)
@Issue(2459)
def commit_inconsistent_eol(sbox):
"commit files with inconsistent eol should fail"
sbox.build()
wc_dir = sbox.wc_dir
iota_path = os.path.join(wc_dir, 'iota')
mu_path = os.path.join(wc_dir, 'A', 'mu')
svntest.main.run_svn(None, 'propset', 'svn:eol-style', 'native', iota_path)
svntest.main.file_append_binary(iota_path,
"added extra line to file iota\012"
"added extra line to file iota\015")
svntest.main.file_append(mu_path, "added extra line to file mu\n"
"added extra line to file mu\n")
expected_err = ".*iota.*"
svntest.actions.run_and_verify_svn(None, None, expected_err,
'commit', '-m', 'log message',
wc_dir)
@SkipUnless(server_has_revprop_commit)
def mkdir_with_revprop(sbox):
"set revision props during remote mkdir"
sbox.build()
remote_dir = sbox.repo_url + "/dir"
svntest.actions.run_and_verify_svn(None, None, [], 'mkdir', '-m', 'msg',
'--with-revprop', 'bug=42', remote_dir)
expected = svntest.verify.UnorderedOutput(
['Unversioned properties on revision 2:\n',
' svn:author\n',' svn:date\n', ' svn:log\n',
' bug\n'])
svntest.actions.run_and_verify_svn(None, expected, [], 'proplist',
'--revprop', '-r', 2, sbox.repo_url)
svntest.actions.run_and_verify_svn(None, '42', [], 'propget', 'bug',
'--revprop', '-r', 2, sbox.repo_url)
@SkipUnless(server_has_revprop_commit)
def delete_with_revprop(sbox):
"set revision props during remote delete"
sbox.build()
remote_dir = sbox.repo_url + "/dir"
svntest.actions.run_and_verify_svn(None, None, [], 'mkdir', '-m', 'msg',
remote_dir)
svntest.actions.run_and_verify_svn(None, None, [], 'delete', '-m', 'msg',
'--with-revprop', 'bug=52', remote_dir)
expected = svntest.verify.UnorderedOutput(
['Unversioned properties on revision 3:\n',
' svn:author\n',' svn:date\n', ' svn:log\n',
' bug\n'])
svntest.actions.run_and_verify_svn(None, expected, [], 'proplist',
'--revprop', '-r', 3, sbox.repo_url)
svntest.actions.run_and_verify_svn(None, '52', [], 'propget', 'bug',
'--revprop', '-r', 3, sbox.repo_url)
@SkipUnless(server_has_revprop_commit)
def commit_with_revprop(sbox):
"set revision props during commit"
sbox.build()
wc_dir = sbox.wc_dir
expected_status = make_standard_slew_of_changes(wc_dir)
omega_path = os.path.join(wc_dir, 'A', 'D', 'H', 'omega')
gloo_path = os.path.join(wc_dir, 'A', 'D', 'H', 'gloo')
expected_output = svntest.wc.State(wc_dir, {
'A/D/H/omega' : Item(verb='Sending'),
'A/D/H/gloo' : Item(verb='Adding'),
})
expected_status.tweak('A/D/H/omega', wc_rev=2, status=' ')
expected_status.tweak('A/D/H/gloo', wc_rev=2, status=' ')
svntest.actions.run_and_verify_commit(wc_dir,
expected_output,
expected_status,
None,
'-m', 'msg',
'--with-revprop', 'bug=62',
omega_path, gloo_path)
expected = svntest.verify.UnorderedOutput(
['Unversioned properties on revision 2:\n',
' svn:author\n',' svn:date\n', ' svn:log\n',
' bug\n'])
svntest.actions.run_and_verify_svn(None, expected, [], 'proplist',
'--revprop', '-r', 2, sbox.repo_url)
svntest.actions.run_and_verify_svn(None, '62', [], 'propget', 'bug',
'--revprop', '-r', 2, sbox.repo_url)
@SkipUnless(server_has_revprop_commit)
def import_with_revprop(sbox):
"set revision props during import"
sbox.build()
local_dir = os.path.join(sbox.wc_dir, 'folder')
local_file = os.path.join(sbox.wc_dir, 'folder', 'file')
os.mkdir(local_dir)
svntest.main.file_write(local_file, "xxxx")
svntest.actions.run_and_verify_svn(None, None, [], 'import', '-m', 'msg',
'--with-revprop', 'bug=72', local_dir,
sbox.repo_url)
expected = svntest.verify.UnorderedOutput(
['Unversioned properties on revision 2:\n',
' svn:author\n',' svn:date\n', ' svn:log\n',
' bug\n'])
svntest.actions.run_and_verify_svn(None, expected, [], 'proplist',
'--revprop', '-r', 2, sbox.repo_url)
svntest.actions.run_and_verify_svn(None, '72', [], 'propget', 'bug',
'--revprop', '-r', 2, sbox.repo_url)
@SkipUnless(server_has_revprop_commit)
def copy_R2R_with_revprop(sbox):
"set revision props during repos-to-repos copy"
sbox.build()
remote_dir1 = sbox.repo_url + "/dir1"
remote_dir2 = sbox.repo_url + "/dir2"
svntest.actions.run_and_verify_svn(None, None, [], 'mkdir', '-m', 'msg',
remote_dir1)
svntest.actions.run_and_verify_svn(None, None, [], 'copy', '-m', 'msg',
'--with-revprop', 'bug=82', remote_dir1,
remote_dir2)
expected = svntest.verify.UnorderedOutput(
['Unversioned properties on revision 3:\n',
' svn:author\n',' svn:date\n', ' svn:log\n',
' bug\n'])
svntest.actions.run_and_verify_svn(None, expected, [], 'proplist',
'--revprop', '-r', 3, sbox.repo_url)
svntest.actions.run_and_verify_svn(None, '82', [], 'propget', 'bug',
'--revprop', '-r', 3, sbox.repo_url)
@SkipUnless(server_has_revprop_commit)
def copy_WC2R_with_revprop(sbox):
"set revision props during wc-to-repos copy"
sbox.build()
remote_dir = sbox.repo_url + "/dir"
local_dir = os.path.join(sbox.wc_dir, 'folder')
svntest.actions.run_and_verify_svn(None, None, [],
'mkdir', local_dir)
svntest.actions.run_and_verify_svn(None, None, [], 'copy', '-m', 'msg',
'--with-revprop', 'bug=92', local_dir,
remote_dir)
expected = svntest.verify.UnorderedOutput(
['Unversioned properties on revision 2:\n',
' svn:author\n',' svn:date\n', ' svn:log\n',
' bug\n'])
svntest.actions.run_and_verify_svn(None, expected, [], 'proplist',
'--revprop', '-r', 2, sbox.repo_url)
svntest.actions.run_and_verify_svn(None, '92', [], 'propget', 'bug',
'--revprop', '-r', 2, sbox.repo_url)
@SkipUnless(server_has_revprop_commit)
def move_R2R_with_revprop(sbox):
"set revision props during repos-to-repos move"
sbox.build()
remote_dir1 = sbox.repo_url + "/dir1"
remote_dir2 = sbox.repo_url + "/dir2"
svntest.actions.run_and_verify_svn(None, None, [], 'mkdir', '-m', 'msg',
remote_dir1)
svntest.actions.run_and_verify_svn(None, None, [], 'move', '-m', 'msg',
'--with-revprop', 'bug=102', remote_dir1,
remote_dir2)
expected = svntest.verify.UnorderedOutput(
['Unversioned properties on revision 3:\n',
' svn:author\n',' svn:date\n', ' svn:log\n',
' bug\n'])
svntest.actions.run_and_verify_svn(None, expected, [], 'proplist',
'--revprop', '-r', 3, sbox.repo_url)
svntest.actions.run_and_verify_svn(None, '102', [], 'propget', 'bug',
'--revprop', '-r', 3, sbox.repo_url)
@SkipUnless(server_has_revprop_commit)
def propedit_with_revprop(sbox):
"set revision props during remote property edit"
sbox.build()
svntest.main.use_editor('append_foo')
svntest.actions.run_and_verify_svn(None, None, [], 'propedit', '-m', 'msg',
'--with-revprop', 'bug=112', 'prop',
sbox.repo_url)
expected = svntest.verify.UnorderedOutput(
['Unversioned properties on revision 2:\n',
' svn:author\n',' svn:date\n', ' svn:log\n',
' bug\n'])
svntest.actions.run_and_verify_svn(None, expected, [], 'proplist',
'--revprop', '-r', 2, sbox.repo_url)
svntest.actions.run_and_verify_svn(None, '112', [], 'propget', 'bug',
'--revprop', '-r', 2, sbox.repo_url)
@SkipUnless(server_has_revprop_commit)
def set_multiple_props_with_revprop(sbox):
"set multiple revision props during remote mkdir"
sbox.build()
remote_dir = sbox.repo_url + "/dir"
svntest.actions.run_and_verify_svn(None, None, [], 'mkdir', '-m', 'msg',
'--with-revprop', 'bug=32',
'--with-revprop', 'ref=22', remote_dir)
expected = svntest.verify.UnorderedOutput(
['Unversioned properties on revision 2:\n',
' svn:author\n',' svn:date\n', ' svn:log\n',
' bug\n', ' ref\n'])
svntest.actions.run_and_verify_svn(None, expected, [], 'proplist',
'--revprop', '-r', 2, sbox.repo_url)
svntest.actions.run_and_verify_svn(None, '32', [], 'propget', 'bug',
'--revprop', '-r', 2, sbox.repo_url)
svntest.actions.run_and_verify_svn(None, '22', [], 'propget', 'ref',
'--revprop', '-r', 2, sbox.repo_url)
@SkipUnless(server_has_revprop_commit)
def use_empty_value_in_revprop_pair(sbox):
"set revprop without value ('') during remote mkdir"
sbox.build()
remote_dir = sbox.repo_url + "/dir"
svntest.actions.run_and_verify_svn(None, None, [], 'mkdir', '-m', 'msg',
'--with-revprop', 'bug=',
'--with-revprop', 'ref=', remote_dir)
expected = svntest.verify.UnorderedOutput(
['Unversioned properties on revision 2:\n',
' svn:author\n',' svn:date\n', ' svn:log\n',
' bug\n', ' ref\n'])
svntest.actions.run_and_verify_svn(None, expected, [], 'proplist',
'--revprop', '-r', 2, sbox.repo_url)
svntest.actions.run_and_verify_svn(None, '', [], 'propget', 'bug',
'--revprop', '-r', 2, sbox.repo_url)
svntest.actions.run_and_verify_svn(None, '', [], 'propget', 'ref',
'--revprop', '-r', 2, sbox.repo_url)
@SkipUnless(server_has_revprop_commit)
def no_equals_in_revprop_pair(sbox):
"set revprop without '=' during remote mkdir"
sbox.build()
remote_dir = sbox.repo_url + "/dir"
svntest.actions.run_and_verify_svn(None, None, [], 'mkdir', '-m', 'msg',
'--with-revprop', 'bug',
'--with-revprop', 'ref', remote_dir)
expected = svntest.verify.UnorderedOutput(
['Unversioned properties on revision 2:\n',
' svn:author\n',' svn:date\n', ' svn:log\n',
' bug\n', ' ref\n'])
svntest.actions.run_and_verify_svn(None, expected, [], 'proplist',
'--revprop', '-r', 2, sbox.repo_url)
svntest.actions.run_and_verify_svn(None, '', [], 'propget', 'bug',
'--revprop', '-r', 2, sbox.repo_url)
svntest.actions.run_and_verify_svn(None, '', [], 'propget', 'ref',
'--revprop', '-r', 2, sbox.repo_url)
@SkipUnless(server_has_revprop_commit)
def set_invalid_revprops(sbox):
"set invalid revision props during remote mkdir"
sbox.build()
remote_dir = sbox.repo_url + "/dir"
expected = '.*Standard properties can\'t.*'
svntest.actions.run_and_verify_svn(None, [], expected, 'mkdir', '-m', 'msg',
'--with-revprop', 'svn:author=42', remote_dir)
svntest.actions.run_and_verify_svn(None, [], expected, 'mkdir', '-m', 'msg',
'--with-revprop', 'svn:log=42', remote_dir)
svntest.actions.run_and_verify_svn(None, [], expected, 'mkdir', '-m', 'msg',
'--with-revprop', 'svn:date=42', remote_dir)
svntest.actions.run_and_verify_svn(None, [], expected, 'mkdir', '-m', 'msg',
'--with-revprop', 'svn:foo=bar', remote_dir)
svntest.actions.run_and_verify_svn(None, [],
'svn: E205000: '
'Revision property pair is empty',
'mkdir', '-m', 'msg',
'--with-revprop', '',
remote_dir)
@Issue(3553)
def start_commit_hook_test(sbox):
"start-commit hook failure case testing"
sbox.build()
wc_dir = sbox.wc_dir
repo_dir = sbox.repo_dir
error_msg = "Text with <angle brackets> & ampersand"
svntest.actions.create_failing_hook(repo_dir, "start-commit", error_msg)
iota_path = os.path.join(wc_dir, "iota")
svntest.main.file_append(iota_path, "More stuff in iota")
exit_code, actual_stdout, actual_stderr = svntest.main.run_svn(
1, 'ci', '--quiet', '-m', 'log msg', wc_dir)
svntest.verify.compare_and_display_lines('Start-commit hook test',
'STDOUT', [], actual_stdout)
if len(actual_stderr) > 2:
actual_stderr = actual_stderr[-2:]
expected_stderr = [ "svn: E165001: " +
svntest.actions.hook_failure_message('start-commit'),
error_msg + "\n",
]
svntest.verify.compare_and_display_lines('Start-commit hook test',
'STDERR',
expected_stderr, actual_stderr)
@Issue(3553)
def pre_commit_hook_test(sbox):
"pre-commit hook failure case testing"
sbox.build()
wc_dir = sbox.wc_dir
repo_dir = sbox.repo_dir
error_msg = "Text with <angle brackets> & ampersand"
svntest.actions.create_failing_hook(repo_dir, "pre-commit", error_msg)
iota_path = os.path.join(wc_dir, "iota")
svntest.main.file_append(iota_path, "More stuff in iota")
exit_code, actual_stdout, actual_stderr = svntest.main.run_svn(
1, 'ci', '--quiet', '-m', 'log msg', wc_dir)
svntest.verify.compare_and_display_lines('Pre-commit hook test',
'STDOUT', [], actual_stdout)
if len(actual_stderr) > 2:
actual_stderr = actual_stderr[-2:]
expected_stderr = [ "svn: E165001: " +
svntest.actions.hook_failure_message('pre-commit'),
error_msg + "\n",
]
svntest.verify.compare_and_display_lines('Pre-commit hook test',
'STDERR',
expected_stderr, actual_stderr)
def versioned_log_message(sbox):
"'svn commit -F foo' when foo is a versioned file"
sbox.build()
os.chdir(sbox.wc_dir)
iota_path = os.path.join('iota')
mu_path = os.path.join('A', 'mu')
log_path = os.path.join('A', 'D', 'H', 'omega')
svntest.main.file_append(iota_path, "2")
svntest.actions.run_and_verify_svn(None, None, svntest.verify.AnyOutput,
'ci', '-F', log_path)
svntest.actions.run_and_verify_svn(None, None, [],
'ci', '-F', log_path, '--force-log')
svntest.main.file_append(mu_path, "2")
svntest.actions.run_and_verify_svn(None, None, svntest.verify.AnyOutput,
'ci', '-F', log_path, mu_path)
svntest.actions.run_and_verify_svn(None, None, [],
'ci',
'-F', log_path,
'--force-log', mu_path)
def changelist_near_conflict(sbox):
"'svn commit --changelist=foo' above a conflict"
sbox.build()
wc_dir = sbox.wc_dir
iota_path = os.path.join(wc_dir, "iota")
mu_path = os.path.join(wc_dir, "A", "mu")
gloo_path = os.path.join(wc_dir, "A", "D", "H", "gloo")
expected_status = make_standard_slew_of_changes(wc_dir)
changelist_name = "logical-changeset"
svntest.actions.run_and_verify_svn(None, None, [],
"changelist", changelist_name,
mu_path, gloo_path)
inject_conflict_into_wc(sbox, 'iota', iota_path,
None, expected_status, 2)
expected_output = svntest.wc.State(wc_dir, {
"A/D/H/gloo" : Item(verb='Adding'),
})
expected_status.tweak("A/D/H/gloo", wc_rev=3, status=" ")
svntest.actions.run_and_verify_commit(wc_dir,
expected_output,
expected_status,
None,
"--changelist=" + changelist_name,
"-m", "msg", wc_dir)
def commit_out_of_date_file(sbox):
"try to commit a file that is out-of-date"
sbox.build()
wc_dir = sbox.wc_dir
wc_backup = sbox.add_wc_path('backup')
svntest.actions.duplicate_dir(wc_dir, wc_backup)
pi_path = os.path.join(wc_dir, 'A', 'D', 'G', 'pi')
backup_pi_path = os.path.join(wc_backup, 'A', 'D', 'G', 'pi')
svntest.main.file_append(pi_path, "new line\n")
expected_output = svntest.wc.State(wc_dir, {
"A/D/G/pi" : Item(verb='Sending'),
})
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
expected_status.tweak("A/D/G/pi", wc_rev=2, status=" ")
svntest.actions.run_and_verify_commit(wc_dir,
expected_output,
expected_status,
None,
"-m", "log message", wc_dir)
svntest.main.file_append(backup_pi_path, "hello")
expected_err = ".*(pi.*out of date|Out of date.*pi).*"
svntest.actions.run_and_verify_svn(None, None, expected_err,
'commit', '-m', 'log message',
wc_backup)
@SkipUnless(server_gets_client_capabilities)
@Issue(2991)
def start_commit_detect_capabilities(sbox):
"start-commit hook sees client capabilities" sbox.build()
wc_dir = sbox.wc_dir
repos_dir = sbox.repo_dir
hook_text = "import sys\n" + \
"fp = open(sys.argv[1] + '/hooks.log', 'w')\n" + \
"caps = sys.argv[3].split(':')\n" + \
"if 'mergeinfo' in caps:\n" + \
" fp.write('yes')\n" + \
"else:\n" + \
" fp.write('no')\n" + \
"fp.close()\n"
start_commit_hook = svntest.main.get_start_commit_hook_path(repos_dir)
svntest.main.create_python_hook_script(start_commit_hook, hook_text)
iota_path = os.path.join(wc_dir, "iota")
svntest.main.file_append(iota_path, "More stuff in iota")
svntest.actions.run_and_verify_svn(None, [], [], 'ci', '--quiet',
'-m', 'log msg', wc_dir)
log_path = os.path.join(repos_dir, "hooks.log")
if os.path.exists(log_path):
data = open(log_path).read()
os.unlink(log_path)
else:
raise svntest.verify.SVNUnexpectedOutput("'%s' not found") % log_path
if data != 'yes':
raise svntest.Failure
@Issue(3198)
def commit_added_missing(sbox):
"commit a missing to-be-added file should fail"
sbox.build()
wc_dir = sbox.wc_dir
mu_path = os.path.join(wc_dir, 'A', 'mu')
a_path = os.path.join(wc_dir, 'A', 'a.txt')
b_path = os.path.join(wc_dir, 'A', 'b.txt')
svntest.main.run_svn(None, 'cp', mu_path, a_path)
svntest.main.run_svn(None, 'cp', mu_path, b_path)
os.remove(b_path)
svntest.actions.run_and_verify_svn("Commit should have failed",
[], ".* is scheduled for addition, but is missing",
'commit', '-m', 'logmsg', wc_dir)
def commit_fails_at_path(path, wc_dir, error_re):
svntest.actions.run_and_verify_commit(wc_dir,
None,
None,
error_re,
path)
def tree_conflicts_block_commit(sbox):
"tree conflicts block commit"
svntest.actions.build_greek_tree_conflicts(sbox)
wc_dir = sbox.wc_dir
A = os.path.join(wc_dir, 'A')
D = os.path.join(wc_dir, 'A', 'D')
G = os.path.join(wc_dir, 'A', 'D', 'G')
error_re = "remains in conflict"
commit_fails_at_path(wc_dir, wc_dir, error_re)
commit_fails_at_path(A, A, error_re)
commit_fails_at_path(D, D, error_re)
commit_fails_at_path(G, G, error_re)
commit_fails_at_path(os.path.join(G, 'pi'), G, error_re)
def tree_conflicts_resolved(sbox):
"tree conflicts resolved"
svntest.actions.build_greek_tree_conflicts(sbox)
wc_dir = sbox.wc_dir
wc_dir_2 = sbox.add_wc_path('2')
svntest.actions.duplicate_dir(wc_dir, wc_dir_2)
G = os.path.join(wc_dir, 'A', 'D', 'G')
victims = [ os.path.join(G, v) for v in ['pi', 'rho', 'tau'] ]
svntest.actions.run_and_verify_resolved(victims)
expected_status = svntest.actions.get_virginal_state(wc_dir, 2)
expected_status.tweak('A/D/G/pi', status='D ')
expected_status.tweak('A/D/G/rho', status='A ', copied='+', wc_rev='-')
expected_status.remove('A/D/G/tau')
svntest.actions.run_and_verify_status(wc_dir, expected_status)
G2 = os.path.join(wc_dir_2, 'A', 'D', 'G')
victims = [ os.path.join(G2, v) for v in ['pi', 'rho', 'tau'] ]
svntest.actions.run_and_verify_resolved(victims, G2, '-R')
expected_status.wc_dir = wc_dir_2
svntest.actions.run_and_verify_status(wc_dir_2, expected_status)
def commit_multiple_nested_deletes(sbox):
"committing multiple nested deletes"
sbox.build()
wc_dir = sbox.wc_dir
A = os.path.join(wc_dir, 'A')
A_B = os.path.join(A, 'B')
sbox.simple_rm('A')
svntest.main.run_svn(None, 'ci', A, A_B, '-m', 'Q')
@Issue(4042)
def commit_incomplete(sbox):
"commit an incomplete dir"
sbox.build()
wc_dir = sbox.wc_dir
sbox.simple_propset('pname', 'pval', 'A/B')
svntest.actions.set_incomplete(sbox.ospath('A/B'), 1)
expected_output = svntest.wc.State(wc_dir, {
'A/B' : Item(verb='Sending'),
})
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
expected_status.tweak('A/B', status='! ', wc_rev=2)
svntest.actions.run_and_verify_commit(wc_dir,
expected_output,
expected_status,
None,
wc_dir)
def commit_add_subadd(sbox):
"committing add with explicit subadd targets"
sbox.build()
wc_dir = sbox.wc_dir
targets_file = sbox.ospath('targets') targets_file = os.path.abspath(targets_file)
targets = "A/D A/D/H A/D/H/chi A/D/H/omega A/D/H/psi".split()
open(targets_file, 'w').write("\n".join(targets))
sbox.simple_rm('A/D')
sbox.simple_commit(message='rm')
os.chdir(wc_dir)
svntest.main.run_svn(None, 'up')
svntest.main.run_svn(None, 'merge', '-c', '-2', './')
svntest.main.run_svn(None, 'commit', '--targets', targets_file, '-mm')
@Issue(4480)
def commit_mergeinfo_ood(sbox):
"commit of mergeinfo that should cause out of date"
sbox.build()
sbox.simple_rm('A', 'iota')
sbox.simple_commit()
sbox.simple_mkdir('trunk', 'branch')
sbox.simple_commit()
sbox.simple_append('trunk/a', 'This is a\n')
sbox.simple_add('trunk/a')
sbox.simple_commit()
sbox.simple_append('trunk/b', 'This is b\n')
sbox.simple_add('trunk/b')
sbox.simple_commit()
sbox.simple_update()
expected_output = [
'--- Merging r4 into \'%s\':\n' % sbox.ospath('branch'),
'A %s\n' % sbox.ospath('branch/a'),
'--- Recording mergeinfo for merge of r4' \
' into \'%s\':\n' % sbox.ospath('branch'),
' U %s\n' % sbox.ospath('branch'),
]
svntest.actions.run_and_verify_svn(None, expected_output, [],
'merge', '-c4', '^/trunk',
sbox.ospath('branch'))
sbox.simple_commit()
svntest.actions.run_and_verify_svn(None, None, [],
'update', '-r5', sbox.wc_dir)
expected_output = [
'--- Merging r5 into \'%s\':\n' % sbox.ospath('branch'),
'A %s\n' % sbox.ospath('branch/b'),
'--- Recording mergeinfo for merge of r5 into \'%s\':\n' % sbox.ospath('branch'),
' U %s\n' % sbox.ospath('branch'),
]
svntest.actions.run_and_verify_svn(None, expected_output, [],
'merge', '-c5', '^/trunk',
sbox.ospath('branch'))
expected_err = '.*out of date.*'
svntest.actions.run_and_verify_svn(None, None, expected_err,
'commit', sbox.ospath(''), '-m', 'M')
test_list = [ None,
commit_one_file,
commit_one_new_file,
commit_one_new_binary_file,
commit_multiple_targets,
commit_multiple_targets_2,
commit_inclusive_dir,
commit_top_dir,
commit_unversioned_thing,
nested_dir_replacements,
hudson_part_1,
hudson_part_1_variation_1,
hudson_part_1_variation_2,
hudson_part_2,
hudson_part_2_1,
hook_test,
merge_mixed_revisions,
commit_uri_unsafe,
commit_deleted_edited,
commit_in_dir_scheduled_for_addition,
commit_rmd_and_deleted_file,
commit_add_file_twice,
commit_from_long_dir,
commit_with_lock,
commit_current_dir,
commit_multiple_wc_nested,
commit_multiple_wc,
commit_multiple_wc_multiple_repos,
commit_nonrecursive,
failed_commit,
commit_out_of_date_deletions,
commit_with_bad_log_message,
commit_with_mixed_line_endings,
commit_with_mixed_line_endings_in_ignored_part,
from_wc_top_with_bad_editor,
mods_in_schedule_delete,
tab_test,
local_mods_are_not_commits,
post_commit_hook_test,
commit_same_folder_in_targets,
commit_inconsistent_eol,
mkdir_with_revprop,
delete_with_revprop,
commit_with_revprop,
import_with_revprop,
copy_R2R_with_revprop,
copy_WC2R_with_revprop,
move_R2R_with_revprop,
propedit_with_revprop,
set_multiple_props_with_revprop,
use_empty_value_in_revprop_pair,
no_equals_in_revprop_pair,
set_invalid_revprops,
start_commit_hook_test,
pre_commit_hook_test,
versioned_log_message,
changelist_near_conflict,
commit_out_of_date_file,
start_commit_detect_capabilities,
commit_added_missing,
tree_conflicts_block_commit,
tree_conflicts_resolved,
commit_multiple_nested_deletes,
commit_incomplete,
commit_add_subadd,
commit_mergeinfo_ood,
]
if __name__ == '__main__':
svntest.main.run_tests(test_list)