Author: julianfoad
Date: Mon Oct 4 11:51:17 2010
New Revision: 1004209
URL: http://svn.apache.org/viewvc?rev=1004209&view=rev
Log:
Add a test for the NODES table op_depth column.
* subversion/tests/cmdline/copy_tests.py
(check_op_depth): New function.
(nodes_table_wc_wc_copies): New test.
(test_list): Add the new test, marked Wimp.
Modified:
subversion/trunk/subversion/tests/cmdline/copy_tests.py
Modified: subversion/trunk/subversion/tests/cmdline/copy_tests.py
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/copy_tests.py?rev=1004209&r1=1004208&r2=1004209&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/copy_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/copy_tests.py Mon Oct 4 11:51:17
2010
@@ -4679,6 +4679,143 @@ def copy_over_deleted_dir(sbox):
main.run_svn(None, 'cp', os.path.join(sbox.wc_dir, 'A/D'),
os.path.join(sbox.wc_dir, 'A/B'))
+#----------------------------------------------------------------------
+
+def check_op_depth(path, expected_result):
+ """Examine the WC DB for paths PATH and below, and check that their rows
+ in the 'NODES' table match EXPECTED_RESULT. EXPECTED_RESULT is a
+ dictionary of {(op_depth, relpath) -> has_repo_noderev}, where 'relpath'
+ is relative to PATH, and 'has_repo_noderev' is true iff the repository
+ id, revision and relpath columns are expected to be non-null.
+
+ If the result does not match, raise a Failure.
+ """
+
+ errors = []
+
+ db, _, base_relpath = svntest.wc.open_wc_db(path)
+ c = db.cursor()
+
+ c.execute("""SELECT op_depth, presence, local_relpath, repos_id, revision,
+ repos_path FROM nodes
+ WHERE local_relpath LIKE '""" + base_relpath + """%'""")
+ for row in c:
+ op_depth = row[0]
+ wc_relpath = row[2]
+ repo_id = row[3]
+ repo_rev = row[4]
+ repo_relpath = row[5]
+ relpath = wc_relpath[len(base_relpath):]
+
+ try:
+ has_repo = expected_result.pop((op_depth, relpath))
+ except KeyError:
+ errors.append("Row not expected: op_depth=%s, relpath=%s"
+ % (op_depth, relpath))
+
+ try:
+ if has_repo:
+ assert repo_id and repo_rev and repo_relpath
+ else:
+ assert not repo_id and not repo_rev and not repo_relpath
+ except AssertionError:
+ print " EXPECTED:", op_depth, relpath, has_repo
+ print " ACTUAL: ", op_depth, relpath, repo_relpath
+ errors.append("Row op_depth=%s, relpath=%s has repo_relpath=%s"
+ % (op_depth, relpath, repo_relpath))
+
+ for (op_depth, relpath) in expected_result:
+ errors.append("Row not found: op_depth=%s, relpath=%s"
+ % (op_depth, relpath))
+
+ db.close()
+
+ if errors:
+ raise svntest.Failure(errors)
+
+def nodes_table_wc_wc_copies(sbox):
+ """test wc-to-wc copies"""
+ sbox.build()
+
+ def wc_path(*components):
+ return os.path.join(sbox.wc_dir, *components)
+
+ # Prepare various things to copy
+
+ source_base_file = wc_path('A', 'B', 'lambda')
+ source_base_dir = wc_path('A', 'B', 'E')
+
+ source_added_file = wc_path('A', 'B', 'file-added')
+ source_added_dir = wc_path('A', 'B', 'D-added')
+ source_added_dir2 = wc_path('A', 'B', 'D-added', 'D2')
+
+ svntest.main.file_write(source_added_file, 'New file')
+ sbox.simple_add(source_added_file)
+ sbox.simple_mkdir(source_added_dir)
+ sbox.simple_mkdir(source_added_dir2)
+
+ source_copied_file = wc_path('A', 'B', 'lambda-copied')
+ source_copied_dir = wc_path('A', 'B', 'E-copied')
+
+ svntest.main.run_svn(None, 'copy', source_base_file, source_copied_file)
+ svntest.main.run_svn(None, 'copy', source_base_dir, source_copied_dir)
+
+ # Test copying various things
+
+ # base file
+ target = wc_path('A', 'C', 'copy1')
+ svntest.main.run_svn(None, 'copy', source_base_file, target)
+ check_op_depth(target, { (3, ''): True })
+
+ # base dir
+ target = wc_path('A', 'C', 'copy2')
+ svntest.main.run_svn(None, 'copy', source_base_dir, target)
+ check_op_depth(target, { (3, ''): True,
+ (3, '/alpha'): False,
+ (3, '/beta'): False })
+
+ # added file
+ target = wc_path('A', 'C', 'copy3')
+ svntest.main.run_svn(None, 'copy', source_added_file, target)
+ check_op_depth(target, { (3, ''): False })
+
+ # added dir
+ target = wc_path('A', 'C', 'copy4')
+ svntest.main.run_svn(None, 'copy', source_added_dir, target)
+ check_op_depth(target, { (3, ''): False,
+ (4, '/D2'): False })
+
+ # copied file
+ target = wc_path('A', 'C', 'copy5')
+ svntest.main.run_svn(None, 'copy', source_copied_file, target)
+ check_op_depth(target, { (3, ''): True })
+
+ # copied dir
+ target = wc_path('A', 'C', 'copy6')
+ svntest.main.run_svn(None, 'copy', source_copied_dir, target)
+ check_op_depth(target, { (3, ''): True,
+ (3, '/alpha'): False,
+ (3, '/beta'): False })
+
+ # copied tree with everything in it
+ target = wc_path('A', 'C', 'copy7')
+ svntest.main.run_svn(None, 'copy', wc_path('A', 'B'), target)
+ check_op_depth(target, { (3, ''): True,
+ (3, '/lambda'): False,
+ (3, '/E'): False,
+ (3, '/E/alpha'): False,
+ (3, '/E/beta'): False,
+ (3, '/F'): False,
+ # Each add is an op_root
+ (4, '/file-added'): False,
+ (4, '/D-added'): False,
+ (5, '/D-added/D2'): False,
+ # Each copied-copy subtree is an op_root
+ (4, '/lambda-copied'): True,
+ (4, '/E-copied'): True,
+ (4, '/E-copied/alpha'):False,
+ (4, '/E-copied/beta'): False, })
+
########################################################################
# Run the tests
@@ -4774,6 +4911,7 @@ test_list = [ None,
XFail(changed_dir_data_should_match_checkout),
move_added_nodes,
copy_over_deleted_dir,
+ Wimp("Needs NODES table & op-depth", nodes_table_wc_wc_copies),
]
if __name__ == '__main__':