Alien-SVN
view release on metacpan or search on metacpan
src/subversion/subversion/tests/cmdline/update_tests.py view on Meta::CPAN
# Now start working in the backup working copy:
# Make a local mod to theta
svntest.main.file_append(theta_backup_path, "extra theta text")
theta_contents_local = theta_contents + "extra theta text"
# Create expected output tree for an update of wc_backup.
expected_output = svntest.wc.State(wc_backup, {
'A/theta' : Item(status='C '),
})
# Create expected disk tree for the update --
# look! binary contents, and a binary property!
expected_disk = svntest.main.greek_state.copy()
expected_disk.add({
'A/theta' : Item(theta_contents_local,
props={'svn:mime-type' : 'application/octet-stream'}),
})
# Create expected status tree for the update.
expected_status = svntest.actions.get_virginal_state(wc_backup, 3)
expected_status.add({
'A/theta' : Item(status='C ', wc_rev=3),
})
# Extra 'singleton' files we expect to exist after the update.
# In the case, the locally-modified binary file should be backed up
# to an .orig file.
# This is a list of lists, of the form [ WC_DIR,
# [pattern, contents], ...]
extra_files = [[wc_backup, 'theta.*\.r2', theta_contents],
[wc_backup, 'theta.*\.r3', theta_contents_r3]]
# Do the update and check the results in three ways. Pass our
# custom singleton handler to verify the .orig file; this handler
# will verify the existence (and contents) of both binary files
# after the update finishes.
svntest.actions.run_and_verify_update(wc_backup,
expected_output,
expected_disk,
expected_status,
None,
detect_extra_files, extra_files,
None, None, 1)
# verify that the extra_files list is now empty.
if len(extra_files) != 0:
logger.warn("Not all extra reject files have been accounted for:")
logger.warn(extra_files)
raise svntest.Failure
#----------------------------------------------------------------------
def update_binary_file_2(sbox):
"update to an old revision of a binary files"
sbox.build()
wc_dir = sbox.wc_dir
# Suck up contents of a test .png file.
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
# no reason other than we have had problems in the past with getting
# svndiff data out of the repository for files > 102400 bytes).
# How? Well, we'll just keep doubling the binary contents of the
# original theta.png until we're big enough.
zeta_contents = theta_contents
while(len(zeta_contents) < 102401):
zeta_contents = zeta_contents + zeta_contents
# Write our two files' contents out to disk, in A/theta and A/zeta.
theta_path = sbox.ospath('A/theta')
svntest.main.file_write(theta_path, theta_contents, 'wb')
zeta_path = sbox.ospath('A/zeta')
svntest.main.file_write(zeta_path, zeta_contents, 'wb')
# Now, `svn add' those two files.
svntest.main.run_svn(None, 'add', theta_path, zeta_path)
# Created expected output tree for 'svn ci'
expected_output = svntest.wc.State(wc_dir, {
'A/theta' : Item(verb='Adding (bin)'),
'A/zeta' : Item(verb='Adding (bin)'),
})
# Create expected status tree
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
expected_status.add({
'A/theta' : Item(status=' ', wc_rev=2),
'A/zeta' : Item(status=' ', wc_rev=2),
})
# Commit the new binary filea, creating revision 2.
svntest.actions.run_and_verify_commit(wc_dir, expected_output,
expected_status, None, wc_dir)
# Make some mods to the binary files.
svntest.main.file_append(theta_path, "foobar")
new_theta_contents = theta_contents + "foobar"
svntest.main.file_append(zeta_path, "foobar")
new_zeta_contents = zeta_contents + "foobar"
# Created expected output tree for 'svn ci'
expected_output = svntest.wc.State(wc_dir, {
'A/theta' : Item(verb='Sending'),
'A/zeta' : Item(verb='Sending'),
})
# Create expected status tree
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
expected_status.add({
'A/theta' : Item(status=' ', wc_rev=3),
'A/zeta' : Item(status=' ', wc_rev=3),
})
# Commit original working copy again, creating revision 3.
svntest.actions.run_and_verify_commit(wc_dir, expected_output,
expected_status, None, wc_dir)
# Create expected output tree for an update to rev 2.
expected_output = svntest.wc.State(wc_dir, {
'A/theta' : Item(status='U '),
'A/zeta' : Item(status='U '),
})
# Create expected disk tree for the update --
# look! binary contents, and a binary property!
expected_disk = svntest.main.greek_state.copy()
expected_disk.add({
'A/theta' : Item(theta_contents,
props={'svn:mime-type' : 'application/octet-stream'}),
'A/zeta' : Item(zeta_contents,
props={'svn:mime-type' : 'application/octet-stream'}),
})
# Create expected status tree for the update.
expected_status = svntest.actions.get_virginal_state(wc_dir, 2)
expected_status.add({
'A/theta' : Item(status=' ', wc_rev=2),
'A/zeta' : Item(status=' ', wc_rev=2),
})
# Do an update from revision 2 and make sure that our binary file
# gets reverted to its original contents.
svntest.actions.run_and_verify_update(wc_dir,
expected_output,
expected_disk,
expected_status,
None, None, None,
None, None, 1,
'-r', '2', wc_dir)
#----------------------------------------------------------------------
@Issue(4128)
def update_binary_file_3(sbox):
"update locally modified file to equal versions"
sbox.build()
wc_dir = sbox.wc_dir
# Suck up contents of a test .png file.
theta_contents = open(os.path.join(sys.path[0], "theta.bin"), 'rb').read()
# Write our files contents out to disk, in A/theta.
theta_path = sbox.ospath('A/theta')
svntest.main.file_write(theta_path, theta_contents, 'wb')
# Now, `svn add' that file.
svntest.main.run_svn(None, 'add', theta_path)
# Created expected output tree for 'svn ci'
expected_output = svntest.wc.State(wc_dir, {
'A/theta' : Item(verb='Adding (bin)'),
})
# Create expected status tree
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
expected_status.add({
'A/theta' : Item(status=' ', wc_rev=2),
})
# Commit the new binary file, creating revision 2.
svntest.actions.run_and_verify_commit(wc_dir, expected_output,
expected_status, None, wc_dir)
# Make some mods to the binary files.
svntest.main.file_append(theta_path, "foobar")
new_theta_contents = theta_contents + "foobar"
# Created expected output tree for 'svn ci'
expected_output = svntest.wc.State(wc_dir, {
'A/theta' : Item(verb='Sending'),
})
# Create expected status tree
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
expected_status.add({
'A/theta' : Item(status=' ', wc_rev=3),
})
# Commit modified working copy, creating revision 3.
svntest.actions.run_and_verify_commit(wc_dir, expected_output,
expected_status, None, wc_dir)
# Now we locally modify the file back to the old version.
svntest.main.file_write(theta_path, theta_contents, 'wb')
# Create expected output tree for an update to rev 2.
expected_output = svntest.wc.State(wc_dir, {
'A/theta' : Item(status='G '),
})
# Create expected disk tree for the update
expected_disk = svntest.main.greek_state.copy()
expected_disk.add({
'A/theta' : Item(theta_contents,
props={'svn:mime-type' : 'application/octet-stream'}),
})
# Create expected status tree for the update.
expected_status = svntest.actions.get_virginal_state(wc_dir, 2)
( run in 1.172 second using v1.01-cache-2.11-cpan-df04353d9ac )