merge_tests.py
来自「linux subdivision ying gai ke yi le ba」· Python 代码 · 共 1,635 行 · 第 1/5 页
PY
1,635 行
})
expected_skip = wc.State('', { })
svntest.actions.run_and_verify_merge(other_wc, '2', '3',
svntest.main.current_repo_url,
expected_output,
expected_disk,
expected_status,
expected_skip,
None, None, None, None, None,
1)
#----------------------------------------------------------------------
# Regression test for Issue #1297:
# A merge that creates a new file followed by an immediate diff
# The diff should succeed.
def merge_in_new_file_and_diff(sbox):
"diff after merge that creates a new file"
sbox.build()
wc_dir = sbox.wc_dir
trunk_url = svntest.main.current_repo_url + '/A/B/E'
# Create a branch
svntest.actions.run_and_verify_svn(None, None, [], 'cp',
trunk_url,
svntest.main.current_repo_url + '/branch',
'-m', "Creating the Branch")
# Update to revision 2.
svntest.actions.run_and_verify_svn(None, None, [], 'update', wc_dir)
new_file_path = os.path.join(wc_dir, 'A', 'B', 'E', 'newfile')
fp = open(new_file_path, 'w')
fp.write("newfile")
fp.close()
# Add the new file, and commit revision 3.
svntest.actions.run_and_verify_svn(None, None, [], "add", new_file_path)
svntest.actions.run_and_verify_svn(None, None, [], 'ci', '-m',
"Changing the trunk.", wc_dir)
# Merge our addition into the branch.
branch_path = os.path.join(wc_dir, "branch")
expected_output = svntest.wc.State(branch_path, {
'newfile' : Item(status='A '),
})
expected_disk = wc.State('', {
'alpha' : Item("This is the file 'alpha'."),
'beta' : Item("This is the file 'beta'."),
'newfile' : Item("newfile"),
})
expected_status = wc.State(branch_path, {
'' : Item(status=' ', wc_rev=2),
'alpha' : Item(status=' ', wc_rev=2),
'beta' : Item(status=' ', wc_rev=2),
'newfile' : Item(status='A ', wc_rev='-', copied='+')
})
expected_status.tweak(repos_rev=3)
expected_skip = wc.State('', { })
svntest.actions.run_and_verify_merge(branch_path, '1', 'HEAD', trunk_url,
expected_output,
expected_disk,
expected_status,
expected_skip)
# Finally, run diff. This diff produces no output!
svntest.actions.run_and_verify_svn(None, [], [], 'diff', branch_path)
#----------------------------------------------------------------------
# Issue #1425: 'svn merge' should skip over any unversioned obstructions.
def merge_skips_obstructions(sbox):
"merge should skip over unversioned obstructions"
sbox.build()
wc_dir = sbox.wc_dir
C_path = os.path.join(wc_dir, 'A', 'C')
F_path = os.path.join(wc_dir, 'A', 'B', 'F')
F_url = svntest.main.current_repo_url + '/A/B/F'
Q_path = os.path.join(F_path, 'Q')
foo_path = os.path.join(F_path, 'foo')
bar_path = os.path.join(F_path, 'Q', 'bar')
svntest.main.run_svn(None, 'mkdir', Q_path)
svntest.main.file_append(foo_path, "foo")
svntest.main.file_append(bar_path, "bar")
svntest.main.run_svn(None, 'add', foo_path, bar_path)
expected_output = wc.State(wc_dir, {
'A/B/F/Q' : Item(verb='Adding'),
'A/B/F/Q/bar' : Item(verb='Adding'),
'A/B/F/foo' : Item(verb='Adding'),
})
expected_status = svntest.actions.get_virginal_state(wc_dir, 2)
expected_status.tweak(wc_rev=1)
expected_status.add({
'A/B/F/Q' : Item(status=' ', wc_rev=2, repos_rev=2),
'A/B/F/Q/bar' : Item(status=' ', wc_rev=2, repos_rev=2),
'A/B/F/foo' : 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)
pre_merge_status = expected_status
# Revision 2 now has A/B/F/foo, A/B/F/Q, A/B/F/Q/bar. Let's merge
# those 'F' changes into empty dir 'C'. But first, create an
# unversioned 'foo' within C, and make sure 'svn merge' doesn't
# error when the addition of foo is obstructed.
expected_output = wc.State(C_path, {
'Q' : Item(status='A '),
'Q/bar' : Item(status='A '),
})
expected_disk = wc.State('', {
'Q' : Item(),
'Q/bar' : Item("bar"),
'foo' : Item("foo"),
})
expected_status = wc.State(C_path, {
'' : Item(status=' ', wc_rev=1, repos_rev=2),
'Q' : Item(status='A ', wc_rev='-', copied='+', repos_rev=2),
'Q/bar' : Item(status='A ', wc_rev='-', copied='+', repos_rev=2),
})
expected_skip = wc.State(C_path, {
'foo' : Item(),
})
svntest.main.file_append(os.path.join(C_path, "foo"), "foo") # unversioned
svntest.actions.run_and_verify_merge(C_path, '1', '2', F_url,
expected_output,
expected_disk,
expected_status,
expected_skip,
None, None, None, None, None,
0, 0)
# Revert the local mods, and this time make "Q" obstructed. An
# unversioned file called "Q" will obstruct the adding of the
# directory of the same name.
svntest.actions.run_and_verify_svn(None, None, [],
'revert', '-R', wc_dir)
os.unlink(os.path.join(C_path, "foo"))
svntest.main.safe_rmtree(os.path.join(C_path, "Q"))
svntest.main.file_append(os.path.join(C_path, "Q"), "foo") # unversioned
svntest.actions.run_and_verify_status(wc_dir, pre_merge_status)
expected_output = wc.State(C_path, {
'foo' : Item(status='A '),
})
expected_disk = wc.State('', {
'Q' : Item("foo"),
'foo' : Item("foo"),
})
expected_status = wc.State(C_path, {
'' : Item(status=' ', wc_rev=1, repos_rev=2),
'foo' : Item(status='A ', wc_rev='-', copied='+', repos_rev=2),
})
expected_skip = wc.State(C_path, {
'Q' : Item(),
'Q/bar' : Item(),
})
svntest.actions.run_and_verify_merge(C_path, '1', '2', F_url,
expected_output,
expected_disk,
expected_status,
expected_skip,
None, None, None, None, None,
0, 0)
# Revert the local mods, and commit the deletion of iota and A/D/G. (r3)
os.unlink(os.path.join(C_path, "foo"))
svntest.actions.run_and_verify_svn(None, None, [], 'revert', '-R', wc_dir)
svntest.actions.run_and_verify_status(wc_dir, pre_merge_status)
iota_path = os.path.join(wc_dir, 'iota')
G_path = os.path.join(wc_dir, 'A', 'D', 'G')
svntest.actions.run_and_verify_svn(None, None, [], 'rm', iota_path, G_path)
expected_output = wc.State(wc_dir, {
'A/D/G' : Item(verb='Deleting'),
'iota' : Item(verb='Deleting'),
})
expected_status = pre_merge_status
expected_status.tweak(repos_rev=3)
expected_status.remove('iota', 'A/D/G', 'A/D/G/pi', 'A/D/G/rho', 'A/D/G/tau')
svntest.actions.run_and_verify_commit(wc_dir,
expected_output,
expected_status,
None, None, None, None, None,
wc_dir)
# Now create unversioned iota and A/D/G, try running a merge -r2:3.
# The merge process should skip over these targets, since they're
# unversioned.
svntest.main.file_append(iota_path, "foo") # unversioned
os.mkdir(G_path) # unversioned
expected_output = wc.State(wc_dir, { })
expected_disk = svntest.main.greek_state.copy()
expected_disk.remove('A/D/G/pi', 'A/D/G/rho', 'A/D/G/tau')
expected_disk.add({
'A/B/F/Q' : Item(),
'A/B/F/Q/bar' : Item("bar"),
'A/B/F/foo' : Item("foo"),
'iota' : Item("foo"),
'A/C/Q' : Item("foo"),
})
expected_skip = wc.State(wc_dir, {
'A/D/G' : Item(),
'iota' : Item(),
})
svntest.actions.run_and_verify_merge(wc_dir, '2', '3',
svntest.main.current_repo_url,
expected_output,
expected_disk,
expected_status,
expected_skip)
# Revert the local mods, and commit a change to A/B/lambda (r4), and then
# commit the deletion of the same file. (r5)
os.unlink(iota_path)
svntest.main.safe_rmtree(G_path)
svntest.actions.run_and_verify_svn(None, None, [], 'revert', '-R', wc_dir)
svntest.actions.run_and_verify_status(wc_dir, expected_status)
lambda_path = os.path.join(wc_dir, 'A', 'B', 'lambda')
svntest.main.file_append(lambda_path, "more text")
expected_output = wc.State(wc_dir, {
'A/B/lambda' : Item(verb='Sending'),
})
expected_status.tweak(repos_rev=4)
expected_status.tweak('A/B/lambda', wc_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, [], 'rm', lambda_path)
expected_output = wc.State(wc_dir, {
'A/B/lambda' : Item(verb='Deleting'),
})
expected_status.tweak(repos_rev=5)
expected_status.remove('A/B/lambda')
svntest.actions.run_and_verify_commit(wc_dir,
expected_output,
expected_status,
None, None, None, None, None,
wc_dir)
# lambda is gone, so create an unversioned lambda in its place.
# Then attempt to merge -r3:4, which is a change to lambda. The merge
# should simply skip the unversioned file.
svntest.main.file_append(lambda_path, "foo") # unversioned
expected_output = wc.State(wc_dir, { })
expected_disk.add({
'A/B/lambda' : Item("foo"),
})
expected_disk.remove('A/D/G', 'iota')
expected_skip = wc.State(wc_dir, {
'A/B/lambda' : Item(),
})
svntest.actions.run_and_verify_merge(wc_dir, '3', '4',
svntest.main.current_repo_url,
expected_output,
expected_disk,
expected_status,
expected_skip)
# OK, so let's commit the new lambda (r6), and then delete the
# working file. Then re-run the -r3:4 merge, and see how svn deals
# with a file being under version control, but missing.
svntest.actions.run_and_verify_svn(None, None, [], 'add', lambda_path)
expected_output = wc.State(wc_dir, {
'A/B/lambda' : Item(verb='Adding'),
})
expected_status.add({
'A/B/lambda' : Item(wc_rev=6, status=' '),
})
expected_status.tweak(repos_rev=6)
svntest.actions.run_and_verify_commit(wc_dir,
expected_output,
expected_status,
None, None, None, None, None,
wc_dir)
os.unlink(lambda_path)
expected_output = wc.State(wc_dir, { })
expected_disk.remove('A/B/lambda')
expected_status.tweak('A/B/lambda', status='! ')
svntest.actions.run_and_verify_merge(wc_dir, '3', '4',
svntest.main.current_repo_url,
expected_output,
expected_disk,
expected_status,
expected_skip)
#----------------------------------------------------------------------
# At one stage a merge that added items with the same name as missing
# items would attempt to add the items and fail, leaving the working
# copy locked and broken.
def merge_into_missing(sbox):
"merge into missing must not break working copy"
sbox.buil
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?