merge_tests.py
来自「linux subdivision ying gai ke yi le ba」· Python 代码 · 共 1,635 行 · 第 1/5 页
PY
1,635 行
# Commit change as rev 4
expected_status = svntest.actions.get_virginal_state(wc_dir, 3)
expected_status.tweak(repos_rev=4)
expected_status.tweak('A/B/E', 'A/B/E/alpha', wc_rev=4, status=' ')
expected_status.add({
'A/B2' : Item(status=' ', wc_rev=3, repos_rev=4),
'A/B2/E' : Item(status=' ', wc_rev=3, repos_rev=4),
'A/B2/E/alpha' : Item(status=' ', wc_rev=3, repos_rev=4),
'A/B2/E/beta' : Item(status=' ', wc_rev=3, repos_rev=4),
'A/B2/F' : Item(status=' ', wc_rev=3, repos_rev=4),
'A/B2/lambda' : Item(status=' ', wc_rev=3, repos_rev=4),
})
svntest.actions.run_and_verify_commit (wc_dir,
expected_output, expected_status,
None, None, None, None, None,
wc_dir)
svntest.actions.run_and_verify_svn(None, None, [], 'up', wc_dir)
pristine_status = expected_status
pristine_status.tweak(wc_rev=4)
# Merge B 3:4 into B2
B2_path = os.path.join(wc_dir, 'A', 'B2')
expected_output = wc.State(B2_path, {
'E' : Item(status=' U'),
'E/alpha' : Item(status=' U'),
})
expected_disk = wc.State('', {
'E' : Item(),
'E/alpha' : Item("This is the file 'alpha'."),
'E/beta' : Item("This is the file 'beta'."),
'F' : Item(),
'lambda' : Item("This is the file 'lambda'."),
})
expected_disk.tweak('E', 'E/alpha',
props={'foo' : 'mod_foo', 'bar' : 'bar_val'})
expected_status = wc.State(B2_path, {
'' : Item(status=' '),
'E' : Item(status=' M'),
'E/alpha' : Item(status=' M'),
'E/beta' : Item(status=' '),
'F' : Item(status=' '),
'lambda' : Item(status=' '),
})
expected_status.tweak(wc_rev=4, repos_rev=4)
expected_skip = wc.State('', { })
svntest.actions.run_and_verify_merge(B2_path, '3', '4', B_url,
expected_output,
expected_disk,
expected_status,
expected_skip,
None, None, None, None, None, 1)
# Revert merge
svntest.actions.run_and_verify_svn(None, None, [],
'revert', '--recursive', wc_dir)
svntest.actions.run_and_verify_status(wc_dir, pristine_status)
# Merge B 2:1 into B2
expected_disk.tweak('E', 'E/alpha', props={})
svntest.actions.run_and_verify_merge(B2_path, '2', '1', B_url,
expected_output,
expected_disk,
expected_status,
expected_skip,
None, None, None, None, None, 1)
# Merge B 3:4 into B2 now causes a conflict
expected_disk.add({
'E/dir_conflicts.prej'
: Item("Property 'foo' locally deleted, "
+ "but update sets it to 'mod_foo'\n"),
'E/alpha.prej'
: Item("Property 'foo' locally deleted, "
+ "but update sets it to 'mod_foo'\n"),
})
expected_disk.tweak('E', 'E/alpha', props={'bar' : 'bar_val'})
expected_status.tweak('E', 'E/alpha', status=' C')
svntest.actions.run_and_verify_merge(B2_path, '3', '4', B_url,
expected_output,
expected_disk,
expected_status,
expected_skip,
None, None, None, None, None, 1)
# issue 1109 : single file property merge. This test performs a merge
# that should be a no-op (adding properties that are already present).
svntest.actions.run_and_verify_svn(None, None, [],
'revert', '--recursive', wc_dir)
svntest.actions.run_and_verify_status(wc_dir, pristine_status)
A_url = svntest.main.current_repo_url + '/A'
A2_url = svntest.main.current_repo_url + '/A2'
# Copy to make revision 5
svntest.actions.run_and_verify_svn(None,
['\n', 'Committed revision 5.\n'], [],
'copy', '-m', 'fumble',
'--username', svntest.main.wc_author,
'--password', svntest.main.wc_passwd,
A_url, A2_url)
svntest.actions.run_and_verify_svn(None, None, [], 'switch', A2_url, wc_dir)
A_url = svntest.main.current_repo_url + '/A/B/E/alpha'
alpha_path = os.path.join(wc_dir, 'B', 'E', 'alpha')
# Cannot use run_and_verify_merge with a file target
svntest.actions.run_and_verify_svn(None,
[' U ' + alpha_path + '\n'], [],
'merge',
'-r', '3:4', A_url, alpha_path)
output, err = svntest.actions.run_and_verify_svn(None, None, [],
'pl', alpha_path)
saw_foo = 0
saw_bar = 0
for line in output:
if re.match("\\s*foo\\s*$", line):
saw_foo = 1
if re.match("\\s*bar\\s*$", line):
saw_bar = 1
if not saw_foo or not saw_bar:
raise svntest.Failure
#----------------------------------------------------------------------
# This is a regression for issue #1176.
def merge_catches_nonexistent_target(sbox):
"merge should not die if a target file is absent"
sbox.build()
wc_dir = sbox.wc_dir
# Copy G to a new directory, Q. Create Q/newfile. Commit a change
# to Q/newfile. Now merge that change... into G. Merge should not
# error, but should do nothing.
G_path = os.path.join(wc_dir, 'A', 'D', 'G')
Q_path = os.path.join(wc_dir, 'A', 'D', 'Q')
newfile_path = os.path.join(Q_path, 'newfile')
Q_url = svntest.main.current_repo_url + '/A/D/Q'
svntest.actions.run_and_verify_svn(None, None, [], 'cp', G_path, Q_path)
svntest.main.file_append(newfile_path, 'This is newfile.\n')
svntest.actions.run_and_verify_svn(None, None, [], 'add', newfile_path)
expected_output = wc.State(wc_dir, {
'A/D/Q' : Item(verb='Adding'),
'A/D/Q/newfile' : Item(verb='Adding'),
})
expected_status = svntest.actions.get_virginal_state(wc_dir, 2)
expected_status.tweak(wc_rev=1)
expected_status.add({
'A/D/Q' : Item(status=' ', wc_rev=2, repos_rev=2),
'A/D/Q/pi' : Item(status=' ', wc_rev=2, repos_rev=2),
'A/D/Q/rho' : Item(status=' ', wc_rev=2, repos_rev=2),
'A/D/Q/tau' : Item(status=' ', wc_rev=2, repos_rev=2),
'A/D/Q/newfile' : Item(status=' ', wc_rev=2, repos_rev=2),
})
svntest.actions.run_and_verify_commit(wc_dir,
expected_output,
expected_status,
None, None, None, None, None,
wc_dir)
svntest.main.file_append(newfile_path, 'A change to newfile.\n')
expected_output = wc.State(wc_dir, {
'A/D/Q/newfile' : Item(verb='Sending'),
})
expected_status.tweak('A/D/Q/newfile', wc_rev=3)
expected_status.tweak(repos_rev=3)
svntest.actions.run_and_verify_commit(wc_dir,
expected_output,
expected_status,
None, None, None, None, None,
wc_dir)
saved_cwd = os.getcwd()
try:
os.chdir(G_path)
expected_output = wc.State('', { })
expected_status = wc.State('', {
'' : Item(),
'pi' : Item(),
'rho' : Item(),
'tau' : Item(),
})
expected_status.tweak(status=' ', wc_rev=1, repos_rev=3)
expected_disk = wc.State('', {
'pi' : Item("This is the file 'pi'."),
'rho' : Item("This is the file 'rho'."),
'tau' : Item("This is the file 'tau'."),
})
expected_skip = wc.State('', {
'newfile' :Item(),
})
svntest.actions.run_and_verify_merge('', '2', '3', Q_url,
expected_output,
expected_disk,
expected_status,
expected_skip)
finally:
os.chdir(saved_cwd)
#----------------------------------------------------------------------
def merge_tree_deleted_in_target(sbox):
"merge on deleted directory in target"
sbox.build()
wc_dir = sbox.wc_dir
# Copy B to a new directory, I. Modify B/E/alpha, Remove I/E. Now
# merge that change... into I. Merge should not error
B_path = os.path.join(wc_dir, 'A', 'B')
I_path = os.path.join(wc_dir, 'A', 'I')
alpha_path = os.path.join(B_path, 'E', 'alpha')
B_url = svntest.main.current_repo_url + '/A/B'
I_url = svntest.main.current_repo_url + '/A/I'
svntest.actions.run_and_verify_svn(None, None, [],
'cp', B_url, I_url, '-m', 'rev 2')
svntest.main.file_append(alpha_path, 'A change to alpha.\n')
svntest.main.file_append(os.path.join(B_path, 'lambda'), 'change lambda.\n')
svntest.actions.run_and_verify_svn(None, None, [],
'ci', '-m', 'rev 3', B_path)
E_url = svntest.main.current_repo_url + '/A/I/E'
svntest.actions.run_and_verify_svn(None, None, [],
'rm', E_url, '-m', 'rev 4')
svntest.actions.run_and_verify_svn(None, None, [],
'up', os.path.join(wc_dir,'A'))
expected_output = wc.State(I_path, {
'lambda' : Item(status='U '),
})
expected_disk = wc.State('', {
'F' : Item(),
'lambda' : Item("This is the file 'lambda'.change lambda.\n"),
})
expected_status = wc.State(I_path, {
'' : Item(status=' '),
'F' : Item(status=' '),
'lambda' : Item(status='M '),
})
expected_status.tweak(wc_rev=4, repos_rev=4)
expected_skip = wc.State(I_path, {
'E' : Item(),
'E/alpha' : Item(),
})
svntest.actions.run_and_verify_merge(I_path, '2', '3', B_url,
expected_output,
expected_disk,
expected_status,
expected_skip,
None, None, None, None, None,
0, 0)
#----------------------------------------------------------------------
# This is a regression for issue #1176.
def merge_similar_unrelated_trees(sbox):
"merging similar trees ancestrally unrelated"
## See http://subversion.tigris.org/issues/show_bug.cgi?id=1249. ##
sbox.build()
wc_dir = sbox.wc_dir
# Simple test. Make three directories with the same content.
# Modify some stuff in the second one. Now merge
# (firstdir:seconddir->thirddir).
base1_path = os.path.join(wc_dir, 'base1')
base2_path = os.path.join(wc_dir, 'base2')
apply_path = os.path.join(wc_dir, 'apply')
base1_url = os.path.join(svntest.main.current_repo_url + '/base1')
base2_url = os.path.join(svntest.main.current_repo_url + '/base2')
# Make a tree of stuff ...
os.mkdir(base1_path)
svntest.main.file_append(os.path.join(base1_path, 'iota'),
"This is the file iota\n")
os.mkdir(os.path.join(base1_path, 'A'))
svntest.main.file_append(os.path.join(base1_path, 'A', 'mu'),
"This is the file mu\n")
os.mkdir(os.path.join(base1_path, 'A', 'B'))
svntest.main.file_append(os.path.join(base1_path, 'A', 'B', 'alpha'),
"This is the file alpha\n")
svntest.main.file_append(os.path.join(base1_path, 'A', 'B', 'beta'),
"This is the file beta\n")
# ... Copy it twice ...
shutil.copytree(base1_path, base2_path)
shutil.copytree(base1_path, apply_path)
# ... Gonna see if merge is naughty or nice!
svntest.main.file_append(os.path.join(base2_path, 'A', 'mu'),
"A new line in mu.\n")
os.rename(os.path.join(base2_path, 'A', 'B', 'beta'),
os.path.join(base2_path, 'A', 'B', 'zeta'))
svntest.actions.run_and_verify_svn(None, None, [],
'add', base1_path, base2_path, apply_path)
svntest.actions.run_and_verify_svn(None, None, [],
'ci', '-m', 'rev 2', wc_dir)
expected_output = wc.State(apply_path, {
'A/mu' : Item(status='U '),
'A/B/zeta' : Item(status='A '),
'A/B/beta' : Item(status='D '),
})
# run_and_verify_merge doesn't support 'svn merge URL URL path'
svntest.actions.run_and_verify_svn(None, None, [],
'merge',
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?