Alien-SVN
view release on metacpan or search on metacpan
src/subversion/subversion/tests/cmdline/basic_tests.py view on Meta::CPAN
Y_Z_path = sbox.ospath('Y/Z')
svntest.actions.run_and_verify_svn("erroneous mkdir dir/subdir", [],
".*Try 'svn mkdir --parents' instead.*",
'mkdir', Y_Z_path)
svntest.actions.run_and_verify_svn("mkdir dir/subdir", None, [],
'mkdir', '--parents', Y_Z_path)
# Verify the WC status, because there was a regression in which parts of
# the WC were left locked.
expected_status = svntest.actions.get_virginal_state(sbox.wc_dir, 1)
expected_status.add({
'Y' : Item(status='A ', wc_rev=0),
'Y/Z' : Item(status='A ', wc_rev=0),
})
svntest.actions.run_and_verify_status(wc_dir, expected_status)
#----------------------------------------------------------------------
def basic_commit_corruption(sbox):
"basic corruption detection on commit"
## I always wanted a test named "basic_corruption". :-)
## Here's how it works:
##
## 1. Make a working copy at rev 1, duplicate it. Now we have
## two working copies at rev 1. Call them first and second.
## 2. Make a local mod to `first/A/mu'.
## 3. Intentionally corrupt `first/A/.svn/text-base/mu.svn-base'.
## 4. Try to commit, expect a failure.
## 5. Repair the text-base, commit again, expect success.
##
## Here we go...
sbox.build()
wc_dir = sbox.wc_dir
# Make a local mod to mu
mu_path = sbox.ospath('A/mu')
svntest.main.file_append(mu_path, 'appended mu text')
# Created expected output tree for 'svn ci'
expected_output = wc.State(wc_dir, {
'A/mu' : Item(verb='Sending'),
})
# Create expected status tree; all local revisions should be at 1,
# but mu should be at revision 2.
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
expected_status.tweak('A/mu', wc_rev=2)
# Modify mu's text-base, so we get a checksum failure the first time
# we try to commit.
mu_tb_path = svntest.wc.text_base_path(mu_path)
tb_dir_path = os.path.dirname(mu_tb_path)
mu_saved_tb_path = mu_tb_path + "-saved"
tb_dir_saved_mode = os.stat(tb_dir_path)[stat.ST_MODE]
mu_tb_saved_mode = os.stat(mu_tb_path)[stat.ST_MODE]
os.chmod(tb_dir_path, 0777) ### What's a more portable way to do this?
os.chmod(mu_tb_path, 0666) ### Would rather not use hardcoded numbers.
shutil.copyfile(mu_tb_path, mu_saved_tb_path)
svntest.main.file_append(mu_tb_path, 'Aaagggkkk, corruption!')
os.chmod(tb_dir_path, tb_dir_saved_mode)
os.chmod(mu_tb_path, mu_tb_saved_mode)
# This commit should fail due to text base corruption.
svntest.actions.run_and_verify_commit(wc_dir, expected_output,
None, # expected_status,
"svn: E200014: Checksum",
wc_dir)
# Restore the uncorrupted text base.
os.chmod(tb_dir_path, 0777)
os.chmod(mu_tb_path, 0666)
os.remove(mu_tb_path)
os.rename(mu_saved_tb_path, mu_tb_path)
os.chmod(tb_dir_path, tb_dir_saved_mode)
os.chmod(mu_tb_path, mu_tb_saved_mode)
# This commit should succeed.
svntest.actions.run_and_verify_commit(wc_dir, expected_output,
expected_status, None, wc_dir)
#----------------------------------------------------------------------
def basic_update_corruption(sbox):
"basic corruption detection on update"
## I always wanted a test named "basic_corruption". :-)
## Here's how it works:
##
## 1. Make a working copy at rev 1, duplicate it. Now we have
## two working copies at rev 1. Call them first and second.
## 2. Make a local mod to `first/A/mu'.
## 3. Repair the text-base, commit again, expect success.
## 4. Intentionally corrupt `second/A/.svn/text-base/mu.svn-base'.
## 5. Try to update `second', expect failure.
## 6. Repair the text-base, update again, expect success.
##
## Here we go...
sbox.build()
wc_dir = sbox.wc_dir
# Make the "other" working copy
other_wc = sbox.add_wc_path('other')
svntest.actions.run_and_verify_svn("Checkout to wc2", None, [],
'co', sbox.repo_url, other_wc)
# Make a local mod to mu
mu_path = sbox.ospath('A/mu')
svntest.main.file_append(mu_path, 'appended mu text')
# Created expected output tree for 'svn ci'
expected_output = wc.State(wc_dir, {
'A/mu' : Item(verb='Sending'),
})
# Create expected status tree; all local revisions should be at 1,
# but mu should be at revision 2.
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
expected_status.tweak('A/mu', wc_rev=2)
# This commit should succeed.
svntest.actions.run_and_verify_commit(wc_dir, expected_output,
expected_status, None, wc_dir)
# Create expected output tree for an update of the other_wc.
expected_output = wc.State(other_wc, {
'A/mu' : Item(status='U '),
})
# Create expected disk tree for the update.
expected_disk = svntest.main.greek_state.copy()
# Create expected status tree for the update.
expected_status = svntest.actions.get_virginal_state(other_wc, 2)
# Modify mu's text-base, so we get a checksum failure the first time
# we try to update.
other_mu_path = os.path.join(other_wc, 'A', 'mu')
mu_tb_path = svntest.wc.text_base_path(other_mu_path)
tb_dir_path = os.path.dirname(mu_tb_path)
mu_saved_tb_path = mu_tb_path + "-saved"
tb_dir_saved_mode = os.stat(tb_dir_path)[stat.ST_MODE]
mu_tb_saved_mode = os.stat(mu_tb_path)[stat.ST_MODE]
os.chmod(tb_dir_path, 0777)
os.chmod(mu_tb_path, 0666)
shutil.copyfile(mu_tb_path, mu_saved_tb_path)
svntest.main.file_append(mu_tb_path, 'Aiyeeeee, corruption!\nHelp!\n')
os.chmod(tb_dir_path, tb_dir_saved_mode)
os.chmod(mu_tb_path, mu_tb_saved_mode)
# Do the update and check the results in four ways.
fail_output = wc.State(other_wc, {
})
fail_status = svntest.actions.get_virginal_state(other_wc, 1)
fail_status.tweak('A', '', status='! ', wc_rev=2)
svntest.actions.run_and_verify_update(other_wc,
fail_output,
expected_disk,
fail_status,
"svn: E155017: Checksum", other_wc)
# Restore the uncorrupted text base.
os.chmod(tb_dir_path, 0777)
os.chmod(mu_tb_path, 0666)
os.remove(mu_tb_path)
os.rename(mu_saved_tb_path, mu_tb_path)
os.chmod(tb_dir_path, tb_dir_saved_mode)
os.chmod(mu_tb_path, mu_tb_saved_mode)
# Create expected status tree for the update.
expected_status = svntest.actions.get_virginal_state(other_wc, 2)
# This update should succeed. (Actually, I'm kind of astonished
# that this works without even an intervening "svn cleanup".)
expected_disk.tweak('A/mu',
contents=expected_disk.desc['A/mu'].contents
+ 'appended mu text')
svntest.actions.run_and_verify_update(other_wc,
expected_output,
expected_disk,
expected_status)
#----------------------------------------------------------------------
def basic_merging_update(sbox):
"receiving text merges as part of an update"
sbox.build()
wc_dir = sbox.wc_dir
# First change the greek tree to make two files 10 lines long
mu_path = sbox.ospath('A/mu')
rho_path = sbox.ospath('A/D/G/rho')
mu_text = ""
rho_text = ""
for x in range(2,11):
mu_text = mu_text + '\nThis is line ' + repr(x) + ' in mu'
rho_text = rho_text + '\nThis is line ' + repr(x) + ' in rho'
svntest.main.file_append(mu_path, mu_text)
svntest.main.file_append(rho_path, rho_text)
# Create expected output tree for initial commit
expected_output = wc.State(wc_dir, {
'A/mu' : Item(verb='Sending'),
'A/D/G/rho' : Item(verb='Sending'),
})
# Create expected status tree; all local revisions should be at 1,
# but mu and rho should be at revision 2.
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
expected_status.tweak('A/mu', 'A/D/G/rho', wc_rev=2)
# Initial commit.
svntest.actions.run_and_verify_commit(wc_dir,
expected_output,
expected_status,
None,
wc_dir)
# Make a backup copy of the working copy
wc_backup = sbox.add_wc_path('backup')
svntest.actions.duplicate_dir(wc_dir, wc_backup)
# Make a couple of local mods to files
svntest.main.file_append(mu_path, ' Appended to line 10 of mu')
svntest.main.file_append(rho_path, ' Appended to line 10 of rho')
# Created expected output tree for 'svn ci'
( run in 0.425 second using v1.01-cache-2.11-cpan-9288abcf80b )