Alien-SVN
view release on metacpan or search on metacpan
src/subversion/subversion/tests/cmdline/checkout_tests.py view on Meta::CPAN
r1_time = datetime.datetime(*map(int, date_pattern.match(r1_string).groups()))
peg_time = r1_time + datetime.timedelta(microseconds=1)
assert r1_time != peg_time
# peg_string is, by all likelihood, younger than r1's svn:date and older than
# r2's svn:date. It is also not equal to either of them, so we test the
# binary search of svn:date values.
peg_string = '%04d-%02d-%02dT%02d:%02d:%02d.%06dZ' % \
tuple(getattr(peg_time, x)
for x in ["year", "month", "day", "hour", "minute",
"second", "microsecond"])
# create a new revision
mu_path = os.path.join(wc_dir, 'A', 'mu')
svntest.main.file_append(mu_path, 'appended mu text')
svntest.actions.run_and_verify_svn(None, None, [],
'ci', '-m', 'changed file mu', wc_dir)
# now checkout the repo@peg_string in another folder, this should create our
# initial wc without the change in mu.
checkout_target = sbox.add_wc_path('checkout')
os.mkdir(checkout_target)
expected_output = svntest.main.greek_state.copy()
expected_output.wc_dir = checkout_target
expected_output.tweak(status='A ', contents=None)
expected_wc = svntest.main.greek_state.copy()
# use an old date to checkout, that way we're sure we get the first revision
svntest.actions.run_and_verify_checkout(sbox.repo_url +
'@{' + peg_string + '}',
checkout_target,
expected_output,
expected_wc)
# now try another checkout with repo@r1_string
checkout_target = sbox.add_wc_path('checkout2')
os.mkdir(checkout_target)
expected_output = svntest.main.greek_state.copy()
expected_output.wc_dir = checkout_target
expected_output.tweak(status='A ', contents=None)
expected_wc = svntest.main.greek_state.copy()
# use an old date to checkout, that way we're sure we get the first revision
svntest.actions.run_and_verify_checkout(sbox.repo_url +
'@{' + r1_string + '}',
checkout_target,
expected_output,
expected_wc)
#----------------------------------------------------------------------
def co_with_obstructing_local_adds(sbox):
"co handles obstructing paths scheduled for add"
sbox.build()
wc_dir = sbox.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)
# Add files and dirs to the repos via the first WC. Each of these
# will be added to the backup WC via a checkout:
#
# A/B/upsilon: Identical to the file scheduled for addition in
# the backup WC.
#
# A/C/nu: A "normal" add, won't exist in the backup WC.
#
# A/D/kappa: Conflicts with the file scheduled for addition in
# the backup WC.
#
# A/D/H/I: New dirs that will also be scheduled for addition
# A/D/H/I/J: in the backup WC.
# A/D/H/I/K:
#
# A/D/H/I/L: A "normal" dir add, won't exist in the backup WC.
#
# A/D/H/I/K/xi: Identical to the file scheduled for addition in
# the backup WC.
#
# A/D/H/I/K/eta: Conflicts with the file scheduled for addition in
# the backup WC.
upsilon_path = os.path.join(wc_dir, 'A', 'B', 'upsilon')
svntest.main.file_append(upsilon_path, "This is the file 'upsilon'\n")
nu_path = os.path.join(wc_dir, 'A', 'C', 'nu')
svntest.main.file_append(nu_path, "This is the file 'nu'\n")
kappa_path = os.path.join(wc_dir, 'A', 'D', 'kappa')
svntest.main.file_append(kappa_path, "This is REPOS file 'kappa'\n")
I_path = os.path.join(wc_dir, 'A', 'D', 'H', 'I')
os.mkdir(I_path)
J_path = os.path.join(I_path, 'J')
os.mkdir(J_path)
K_path = os.path.join(I_path, 'K')
os.mkdir(K_path)
L_path = os.path.join(I_path, 'L')
os.mkdir(L_path)
xi_path = os.path.join(K_path, 'xi')
svntest.main.file_append(xi_path, "This is file 'xi'\n")
eta_path = os.path.join(K_path, 'eta')
svntest.main.file_append(eta_path, "This is REPOS file 'eta'\n")
svntest.main.run_svn(None, 'add', upsilon_path, nu_path,
kappa_path, I_path)
# Created expected output tree for 'svn ci'
expected_output = wc.State(wc_dir, {
'A/B/upsilon' : Item(verb='Adding'),
'A/C/nu' : Item(verb='Adding'),
'A/D/kappa' : Item(verb='Adding'),
'A/D/H/I' : Item(verb='Adding'),
'A/D/H/I/J' : Item(verb='Adding'),
'A/D/H/I/K' : Item(verb='Adding'),
'A/D/H/I/K/xi' : Item(verb='Adding'),
'A/D/H/I/K/eta' : Item(verb='Adding'),
'A/D/H/I/L' : Item(verb='Adding'),
})
# Create expected status tree.
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
expected_status.add({
'A/B/upsilon' : Item(status=' ', wc_rev=2),
'A/C/nu' : Item(status=' ', wc_rev=2),
'A/D/kappa' : Item(status=' ', wc_rev=2),
'A/D/H/I' : Item(status=' ', wc_rev=2),
'A/D/H/I/J' : Item(status=' ', wc_rev=2),
'A/D/H/I/K' : Item(status=' ', wc_rev=2),
'A/D/H/I/K/xi' : Item(status=' ', wc_rev=2),
'A/D/H/I/K/eta' : Item(status=' ', wc_rev=2),
'A/D/H/I/L' : Item(status=' ', wc_rev=2),
})
# Commit.
svntest.actions.run_and_verify_commit(wc_dir, expected_output,
expected_status, None, wc_dir)
# Create various paths scheduled for addition which will obstruct
# the adds coming from the repos.
upsilon_backup_path = os.path.join(wc_backup, 'A', 'B', 'upsilon')
svntest.main.file_append(upsilon_backup_path,
"This is the file 'upsilon'\n")
kappa_backup_path = os.path.join(wc_backup, 'A', 'D', 'kappa')
svntest.main.file_append(kappa_backup_path,
"This is WC file 'kappa'\n")
I_backup_path = os.path.join(wc_backup, 'A', 'D', 'H', 'I')
os.mkdir(I_backup_path)
J_backup_path = os.path.join(I_backup_path, 'J')
os.mkdir(J_backup_path)
K_backup_path = os.path.join(I_backup_path, 'K')
os.mkdir(K_backup_path)
xi_backup_path = os.path.join(K_backup_path, 'xi')
svntest.main.file_append(xi_backup_path, "This is file 'xi'\n")
eta_backup_path = os.path.join(K_backup_path, 'eta')
svntest.main.file_append(eta_backup_path, "This is WC file 'eta'\n")
svntest.main.run_svn(None, 'add',
upsilon_backup_path,
kappa_backup_path,
I_backup_path)
# Create expected output tree for a checkout of the wc_backup.
expected_output = wc.State(wc_backup, {
'A/B/upsilon' : Item(status='E '),
'A/C/nu' : Item(status='A '),
'A/D/H/I' : Item(status='E '),
'A/D/H/I/J' : Item(status='E '),
'A/D/H/I/K' : Item(status='E '),
'A/D/H/I/K/xi' : Item(status='E '),
'A/D/H/I/K/eta' : Item(status='C '),
'A/D/H/I/L' : Item(status='A '),
'A/D/kappa' : Item(status='C '),
})
# Create expected disk for checkout of wc_backup.
expected_disk = svntest.main.greek_state.copy()
expected_disk.add({
'A/B/upsilon' : Item("This is the file 'upsilon'\n"),
'A/C/nu' : Item("This is the file 'nu'\n"),
'A/D/H/I' : Item(),
'A/D/H/I/J' : Item(),
'A/D/H/I/K' : Item(),
'A/D/H/I/K/xi' : Item("This is file 'xi'\n"),
'A/D/H/I/K/eta' : Item("\n".join(["<<<<<<< .mine",
"This is WC file 'eta'",
"=======",
"This is REPOS file 'eta'",
">>>>>>> .r2",
""])),
'A/D/H/I/L' : Item(),
'A/D/kappa' : Item("\n".join(["<<<<<<< .mine",
"This is WC file 'kappa'",
"=======",
"This is REPOS file 'kappa'",
">>>>>>> .r2",
""])),
})
# Create expected status tree for the checkout. Since the obstructing
# kappa and upsilon differ from the repos, they should show as modified.
expected_status = svntest.actions.get_virginal_state(wc_backup, 2)
expected_status.add({
'A/B/upsilon' : Item(status=' ', wc_rev=2),
'A/C/nu' : Item(status=' ', wc_rev=2),
'A/D/H/I' : Item(status=' ', wc_rev=2),
'A/D/H/I/J' : Item(status=' ', wc_rev=2),
'A/D/H/I/K' : Item(status=' ', wc_rev=2),
'A/D/H/I/K/xi' : Item(status=' ', wc_rev=2),
'A/D/H/I/K/eta' : Item(status='C ', wc_rev=2),
'A/D/H/I/L' : Item(status=' ', wc_rev=2),
'A/D/kappa' : Item(status='C ', wc_rev=2),
})
# "Extra" files that we expect to result from the conflicts.
extra_files = ['eta\.r0', 'eta\.r2', 'eta\.mine',
'kappa\.r0', 'kappa\.r2', 'kappa\.mine']
# Perform the checkout and check the results in three ways.
# We use --force here because run_and_verify_checkout() will delete
# wc_backup before performing the checkout otherwise.
svntest.actions.run_and_verify_checkout(sbox.repo_url, wc_backup,
expected_output, expected_disk,
svntest.tree.detect_conflict_files,
extra_files, None, None,
'--force')
svntest.actions.run_and_verify_status(wc_backup, expected_status)
# Some obstructions are still not permitted:
#
# Test that file and dir obstructions scheduled for addition *with*
# history fail when checkout tries to add the same path.
# URL to URL copy of A/D/G to A/D/M.
G_URL = sbox.repo_url + '/A/D/G'
M_URL = sbox.repo_url + '/A/D/M'
svntest.actions.run_and_verify_svn("Copy error:", None, [],
'cp', G_URL, M_URL, '-m', '')
# WC to WC copy of A/D/H to A/D/M. (M is now scheduled for addition
# with history in WC and pending addition from the repos).
D_path = os.path.join(wc_dir, 'A', 'D')
H_path = os.path.join(wc_dir, 'A', 'D', 'H')
M_path = os.path.join(wc_dir, 'A', 'D', 'M')
svntest.actions.run_and_verify_svn("Copy error:", None, [],
'cp', H_path, M_path)
# URL to URL copy of A/B/E/alpha to A/B/F/omicron.
omega_URL = sbox.repo_url + '/A/B/E/alpha'
omicron_URL = sbox.repo_url + '/A/B/F/omicron'
svntest.actions.run_and_verify_svn("Copy error:", None, [],
'cp', omega_URL, omicron_URL,
'-m', '')
# WC to WC copy of A/D/H/chi to /A/B/F/omicron. (omicron is now
# scheduled for addition with history in WC and pending addition
# from the repos).
F_path = os.path.join(wc_dir, 'A', 'B', 'F')
omicron_path = os.path.join(wc_dir, 'A', 'B', 'F', 'omicron')
chi_path = os.path.join(wc_dir, 'A', 'D', 'H', 'chi')
svntest.actions.run_and_verify_svn("Copy error:", None, [],
'cp', chi_path,
omicron_path)
# Try to co M's Parent.
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
expected_status.add({
'A/B/F/omicron' : Item(status='A ', copied='+', wc_rev='-'),
'A/B/upsilon' : Item(status=' ', wc_rev=2),
'A/C/nu' : Item(status=' ', wc_rev=2),
'A/D/kappa' : Item(status=' ', wc_rev=2),
'A/D/H/I' : Item(status=' ', wc_rev=2),
'A/D/H/I/J' : Item(status=' ', wc_rev=2),
'A/D/H/I/K' : Item(status=' ', wc_rev=2),
'A/D/H/I/K/xi' : Item(status=' ', wc_rev=2),
'A/D/H/I/K/eta' : Item(status=' ', wc_rev=2),
'A/D/H/I/L' : Item(status=' ', wc_rev=2),
'A/D/M' : Item(status='A ', copied='+', wc_rev='-'),
'A/D/M/psi' : Item(status=' ', copied='+', wc_rev='-'),
'A/D/M/chi' : Item(status=' ', copied='+', wc_rev='-'),
'A/D/M/omega' : Item(status=' ', copied='+', wc_rev='-'),
'A/D/M/I' : Item(status='A ', copied='+', wc_rev='-',
entry_status=' '), # A/D/MI is a new op_root
'A/D/M/I/J' : Item(status=' ', copied='+', wc_rev='-'),
'A/D/M/I/K' : Item(status=' ', copied='+', wc_rev='-'),
( run in 2.140 seconds using v1.01-cache-2.11-cpan-97f6503c9c8 )