You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by da...@apache.org on 2012/03/30 15:55:31 UTC

svn commit: r1307424 [8/11] - in /subversion/branches/revprop-packing: ./ build/ac-macros/ notes/ notes/directory-index/ notes/wc-ng/ subversion/bindings/javahl/ subversion/bindings/swig/python/svn/ subversion/bindings/swig/python/tests/ subversion/bin...

Modified: subversion/branches/revprop-packing/subversion/tests/cmdline/svntest/actions.py
URL: http://svn.apache.org/viewvc/subversion/branches/revprop-packing/subversion/tests/cmdline/svntest/actions.py?rev=1307424&r1=1307423&r2=1307424&view=diff
==============================================================================
--- subversion/branches/revprop-packing/subversion/tests/cmdline/svntest/actions.py (original)
+++ subversion/branches/revprop-packing/subversion/tests/cmdline/svntest/actions.py Fri Mar 30 13:55:26 2012
@@ -24,14 +24,31 @@
 ######################################################################
 
 import os, shutil, re, sys, errno
-import difflib, pprint
+import difflib, pprint, logging
 import xml.parsers.expat
 from xml.dom.minidom import parseString
+if sys.version_info[0] >= 3:
+  # Python >=3.0
+  from io import StringIO
+else:
+  # Python <3.0
+  from cStringIO import StringIO
 
 import svntest
 from svntest import main, verify, tree, wc
 from svntest import Failure
 
+logger = logging.getLogger()
+
+def _log_tree_state(msg, actual, subtree=""):
+  if subtree:
+    subtree += os.sep
+  o = StringIO()
+  o.write(msg + '\n')
+  tree.dump_tree_script(actual, subtree, stream=o)
+  logger.warn(o.getvalue())
+  o.close()
+
 def no_sleep_for_timestamps():
   os.environ['SVN_I_LOVE_CORRUPTED_WORKING_COPIES_SO_DISABLE_SLEEP_FOR_TIMESTAMPS'] = 'yes'
 
@@ -84,9 +101,9 @@ def setup_pristine_greek_repository():
     lastline = output.pop().strip()
     match = re.search("(Committed|Imported) revision [0-9]+.", lastline)
     if not match:
-      print("ERROR:  import did not succeed, while creating greek repos.")
-      print("The final line from 'svn import' was:")
-      print(lastline)
+      logger.error("import did not succeed, while creating greek repos.")
+      logger.error("The final line from 'svn import' was:")
+      logger.error(lastline)
       sys.exit(1)
     output_tree = wc.State.from_commit(output)
 
@@ -117,7 +134,7 @@ def guarantee_empty_repository(path):
   nothing."""
 
   if path == main.pristine_greek_repos_dir:
-    print("ERROR:  attempt to overwrite the pristine repos!  Aborting.")
+    logger.error("attempt to overwrite the pristine repos!  Aborting.")
     sys.exit(1)
 
   # create an empty repository at PATH.
@@ -134,13 +151,13 @@ def guarantee_greek_repository(path, min
   nothing but the greek-tree at revision 1."""
 
   if path == main.pristine_greek_repos_dir:
-    print("ERROR:  attempt to overwrite the pristine repos!  Aborting.")
+    logger.error("attempt to overwrite the pristine repos!  Aborting.")
     sys.exit(1)
 
   # copy the pristine repository to PATH.
   main.safe_rmtree(path)
   if main.copy_repos(main.pristine_greek_repos_dir, path, 1, 1, minor_version):
-    print("ERROR:  copying repository failed.")
+    logger.error("copying repository failed.")
     sys.exit(1)
 
   # make the repos world-writeable, for mod_dav_svn's sake.
@@ -458,8 +475,7 @@ def run_and_verify_checkout2(do_remove,
   try:
     tree.compare_trees("output", actual, output_tree)
   except tree.SVNTreeUnequal:
-    print("ACTUAL OUTPUT TREE:")
-    tree.dump_tree_script(actual, wc_dir_name + os.sep)
+    _log_tree_state("ACTUAL OUTPUT TREE:", actual, wc_dir_name)
     raise
 
   # Create a tree by scanning the working copy
@@ -471,8 +487,7 @@ def run_and_verify_checkout2(do_remove,
                        singleton_handler_a, a_baton,
                        singleton_handler_b, b_baton)
   except tree.SVNTreeUnequal:
-    print("ACTUAL DISK TREE:")
-    tree.dump_tree_script(actual, wc_dir_name + os.sep)
+    _log_tree_state("ACTUAL DISK TREE:", actual, wc_dir_name)
     raise
 
 def run_and_verify_checkout(URL, wc_dir_name, output_tree, disk_tree,
@@ -523,8 +538,7 @@ def run_and_verify_export(URL, export_di
   try:
     tree.compare_trees("output", actual, output_tree)
   except tree.SVNTreeUnequal:
-    print("ACTUAL OUTPUT TREE:")
-    tree.dump_tree_script(actual, export_dir_name + os.sep)
+    _log_tree_state("ACTUAL OUTPUT TREE:", actual, export_dir_name)
     raise
 
   # Create a tree by scanning the working copy.  Don't ignore
@@ -536,8 +550,7 @@ def run_and_verify_export(URL, export_di
   try:
     tree.compare_trees("disk", actual, disk_tree)
   except tree.SVNTreeUnequal:
-    print("ACTUAL DISK TREE:")
-    tree.dump_tree_script(actual, export_dir_name + os.sep)
+    _log_tree_state("ACTUAL DISK TREE:", actual, export_dir_name)
     raise
 
 
@@ -756,8 +769,7 @@ def verify_update(actual_output,
     try:
       tree.compare_trees("output", actual_output, output_tree)
     except tree.SVNTreeUnequal:
-      print("ACTUAL OUTPUT TREE:")
-      tree.dump_tree_script(actual_output, wc_dir_name + os.sep)
+      _log_tree_state("ACTUAL OUTPUT TREE:", actual_output, wc_dir_name)
       raise
 
   # Verify actual mergeinfo recording output against expected output.
@@ -766,9 +778,8 @@ def verify_update(actual_output,
       tree.compare_trees("mergeinfo_output", actual_mergeinfo_output,
                          mergeinfo_output_tree)
     except tree.SVNTreeUnequal:
-      print("ACTUAL MERGEINFO OUTPUT TREE:")
-      tree.dump_tree_script(actual_mergeinfo_output,
-                            wc_dir_name + os.sep)
+      _log_tree_state("ACTUAL MERGEINFO OUTPUT TREE:", actual_mergeinfo_output,
+                      wc_dir_name)
       raise
 
   # Verify actual mergeinfo elision output against expected output.
@@ -777,9 +788,8 @@ def verify_update(actual_output,
       tree.compare_trees("elision_output", actual_elision_output,
                          elision_output_tree)
     except tree.SVNTreeUnequal:
-      print("ACTUAL ELISION OUTPUT TREE:")
-      tree.dump_tree_script(actual_elision_output,
-                            wc_dir_name + os.sep)
+      _log_tree_state("ACTUAL ELISION OUTPUT TREE:", actual_elision_output,
+                      wc_dir_name)
       raise
 
   # Create a tree by scanning the working copy, and verify it
@@ -790,10 +800,8 @@ def verify_update(actual_output,
                          singleton_handler_a, a_baton,
                          singleton_handler_b, b_baton)
     except tree.SVNTreeUnequal:
-      print("EXPECTED DISK TREE:")
-      tree.dump_tree_script(disk_tree)
-      print("ACTUAL DISK TREE:")
-      tree.dump_tree_script(actual_disk)
+      _log_tree_state("EXPECTED DISK TREE:", disk_tree)
+      _log_tree_state("ACTUAL DISK TREE:", actual_disk)
       raise
 
   # Verify via 'status' command too, if possible.
@@ -1041,9 +1049,9 @@ def run_and_verify_merge(dir, rev1, rev2
     try:
       tree.compare_trees("disk", post_disk, pre_disk)
     except tree.SVNTreeError:
-      print("=============================================================")
-      print("Dry-run merge altered working copy")
-      print("=============================================================")
+      logger.warn("=============================================================")
+      logger.warn("Dry-run merge altered working copy")
+      logger.warn("=============================================================")
       raise
 
 
@@ -1107,26 +1115,26 @@ def run_and_verify_merge(dir, rev1, rev2
     out_dry_copy = set(out_dry[:])
 
     if out_copy != out_dry_copy:
-      print("=============================================================")
-      print("Merge outputs differ")
-      print("The dry-run merge output:")
+      logger.warn("=============================================================")
+      logger.warn("Merge outputs differ")
+      logger.warn("The dry-run merge output:")
       for x in out_dry:
-        sys.stdout.write(x)
-      print("The full merge output:")
+        logger.warn(x)
+      logger.warn("The full merge output:")
       for x in out:
-        sys.stdout.write(x)
-      print("=============================================================")
+        logger.warn(x)
+      logger.warn("=============================================================")
       raise main.SVNUnmatchedError
 
   def missing_skip(a, b):
-    print("=============================================================")
-    print("Merge failed to skip: " + a.path)
-    print("=============================================================")
+    logger.warn("=============================================================")
+    logger.warn("Merge failed to skip: %s", a.path)
+    logger.warn("=============================================================")
     raise Failure
   def extra_skip(a, b):
-    print("=============================================================")
-    print("Merge unexpectedly skipped: " + a.path)
-    print("=============================================================")
+    logger.warn("=============================================================")
+    logger.warn("Merge unexpectedly skipped: %s", a.path)
+    logger.warn("=============================================================")
     raise Failure
 
   myskiptree = tree.build_tree_from_skipped(out)
@@ -1136,8 +1144,7 @@ def run_and_verify_merge(dir, rev1, rev2
     tree.compare_trees("skip", myskiptree, skip_tree,
                        extra_skip, None, missing_skip, None)
   except tree.SVNTreeUnequal:
-    print("ACTUAL SKIP TREE:")
-    tree.dump_tree_script(myskiptree, dir + os.sep)
+    _log_tree_state("ACTUAL SKIP TREE:", myskiptree, dir)
     raise
 
   actual_diff = svntest.wc.State.from_checkout(merge_diff_out, False)
@@ -1193,9 +1200,9 @@ def run_and_verify_patch(dir, patch_path
     try:
       tree.compare_trees("disk", post_disk, pre_disk)
     except tree.SVNTreeError:
-      print("=============================================================")
-      print("'svn patch --dry-run' altered working copy")
-      print("=============================================================")
+      logger.warn("=============================================================")
+      logger.warn("'svn patch --dry-run' altered working copy")
+      logger.warn("=============================================================")
       raise
 
   # Update and make a tree of the output.
@@ -1212,9 +1219,9 @@ def run_and_verify_patch(dir, patch_path
     if not match:
       raise main.SVNUnmatchedError
   elif err:
-    print("UNEXPECTED STDERR:")
+    logger.warn("UNEXPECTED STDERR:")
     for x in err:
-      sys.stdout.write(x)
+      logger.warn(x)
     raise verify.SVNUnexpectedStderr
 
   if dry_run and out != out_dry:
@@ -1225,14 +1232,14 @@ def run_and_verify_patch(dir, patch_path
                                      '', out_dry_expected, out_dry)
 
   def missing_skip(a, b):
-    print("=============================================================")
-    print("'svn patch' failed to skip: " + a.path)
-    print("=============================================================")
+    logger.warn("=============================================================")
+    logger.warn("'svn patch' failed to skip: %s", a.path)
+    logger.warn("=============================================================")
     raise Failure
   def extra_skip(a, b):
-    print("=============================================================")
-    print("'svn patch' unexpectedly skipped: " + a.path)
-    print("=============================================================")
+    logger.warn("=============================================================")
+    logger.warn("'svn patch' unexpectedly skipped: %s", a.path)
+    logger.warn("=============================================================")
     raise Failure
 
   myskiptree = tree.build_tree_from_skipped(out)
@@ -1366,9 +1373,9 @@ def process_output_for_commit(output):
     cm = re.compile("(Committed|Imported) revision [0-9]+.")
     match = cm.search(lastline)
     if not match:
-      print("ERROR:  commit did not succeed.")
-      print("The final line from 'svn ci' was:")
-      print(lastline)
+      logger.warn("ERROR:  commit did not succeed.")
+      logger.warn("The final line from 'svn ci' was:")
+      logger.warn(lastline)
       raise main.SVNCommitFailure
 
   # The new 'final' line in the output is either a regular line that
@@ -1438,8 +1445,7 @@ def run_and_verify_commit(wc_dir_name, o
   except tree.SVNTreeError:
       verify.display_trees("Output of commit is unexpected",
                            "OUTPUT TREE", output_tree, actual)
-      print("ACTUAL OUTPUT TREE:")
-      tree.dump_tree_script(actual, wc_dir_name + os.sep)
+      _log_tree_state("ACTUAL OUTPUT TREE:", actual, wc_dir_name)
       raise
 
   # Verify via 'status' command too, if possible.
@@ -1478,8 +1484,7 @@ def run_and_verify_status(wc_dir_name, o
                        singleton_handler_b, b_baton)
   except tree.SVNTreeError:
     verify.display_trees(None, 'STATUS OUTPUT TREE', output_tree, actual)
-    print("ACTUAL STATUS TREE:")
-    tree.dump_tree_script(actual, wc_dir_name + os.sep)
+    _log_tree_state("ACTUAL STATUS TREE:", actual, wc_dir_name)
     raise
 
   # if we have an output State, and we can/are-allowed to create an
@@ -1515,8 +1520,7 @@ def run_and_verify_unquiet_status(wc_dir
   try:
     tree.compare_trees("UNQUIET STATUS", actual, status_tree)
   except tree.SVNTreeError:
-    print("ACTUAL UNQUIET STATUS TREE:")
-    tree.dump_tree_script(actual, wc_dir_name + os.sep)
+    _log_tree_state("ACTUAL UNQUIET STATUS TREE:", actual, wc_dir_name)
     raise
 
 def run_and_verify_status_xml(expected_entries = [],
@@ -1621,7 +1625,7 @@ def run_and_verify_diff_summarize_xml(er
       modified_path = modified_path.replace(os.sep, "/")
 
     if modified_path not in expected_paths:
-      print("ERROR: %s not expected in the changed paths." % modified_path)
+      logger.warn("ERROR: %s not expected in the changed paths.", modified_path)
       raise Failure
 
     index = expected_paths.index(modified_path)
@@ -1633,15 +1637,15 @@ def run_and_verify_diff_summarize_xml(er
     actual_prop = path.getAttribute('props')
 
     if expected_item != actual_item:
-      print("ERROR: expected: %s actual: %s" % (expected_item, actual_item))
+      logger.warn("ERROR: expected: %s actual: %s", expected_item, actual_item)
       raise Failure
 
     if expected_kind != actual_kind:
-      print("ERROR: expected: %s actual: %s" % (expected_kind, actual_kind))
+      logger.warn("ERROR: expected: %s actual: %s", expected_kind, actual_kind)
       raise Failure
 
     if expected_prop != actual_prop:
-      print("ERROR: expected: %s actual: %s" % (expected_prop, actual_prop))
+      logger.warn("ERROR: expected: %s actual: %s", expected_prop, actual_prop)
       raise Failure
 
 def run_and_verify_diff_summarize(output_tree, *args):
@@ -1664,8 +1668,7 @@ def run_and_verify_diff_summarize(output
     tree.compare_trees("output", actual, output_tree)
   except tree.SVNTreeError:
     verify.display_trees(None, 'DIFF OUTPUT TREE', output_tree, actual)
-    print("ACTUAL DIFF OUTPUT TREE:")
-    tree.dump_tree_script(actual)
+    _log_tree_state("ACTUAL DIFF OUTPUT TREE:", actual)
     raise
 
 def run_and_validate_lock(path, username):
@@ -1929,9 +1932,9 @@ def check_prop(name, path, exp_out, revp
                                          '--password', main.wc_passwd,
                                          *revprop_options)
   if out != exp_out:
-    print("svn pg --strict %s output does not match expected." % name)
-    print("Expected standard output:  %s\n" % exp_out)
-    print("Actual standard output:  %s\n" % out)
+    logger.warn("svn pg --strict %s output does not match expected.", name)
+    logger.warn("Expected standard output:  %s\n", exp_out)
+    logger.warn("Actual standard output:  %s\n", out)
     raise Failure
 
 def fill_file_with_lines(wc_path, line_nbr, line_descrip=None,
@@ -2525,8 +2528,8 @@ def deep_trees_run_tests_scheme_for_upda
     try:
       add_deep_trees(sbox, test_case.name)
     except:
-      print("ERROR IN: Tests scheme for update: "
-          + "while setting up deep trees in '%s'" % test_case.name)
+      logger.warn("ERROR IN: Tests scheme for update: "
+          + "while setting up deep trees in '%s'", test_case.name)
       raise
 
 
@@ -2541,8 +2544,8 @@ def deep_trees_run_tests_scheme_for_upda
     try:
       test_case.incoming_action(j(sbox.wc_dir, test_case.name))
     except:
-      print("ERROR IN: Tests scheme for update: "
-          + "while performing incoming action in '%s'" % test_case.name)
+      logger.warn("ERROR IN: Tests scheme for update: "
+          + "while performing incoming action in '%s'", test_case.name)
       raise
 
 
@@ -2562,8 +2565,8 @@ def deep_trees_run_tests_scheme_for_upda
     try:
       test_case.local_action(j(wc_dir, test_case.name))
     except:
-      print("ERROR IN: Tests scheme for update: "
-          + "while performing local action in '%s'" % test_case.name)
+      logger.warn("ERROR IN: Tests scheme for update: "
+          + "while performing local action in '%s'", test_case.name)
       raise
 
 
@@ -2597,8 +2600,8 @@ def deep_trees_run_tests_scheme_for_upda
         run_and_verify_info([x_info[path]], j(base, path))
 
     except:
-      print("ERROR IN: Tests scheme for update: "
-          + "while verifying in '%s'" % test_case.name)
+      logger.warn("ERROR IN: Tests scheme for update: "
+          + "while verifying in '%s'", test_case.name)
       raise
 
 
@@ -2617,8 +2620,8 @@ def deep_trees_run_tests_scheme_for_upda
                             test_case.commit_block_string,
                             base)
     except:
-      print("ERROR IN: Tests scheme for update: "
-          + "while checking commit-blocking in '%s'" % test_case.name)
+      logger.warn("ERROR IN: Tests scheme for update: "
+          + "while checking commit-blocking in '%s'", test_case.name)
       raise
 
 
@@ -2776,8 +2779,8 @@ def deep_trees_run_tests_scheme_for_swit
       make_deep_trees(j(base, "incoming"))
       main.run_svn(None, 'add', base)
     except:
-      print("ERROR IN: Tests scheme for switch: "
-          + "while setting up deep trees in '%s'" % test_case.name)
+      logger.warn("ERROR IN: Tests scheme for switch: "
+          + "while setting up deep trees in '%s'", test_case.name)
       raise
 
 
@@ -2792,8 +2795,8 @@ def deep_trees_run_tests_scheme_for_swit
     try:
       test_case.incoming_action(j(sbox.wc_dir, test_case.name, "incoming"))
     except:
-      print("ERROR IN: Tests scheme for switch: "
-          + "while performing incoming action in '%s'" % test_case.name)
+      logger.warn("ERROR IN: Tests scheme for switch: "
+          + "while performing incoming action in '%s'", test_case.name)
       raise
 
 
@@ -2808,8 +2811,8 @@ def deep_trees_run_tests_scheme_for_swit
     try:
       test_case.local_action(j(sbox.wc_dir, test_case.name, "local"))
     except:
-      print("ERROR IN: Tests scheme for switch: "
-          + "while performing local action in '%s'" % test_case.name)
+      logger.warn("ERROR IN: Tests scheme for switch: "
+          + "while performing local action in '%s'", test_case.name)
       raise
 
 
@@ -2843,8 +2846,8 @@ def deep_trees_run_tests_scheme_for_swit
       for path in x_info:
         run_and_verify_info([x_info[path]], j(local, path))
     except:
-      print("ERROR IN: Tests scheme for switch: "
-          + "while verifying in '%s'" % test_case.name)
+      logger.warn("ERROR IN: Tests scheme for switch: "
+          + "while verifying in '%s'", test_case.name)
       raise
 
 
@@ -2863,8 +2866,8 @@ def deep_trees_run_tests_scheme_for_swit
                             test_case.commit_block_string,
                             local)
     except:
-      print("ERROR IN: Tests scheme for switch: "
-          + "while checking commit-blocking in '%s'" % test_case.name)
+      logger.warn("ERROR IN: Tests scheme for switch: "
+          + "while checking commit-blocking in '%s'", test_case.name)
       raise
 
 
@@ -2938,8 +2941,8 @@ def deep_trees_run_tests_scheme_for_merg
       make_deep_trees(j(base, "incoming"))
       main.run_svn(None, 'add', base)
     except:
-      print("ERROR IN: Tests scheme for merge: "
-          + "while setting up deep trees in '%s'" % test_case.name)
+      logger.warn("ERROR IN: Tests scheme for merge: "
+          + "while setting up deep trees in '%s'", test_case.name)
       raise
 
 
@@ -2958,8 +2961,8 @@ def deep_trees_run_tests_scheme_for_merg
       main.run_svn(None, 'cp', incoming_url, local_url, '-m',
                    'copy incoming to local')
     except:
-      print("ERROR IN: Tests scheme for merge: "
-          + "while copying deep trees in '%s'" % test_case.name)
+      logger.warn("ERROR IN: Tests scheme for merge: "
+          + "while copying deep trees in '%s'", test_case.name)
       raise
 
   # 4) Update to load all of the "/local" subdirs into the working copies.
@@ -2967,7 +2970,7 @@ def deep_trees_run_tests_scheme_for_merg
   try:
     main.run_svn(None, 'up', sbox.wc_dir)
   except:
-    print("ERROR IN: Tests scheme for merge: "
+    logger.warn("ERROR IN: Tests scheme for merge: "
           + "while updating local subdirs")
     raise
 
@@ -2978,8 +2981,8 @@ def deep_trees_run_tests_scheme_for_merg
     try:
       test_case.incoming_action(j(sbox.wc_dir, test_case.name, "incoming"))
     except:
-      print("ERROR IN: Tests scheme for merge: "
-          + "while performing incoming action in '%s'" % test_case.name)
+      logger.warn("ERROR IN: Tests scheme for merge: "
+          + "while performing incoming action in '%s'", test_case.name)
       raise
 
 
@@ -2990,7 +2993,7 @@ def deep_trees_run_tests_scheme_for_merg
       main.run_svn(None, 'ci', '-m', 'Committing incoming actions',
                    sbox.wc_dir)
     except:
-      print("ERROR IN: Tests scheme for merge: "
+      logger.warn("ERROR IN: Tests scheme for merge: "
           + "while committing incoming actions")
       raise
 
@@ -3001,8 +3004,8 @@ def deep_trees_run_tests_scheme_for_merg
     try:
       test_case.local_action(j(sbox.wc_dir, test_case.name, "local"))
     except:
-      print("ERROR IN: Tests scheme for merge: "
-          + "while performing local action in '%s'" % test_case.name)
+      logger.warn("ERROR IN: Tests scheme for merge: "
+          + "while performing local action in '%s'", test_case.name)
       raise
 
 
@@ -3013,7 +3016,7 @@ def deep_trees_run_tests_scheme_for_merg
       main.run_svn(None, 'ci', '-m', 'Committing incoming and local actions',
                    sbox.wc_dir)
     except:
-      print("ERROR IN: Tests scheme for merge: "
+      logger.warn("ERROR IN: Tests scheme for merge: "
           + "while committing incoming and local actions")
       raise
 
@@ -3055,8 +3058,8 @@ def deep_trees_run_tests_scheme_for_merg
                            False, False, *varargs)
       run_and_verify_unquiet_status(local, x_status)
     except:
-      print("ERROR IN: Tests scheme for merge: "
-          + "while verifying in '%s'" % test_case.name)
+      logger.warn("ERROR IN: Tests scheme for merge: "
+          + "while verifying in '%s'", test_case.name)
       raise
 
 
@@ -3076,8 +3079,8 @@ def deep_trees_run_tests_scheme_for_merg
                               test_case.commit_block_string,
                               local)
       except:
-        print("ERROR IN: Tests scheme for merge: "
-            + "while checking commit-blocking in '%s'" % test_case.name)
+        logger.warn("ERROR IN: Tests scheme for merge: "
+            + "while checking commit-blocking in '%s'", test_case.name)
         raise
 
 

Modified: subversion/branches/revprop-packing/subversion/tests/cmdline/svntest/factory.py
URL: http://svn.apache.org/viewvc/subversion/branches/revprop-packing/subversion/tests/cmdline/svntest/factory.py?rev=1307424&r1=1307423&r2=1307424&view=diff
==============================================================================
--- subversion/branches/revprop-packing/subversion/tests/cmdline/svntest/factory.py (original)
+++ subversion/branches/revprop-packing/subversion/tests/cmdline/svntest/factory.py Fri Mar 30 13:55:26 2012
@@ -255,7 +255,7 @@ if sys.version_info[0] >= 3:
   from io import StringIO
 else:
   # Python <3.0
-  from StringIO import StringIO
+  from cStringIO import StringIO
 
 def make(wc_dir, commands, prev_status=None, prev_disk=None, verbose=True):
   """The Factory Invocation Function. This is typically the only one

Modified: subversion/branches/revprop-packing/subversion/tests/cmdline/svntest/main.py
URL: http://svn.apache.org/viewvc/subversion/branches/revprop-packing/subversion/tests/cmdline/svntest/main.py?rev=1307424&r1=1307423&r2=1307424&view=diff
==============================================================================
--- subversion/branches/revprop-packing/subversion/tests/cmdline/svntest/main.py (original)
+++ subversion/branches/revprop-packing/subversion/tests/cmdline/svntest/main.py Fri Mar 30 13:55:26 2012
@@ -23,18 +23,18 @@
 #    under the License.
 ######################################################################
 
-import sys     # for argv[]
+import sys
 import os
-import shutil  # for rmtree()
+import shutil
 import re
-import stat    # for ST_MODE
+import stat
 import subprocess
-import time    # for time()
-import traceback # for print_exc()
+import time
 import threading
-import optparse # for argument parsing
+import optparse
 import xml
 import urllib
+import logging
 
 try:
   # Python >=3.0
@@ -78,6 +78,22 @@ SVN_VER_MINOR = 8
 
 default_num_threads = 5
 
+# This enables both a time stamp prefix on all log lines and a
+# '<TIME = 0.042552>' line after running every external command.
+log_with_timestamps = True
+
+# Set up logging
+logger = logging.getLogger()
+handler = logging.StreamHandler(sys.stdout)
+if log_with_timestamps:
+  formatter = logging.Formatter('%(asctime)s [%(levelname)s] %(message)s',
+                                '%Y-%m-%d %H:%M:%S')
+else:
+  formatter = logging.Formatter('[%(levelname)s] %(message)s')
+handler.setFormatter(formatter)
+logger.addHandler(handler)
+
+
 class SVNProcessTerminatedBySignal(Failure):
   "Exception raised if a spawned process segfaulted, aborted, etc."
   pass
@@ -105,7 +121,7 @@ class SVNRepositoryCreateFailure(Failure
 # Windows specifics
 if sys.platform == 'win32':
   windows = True
-  file_scheme_prefix = 'file:///'
+  file_scheme_prefix = 'file:'
   _exe = '.exe'
   _bat = '.bat'
   os.environ['SVN_DBG_STACKTRACES_TO_STDERR'] = 'y'
@@ -132,23 +148,6 @@ wc_author2 = 'jconstant' # use the same 
 # Set C locale for command line programs
 os.environ['LC_ALL'] = 'C'
 
-# This function mimics the Python 2.3 urllib function of the same name.
-def pathname2url(path):
-  """Convert the pathname PATH from the local syntax for a path to the form
-  used in the path component of a URL. This does not produce a complete URL.
-  The return value will already be quoted using the quote() function."""
-
-  # Don't leave ':' in file://C%3A/ escaped as our canonicalization
-  # rules will replace this with a ':' on input.
-  return urllib_parse_quote(path.replace('\\', '/')).replace('%3A', ':')
-
-# This function mimics the Python 2.3 urllib function of the same name.
-def url2pathname(path):
-  """Convert the path component PATH from an encoded URL to the local syntax
-  for a path. This does not accept a complete URL. This function uses
-  unquote() to decode PATH."""
-  return os.path.normpath(urllib_parse_unquote(path))
-
 ######################################################################
 # The locations of the svn, svnadmin and svnlook binaries, relative to
 # the only scripts that import this file right now (they live in ../).
@@ -444,22 +443,16 @@ def wait_on_pipe(waiter, binary_mode, st
       exit_signal = exit_code
 
     if stdout_lines is not None:
-      sys.stdout.write("".join(stdout_lines))
-      sys.stdout.flush()
+      logger.info("".join(stdout_lines))
     if stderr_lines is not None:
-      sys.stderr.write("".join(stderr_lines))
-      sys.stderr.flush()
-    if options.verbose:
-      # show the whole path to make it easier to start a debugger
-      sys.stderr.write("CMD: %s terminated by signal %d\n"
-                       % (command_string, exit_signal))
-      sys.stderr.flush()
+      logger.warning("".join(stderr_lines))
+    # show the whole path to make it easier to start a debugger
+    logger.warning("CMD: %s terminated by signal %d"
+                     % (command_string, exit_signal))
     raise SVNProcessTerminatedBySignal
   else:
-    if exit_code and options.verbose:
-      sys.stderr.write("CMD: %s exited with %d\n"
-                       % (command_string, exit_code))
-      sys.stderr.flush()
+    if exit_code:
+      logger.info("CMD: %s exited with %d" % (command_string, exit_code))
     return stdout_lines, stderr_lines, exit_code
 
 def spawn_process(command, bufsize=0, binary_mode=0, stdin_lines=None,
@@ -477,10 +470,9 @@ def spawn_process(command, bufsize=0, bi
     raise TypeError("stdin_lines should have list type")
 
   # Log the command line
-  if options.verbose and not command.endswith('.py'):
-    sys.stdout.write('CMD: %s %s\n' % (os.path.basename(command),
-                                      ' '.join([_quote_arg(x) for x in varargs])))
-    sys.stdout.flush()
+  if not command.endswith('.py'):
+    logger.info('CMD: %s %s' % (os.path.basename(command),
+                                  ' '.join([_quote_arg(x) for x in varargs])))
 
   infile, outfile, errfile, kid = open_pipe([command] + list(varargs), bufsize)
 
@@ -511,8 +503,7 @@ def run_command_stdin(command, error_exp
   If ERROR_EXPECTED is None, any stderr output will be printed and any
   stderr output or a non-zero exit code will raise an exception."""
 
-  if options.verbose:
-    start = time.time()
+  start = time.time()
 
   exit_code, stdout_lines, stderr_lines = spawn_process(command,
                                                         bufsize,
@@ -520,18 +511,17 @@ def run_command_stdin(command, error_exp
                                                         stdin_lines,
                                                         *varargs)
 
-  if options.verbose:
+  if log_with_timestamps:
     stop = time.time()
-    print('<TIME = %.6f>' % (stop - start))
-    for x in stdout_lines:
-      sys.stdout.write(x)
-    for x in stderr_lines:
-      sys.stdout.write(x)
+    logger.info('<TIME = %.6f>' % (stop - start))
+  for x in stdout_lines:
+    logger.info(x.rstrip())
+  for x in stderr_lines:
+    logger.info(x.rstrip())
 
   if (not error_expected) and ((stderr_lines) or (exit_code != 0)):
-    if not options.verbose:
-      for x in stderr_lines:
-        sys.stdout.write(x)
+    for x in stderr_lines:
+      logger.warning(x.rstrip())
     raise Failure
 
   return exit_code, \
@@ -875,11 +865,10 @@ def copy_repos(src_path, dst_path, head_
 
   if ignore_uuid:
     load_args = load_args + ['--ignore-uuid']
-  if options.verbose:
-    sys.stdout.write('CMD: %s %s | %s %s\n' %
+
+  logger.info('CMD: %s %s | %s %s' %
                      (os.path.basename(svnadmin_binary), ' '.join(dump_args),
                       os.path.basename(svnadmin_binary), ' '.join(load_args)))
-    sys.stdout.flush()
   start = time.time()
 
   dump_in, dump_out, dump_err, dump_kid = open_pipe(
@@ -888,10 +877,6 @@ def copy_repos(src_path, dst_path, head_
     [svnadmin_binary] + load_args,
     stdin=dump_out) # Attached to dump_kid
 
-  stop = time.time()
-  if options.verbose:
-    print('<TIME = %.6f>' % (stop - start))
-
   load_stdout, load_stderr, load_exit_code = wait_on_pipe(load_kid, True)
   dump_stdout, dump_stderr, dump_exit_code = wait_on_pipe(dump_kid, True)
 
@@ -902,6 +887,10 @@ def copy_repos(src_path, dst_path, head_
   load_out.close()
   load_err.close()
 
+  if log_with_timestamps:
+    stop = time.time()
+    logger.info('<TIME = %.6f>' % (stop - start))
+
   if saved_quiet is None:
     del os.environ['SVN_DBG_QUIET']
   else:
@@ -1147,6 +1136,9 @@ def is_os_darwin():
 def is_fs_case_insensitive():
   return (is_os_darwin() or is_os_windows())
 
+def is_threaded_python():
+  return True
+
 def server_has_mergeinfo():
   return options.server_minor_version >= 5
 
@@ -1206,7 +1198,7 @@ class TestSpawningThread(threading.Threa
       args.append('--fs-type=' + options.fs_type)
     if options.test_area_url:
       args.append('--url=' + options.test_area_url)
-    if options.verbose:
+    if logger.getEffectiveLevel() <= logging.DEBUG:
       args.append('-v')
     if options.cleanup:
       args.append('--cleanup')
@@ -1280,7 +1272,7 @@ class TestRunner:
       # If there is no filter or this test made if through
       # the filter then print it!
       if options.milestone_filter is None or len(issues):
-        if options.verbose and self.pred.inprogress:
+        if self.pred.inprogress:
           tail += " [[%s]]" % self.pred.inprogress
         else:
           print(" %3d    %-5s  %s%s" % (self.index,
@@ -1352,32 +1344,29 @@ class TestRunner:
       result = svntest.testcase.RESULT_SKIP
     except Failure, ex:
       result = svntest.testcase.RESULT_FAIL
+      msg = ''
       # We captured Failure and its subclasses. We don't want to print
       # anything for plain old Failure since that just indicates test
       # failure, rather than relevant information. However, if there
       # *is* information in the exception's arguments, then print it.
       if ex.__class__ != Failure or ex.args:
         ex_args = str(ex)
-        print('CWD: %s' % os.getcwd())
+        logger.warn('CWD: %s' % os.getcwd())
         if ex_args:
-          print('EXCEPTION: %s: %s' % (ex.__class__.__name__, ex_args))
+          msg = 'EXCEPTION: %s: %s' % (ex.__class__.__name__, ex_args)
         else:
-          print('EXCEPTION: %s' % ex.__class__.__name__)
-      traceback.print_exc(file=sys.stdout)
-      sys.stdout.flush()
+          msg = 'EXCEPTION: %s' % ex.__class__.__name__
+      logger.warn(msg, exc_info=True)
     except KeyboardInterrupt:
-      print('Interrupted')
+      logger.error('Interrupted')
       sys.exit(0)
     except SystemExit, ex:
-      print('EXCEPTION: SystemExit(%d), skipping cleanup' % ex.code)
+      logger.error('EXCEPTION: SystemExit(%d), skipping cleanup' % ex.code)
       self._print_name(ex.code and 'FAIL: ' or 'PASS: ')
       raise
     except:
       result = svntest.testcase.RESULT_FAIL
-      print('CWD: %s' % os.getcwd())
-      print('UNEXPECTED EXCEPTION:')
-      traceback.print_exc(file=sys.stdout)
-      sys.stdout.flush()
+      logger.warn('CWD: %s' % os.getcwd(), exc_info=True)
 
     os.chdir(saved_dir)
     exit_code, result_text, result_benignity = self.pred.results(result)
@@ -1495,6 +1484,12 @@ def create_default_options():
 
 def _create_parser():
   """Return a parser for our test suite."""
+  def set_log_level(option, opt, value, parser, level=None):
+    if level:
+      logger.setLevel(level)
+    else:
+      logger.setLevel(value)
+
   # set up the parser
   _default_http_library = 'serf'
   usage = 'usage: %prog [options] [<test> ...]'
@@ -1503,8 +1498,10 @@ def _create_parser():
                     help='Print test doc strings instead of running them')
   parser.add_option('--milestone-filter', action='store', dest='milestone_filter',
                     help='Limit --list to those with target milestone specified')
-  parser.add_option('-v', '--verbose', action='store_true', dest='verbose',
-                    help='Print binary command-lines (not with --quiet)')
+  parser.add_option('-v', '--verbose', action='callback',
+                    callback=set_log_level, callback_args=(logging.DEBUG, ),
+                    help='Print binary command-lines (same as ' +
+                         '"--set-log-level logging.DEBUG")')
   parser.add_option('-q', '--quiet', action='store_true',
                     help='Print only unexpected results (not with --verbose)')
   parser.add_option('-p', '--parallel', action='store_const',
@@ -1542,6 +1539,8 @@ def _create_parser():
                     help='Default shard size (for fsfs)')
   parser.add_option('--config-file', action='store',
                     help="Configuration file for tests.")
+  parser.add_option('--set-log-level', action='callback', type='str',
+                    callback=set_log_level)
   parser.add_option('--keep-local-tmp', action='store_true',
                     help="Don't remove svn-test-work/local_tmp after test " +
                          "run is complete.  Useful for debugging failures.")
@@ -1556,7 +1555,8 @@ def _create_parser():
   # most of the defaults are None, but some are other values, set them here
   parser.set_defaults(
         server_minor_version=SVN_VER_MINOR,
-        url=file_scheme_prefix + pathname2url(os.path.abspath(os.getcwd())),
+        url=file_scheme_prefix + \
+                        urllib.pathname2url(os.path.abspath(os.getcwd())),
         http_library=_default_http_library)
 
   return parser
@@ -1572,8 +1572,6 @@ def _parse_options(arglist=sys.argv[1:])
   (options, args) = parser.parse_args(arglist)
 
   # some sanity checking
-  if options.verbose and options.quiet:
-    parser.error("'verbose' and 'quiet' are incompatible")
   if options.fsfs_packing and not options.fsfs_sharding:
     parser.error("--fsfs-packing requires --fsfs-sharding")
 
@@ -1724,7 +1722,8 @@ def execute_tests(test_list, serial_only
                    "or function '%s'\n" % arg)
 
   # Calculate pristine_greek_repos_url from test_area_url.
-  pristine_greek_repos_url = options.test_area_url + '/' + pathname2url(pristine_greek_repos_dir)
+  pristine_greek_repos_url = options.test_area_url + '/' + \
+                                urllib.pathname2url(pristine_greek_repos_dir)
 
   if options.use_jsvn:
     if options.svn_bin is None:

Modified: subversion/branches/revprop-packing/subversion/tests/cmdline/svntest/sandbox.py
URL: http://svn.apache.org/viewvc/subversion/branches/revprop-packing/subversion/tests/cmdline/svntest/sandbox.py?rev=1307424&r1=1307423&r2=1307424&view=diff
==============================================================================
--- subversion/branches/revprop-packing/subversion/tests/cmdline/svntest/sandbox.py (original)
+++ subversion/branches/revprop-packing/subversion/tests/cmdline/svntest/sandbox.py Fri Mar 30 13:55:26 2012
@@ -24,9 +24,13 @@
 import os
 import shutil
 import copy
+import urllib
+import logging
 
 import svntest
 
+logger = logging.getLogger()
+
 
 class Sandbox:
   """Manages a sandbox (one or more repository/working copy pairs) for
@@ -49,7 +53,7 @@ class Sandbox:
     if not read_only:
       self.repo_dir = os.path.join(svntest.main.general_repo_dir, self.name)
       self.repo_url = (svntest.main.options.test_area_url + '/'
-                       + svntest.main.pathname2url(self.repo_dir))
+                       + urllib.pathname2url(self.repo_dir))
     else:
       self.repo_dir = svntest.main.pristine_greek_repos_dir
       self.repo_url = svntest.main.pristine_greek_repos_url
@@ -126,7 +130,7 @@ class Sandbox:
     path = (os.path.join(svntest.main.general_repo_dir, self.name)
             + '.' + suffix)
     url = svntest.main.options.test_area_url + \
-                                        '/' + svntest.main.pathname2url(path)
+                                        '/' + urllib.pathname2url(path)
     self.add_test_path(path, remove)
     return path, url
 
@@ -147,7 +151,7 @@ class Sandbox:
     """Get a stable name for a temporary file that will be removed after
        running the test"""
 
-    dir = self.add_wc_path('tmp')
+    dir = self.add_wc_path('tmp', remove=False)
     if not os.path.exists(dir):
       os.mkdir(dir)
 
@@ -196,17 +200,18 @@ class Sandbox:
                                   temporary and 'TEMP' or 'PERM',
                                   parts[1])
 
-  def simple_update(self, target=None):
+  def simple_update(self, target=None, revision='HEAD'):
     """Update the WC or TARGET.
        TARGET is a relpath relative to the WC."""
     if target is None:
       target = self.wc_dir
     else:
       target = self.ospath(target)
-    svntest.main.run_svn(False, 'update', target)
+    svntest.main.run_svn(False, 'update', target, '-r', revision)
 
   def simple_switch(self, url, target=None):
-    """Switch a TARGET to URL"""
+    """Switch the WC or TARGET to URL.
+       TARGET is a relpath relative to the WC."""
     if target is None:
       target = self.wc_dir
     else:
@@ -228,61 +233,72 @@ class Sandbox:
                          target)
 
   def simple_rm(self, *targets):
-    """TARGET is a relpath relative to the WC."""
+    """Schedule TARGETS for deletion.
+       TARGETS are relpaths relative to the WC."""
     assert len(targets) > 0
     targets = self.ospaths(targets)
     svntest.main.run_svn(False, 'rm', *targets)
 
   def simple_mkdir(self, *targets):
-    """TARGET is a relpath relative to the WC."""
+    """Create TARGETS as directories scheduled for addition.
+       TARGETS are relpaths relative to the WC."""
     assert len(targets) > 0
     targets = self.ospaths(targets)
     svntest.main.run_svn(False, 'mkdir', *targets)
 
   def simple_add(self, *targets):
-    """TARGET is a relpath relative to the WC."""
+    """Schedule TARGETS for addition.
+       TARGETS are relpaths relative to the WC."""
     assert len(targets) > 0
     targets = self.ospaths(targets)
     svntest.main.run_svn(False, 'add', *targets)
 
   def simple_revert(self, *targets):
-    """TARGET is a relpath relative to the WC."""
+    """Revert TARGETS.
+       TARGETS are relpaths relative to the WC."""
     assert len(targets) > 0
     targets = self.ospaths(targets)
     svntest.main.run_svn(False, 'revert', *targets)
 
   def simple_propset(self, name, value, *targets):
-    """TARGET is a relpath relative to the WC."""
+    """Set property NAME to VALUE on TARGETS.
+       TARGETS are relpaths relative to the WC."""
     assert len(targets) > 0
     targets = self.ospaths(targets)
     svntest.main.run_svn(False, 'propset', name, value, *targets)
 
   def simple_propdel(self, name, *targets):
-    """TARGET is a relpath relative to the WC."""
+    """Delete property NAME from TARGETS.
+       TARGETS are relpaths relative to the WC."""
     assert len(targets) > 0
     targets = self.ospaths(targets)
     svntest.main.run_svn(False, 'propdel', name, *targets)
 
   def simple_copy(self, source, dest):
-    """SOURCE and DEST are relpaths relative to the WC."""
+    """Copy SOURCE to DEST in the WC.
+       SOURCE and DEST are relpaths relative to the WC."""
     source = self.ospath(source)
     dest = self.ospath(dest)
     svntest.main.run_svn(False, 'copy', source, dest)
 
   def simple_move(self, source, dest):
-    """SOURCE and DEST are relpaths relative to the WC."""
+    """Move SOURCE to DEST in the WC.
+       SOURCE and DEST are relpaths relative to the WC."""
     source = self.ospath(source)
     dest = self.ospath(dest)
     svntest.main.run_svn(False, 'move', source, dest)
 
   def simple_repo_copy(self, source, dest):
-    """SOURCE and DEST are relpaths relative to the repo root."""
+    """Copy SOURCE to DEST in the repository, committing the result with a
+       default log message.
+       SOURCE and DEST are relpaths relative to the repo root."""
     svntest.main.run_svn(False, 'copy', '-m', svntest.main.make_log_msg(),
                          self.repo_url + '/' + source,
                          self.repo_url + '/' + dest)
 
   def simple_append(self, dest, contents, truncate=False):
-    """Append CONTENTS to file DEST, optionally truncating it first."""
+    """Append CONTENTS to file DEST, optionally truncating it first.
+       DEST is a relpath relative to the WC."""
     open(self.ospath(dest), truncate and 'w' or 'a').write(contents)
 
 
@@ -306,14 +322,13 @@ def cleanup_deferred_test_paths():
 
 
 def _cleanup_test_path(path, retrying=False):
-  if svntest.main.options.verbose:
-    if retrying:
-      print("CLEANUP: RETRY: %s" % path)
-    else:
-      print("CLEANUP: %s" % path)
+  if retrying:
+    logger.info("CLEANUP: RETRY: %s", path)
+  else:
+    logger.info("CLEANUP: %s", path)
+
   try:
     svntest.main.safe_rmtree(path)
   except:
-    if svntest.main.options.verbose:
-      print("WARNING: cleanup failed, will try again later")
+    logger.info("WARNING: cleanup failed, will try again later")
     _deferred_test_paths.append(path)

Modified: subversion/branches/revprop-packing/subversion/tests/cmdline/svntest/tree.py
URL: http://svn.apache.org/viewvc/subversion/branches/revprop-packing/subversion/tests/cmdline/svntest/tree.py?rev=1307424&r1=1307423&r2=1307424&view=diff
==============================================================================
--- subversion/branches/revprop-packing/subversion/tests/cmdline/svntest/tree.py (original)
+++ subversion/branches/revprop-packing/subversion/tests/cmdline/svntest/tree.py Fri Mar 30 13:55:26 2012
@@ -31,12 +31,15 @@ if sys.version_info[0] >= 3:
   from io import StringIO
 else:
   # Python <3.0
-  from StringIO import StringIO
+  from cStringIO import StringIO
 from xml.dom.minidom import parseString
 import base64
+import logging
 
 import svntest
 
+logger = logging.getLogger()
+
 # Tree Exceptions.
 
 # All tree exceptions should inherit from SVNTreeError
@@ -569,7 +572,7 @@ def get_child(node, name):
   """If SVNTreeNode NODE contains a child named NAME, return child;
   else, return None. If SVNTreeNode is not a directory, exit completely."""
   if node.children == None:
-    print("Error: Foolish call to get_child.")
+    logger.error("Foolish call to get_child.")
     sys.exit(1)
   for n in node.children:
     if name == n.name:
@@ -581,8 +584,8 @@ def get_child(node, name):
 def default_singleton_handler(node, description):
   """Print SVNTreeNode NODE's name, describing it with the string
   DESCRIPTION, then raise SVNTreeUnequal."""
-  print("Couldn't find node '%s' in %s tree" % (node.name, description))
-  node.pprint()
+  logger.warn("Couldn't find node '%s' in %s tree" % (node.name, description))
+  logger.warn(str(node))
   raise SVNTreeUnequal
 
 # A test helper function implementing the singleton_handler_a API.
@@ -599,8 +602,8 @@ def detect_conflict_files(node, extra_fi
       break
   else:
     msg = "Encountered unexpected disk path '" + node.name + "'"
-    print(msg)
-    node.pprint()
+    logger.warn(msg)
+    logger.warn(str(node))
     raise SVNTreeUnequal(msg)
 
 ###########################################################################
@@ -634,17 +637,20 @@ def compare_trees(label,
 
   def display_nodes(a, b):
     'Display two nodes, expected and actual.'
-    print("=============================================================")
-    print("Expected '%s' and actual '%s' in %s tree are different!"
-          % (b.name, a.name, label))
-    print("=============================================================")
-    print("EXPECTED NODE TO BE:")
-    print("=============================================================")
-    b.pprint()
-    print("=============================================================")
-    print("ACTUAL NODE FOUND:")
-    print("=============================================================")
-    a.pprint()
+    o = StringIO()
+    o.write("=============================================================\n")
+    o.write("Expected '%s' and actual '%s' in %s tree are different!\n"
+                % (b.name, a.name, label))
+    o.write("=============================================================\n")
+    o.write("EXPECTED NODE TO BE:\n")
+    o.write("=============================================================\n")
+    b.pprint(o)
+    o.write("=============================================================\n")
+    o.write("ACTUAL NODE FOUND:\n")
+    o.write("=============================================================\n")
+    a.pprint(o)
+    logger.warn(o.getvalue())
+    o.close()
 
   # Setup singleton handlers
   if singleton_handler_a is None:
@@ -690,21 +696,21 @@ def compare_trees(label,
         if b_child not in accounted_for:
           singleton_handler_b(b_child, b_baton)
   except SVNTypeMismatch:
-    print('Unequal Types: one Node is a file, the other is a directory')
+    logger.warn('Unequal Types: one Node is a file, the other is a directory')
     raise SVNTreeUnequal
   except IndexError:
-    print("Error: unequal number of children")
+    logger.warn("Error: unequal number of children")
     raise SVNTreeUnequal
   except SVNTreeUnequal:
     if a.name != root_node_name:
-      print("Unequal at node %s" % a.name)
+      logger.warn("Unequal at node %s" % a.name)
     raise
 
 
 
 # Visually show a tree's structure
 
-def dump_tree(n,indent=""):
+def _dump_tree(n,indent="",stream=sys.stdout):
   """Print out a nice representation of the structure of the tree in
   the SVNTreeNode N. Prefix each line with the string INDENT."""
 
@@ -712,18 +718,25 @@ def dump_tree(n,indent=""):
   tmp_children = sorted(n.children or [])
 
   if n.name == root_node_name:
-    print("%s%s" % (indent, "ROOT"))
+    stream.write("%s%s\n" % (indent, "ROOT"))
   else:
-    print("%s%s" % (indent, n.name))
+    stream.write("%s%s\n" % (indent, n.name))
 
   indent = indent.replace("-", " ")
   indent = indent.replace("+", " ")
   for i in range(len(tmp_children)):
     c = tmp_children[i]
     if i == len(tmp_children)-1:
-      dump_tree(c,indent + "  +-- ")
+      _dump_tree(c,indent + "  +-- ",stream)
     else:
-      dump_tree(c,indent + "  |-- ")
+      _dump_tree(c,indent + "  |-- ",stream)
+
+
+def dump_tree(n):
+    output = StringIO()
+    _dump_tree(n,stream=output)
+    logger.warn(output.getvalue())
+    output.close()
 
 
 def dump_tree_script__crawler(n, subtree="", stream=sys.stdout):

Modified: subversion/branches/revprop-packing/subversion/tests/cmdline/svntest/verify.py
URL: http://svn.apache.org/viewvc/subversion/branches/revprop-packing/subversion/tests/cmdline/svntest/verify.py?rev=1307424&r1=1307423&r2=1307424&view=diff
==============================================================================
--- subversion/branches/revprop-packing/subversion/tests/cmdline/svntest/verify.py (original)
+++ subversion/branches/revprop-packing/subversion/tests/cmdline/svntest/verify.py Fri Mar 30 13:55:26 2012
@@ -27,9 +27,12 @@
 import re, sys
 from difflib import unified_diff, ndiff
 import pprint
+import logging
 
 import svntest
 
+logger = logging.getLogger()
+
 
 ######################################################################
 # Exception types
@@ -230,7 +233,7 @@ class AnyOutput(ExpectedOutput):
 
   def display_differences(self, message, label, actual):
     if message:
-      print(message)
+      logger.warn(message)
 
 
 class RegexOutput(ExpectedOutput):
@@ -296,12 +299,12 @@ class UnorderedRegexOutput(UnorderedOutp
 def display_trees(message, label, expected, actual):
   'Print two trees, expected and actual.'
   if message is not None:
-    print(message)
+    logger.warn(message)
   if expected is not None:
-    print('EXPECTED %s:' % label)
+    logger.warn('EXPECTED %s:', label)
     svntest.tree.dump_tree(expected)
   if actual is not None:
-    print('ACTUAL %s:' % label)
+    logger.warn('ACTUAL %s:', label)
     svntest.tree.dump_tree(actual)
 
 
@@ -311,7 +314,7 @@ def display_lines(message, label, expect
   with LABEL) followed by ACTUAL (also labeled with LABEL).
   Both EXPECTED and ACTUAL may be strings or lists of strings."""
   if message is not None:
-    print(message)
+    logger.warn(message)
   if expected is not None:
     output = 'EXPECTED %s' % label
     if expected_is_regexp:
@@ -320,17 +323,17 @@ def display_lines(message, label, expect
     if expected_is_unordered:
       output += ' (unordered)'
     output += ':'
-    print(output)
+    logger.warn(output)
     for x in expected:
       sys.stdout.write(x)
   if actual is not None:
-    print('ACTUAL %s:' % label)
+    logger.warn('ACTUAL %s:', label)
     for x in actual:
       sys.stdout.write(x)
 
   # Additionally print unified diff
   if not expected_is_regexp:
-    print('DIFF ' + ' '.join(output.split(' ')[1:]))
+    logger.warn('DIFF ' + ' '.join(output.split(' ')[1:]))
 
     if type(expected) is str:
       expected = [expected]

Modified: subversion/branches/revprop-packing/subversion/tests/cmdline/svntest/wc.py
URL: http://svn.apache.org/viewvc/subversion/branches/revprop-packing/subversion/tests/cmdline/svntest/wc.py?rev=1307424&r1=1307423&r2=1307424&view=diff
==============================================================================
--- subversion/branches/revprop-packing/subversion/tests/cmdline/svntest/wc.py (original)
+++ subversion/branches/revprop-packing/subversion/tests/cmdline/svntest/wc.py Fri Mar 30 13:55:26 2012
@@ -27,9 +27,20 @@ import os
 import sys
 import re
 import urllib
+import logging
+import pprint
+
+if sys.version_info[0] >= 3:
+  # Python >=3.0
+  from io import StringIO
+else:
+  # Python <3.0
+  from cStringIO import StringIO
 
 import svntest
 
+logger = logging.getLogger()
+
 
 #
 # 'status -v' output looks like this:
@@ -362,9 +373,8 @@ class State:
     if 0:
       check = tree.as_state()
       if self != check:
-        import pprint
-        pprint.pprint(self.desc)
-        pprint.pprint(check.desc)
+        logger.warn(pprint.pformat(self.desc))
+        logger.warn(pprint.pformat(check.desc))
         # STATE -> TREE -> STATE is lossy.
         # In many cases, TREE -> STATE -> TREE is not.
         # Even though our conversion from a TREE has lost some information, we
@@ -894,21 +904,29 @@ def display_nodes(label, path, expected,
   'Display two nodes, expected and actual.'
   expected = item_to_node(path, expected)
   actual = item_to_node(path, actual)
-  print("=============================================================")
-  print("Expected '%s' and actual '%s' in %s tree are different!"
-        % (expected.name, actual.name, label))
-  print("=============================================================")
-  print("EXPECTED NODE TO BE:")
-  print("=============================================================")
-  expected.pprint()
-  print("=============================================================")
-  print("ACTUAL NODE FOUND:")
-  print("=============================================================")
-  actual.pprint()
+
+  o = StringIO()
+  o.write("=============================================================\n")
+  o.write("Expected '%s' and actual '%s' in %s tree are different!\n"
+                % (expected.name, actual.name, label))
+  o.write("=============================================================\n")
+  o.write("EXPECTED NODE TO BE:\n")
+  o.write("=============================================================\n")
+  expected.pprint(o)
+  o.write("=============================================================\n")
+  o.write("ACTUAL NODE FOUND:\n")
+  o.write("=============================================================\n")
+  actual.pprint(o)
+
+  logger.warn(o.getvalue())
+  o.close()
 
 ### yanked from tree.py
 def default_singleton_handler(description, path, item):
   node = item_to_node(path, item)
-  print("Couldn't find node '%s' in %s tree" % (node.name, description))
-  node.pprint()
+  logger.warn("Couldn't find node '%s' in %s tree" % (node.name, description))
+  o = StringIO()
+  node.pprint(o)
+  logger.warn(o.getvalue())
+  o.close()
   raise svntest.tree.SVNTreeUnequal

Modified: subversion/branches/revprop-packing/subversion/tests/cmdline/tree_conflict_tests.py
URL: http://svn.apache.org/viewvc/subversion/branches/revprop-packing/subversion/tests/cmdline/tree_conflict_tests.py?rev=1307424&r1=1307423&r2=1307424&view=diff
==============================================================================
--- subversion/branches/revprop-packing/subversion/tests/cmdline/tree_conflict_tests.py (original)
+++ subversion/branches/revprop-packing/subversion/tests/cmdline/tree_conflict_tests.py Fri Mar 30 13:55:26 2012
@@ -38,6 +38,7 @@ from svntest.actions import run_and_veri
 from svntest.actions import run_and_verify_info
 from svntest.actions import get_virginal_state
 import shutil
+import logging
 
 # (abbreviation)
 Skip = svntest.testcase.Skip_deco
@@ -49,16 +50,7 @@ Wimp = svntest.testcase.Wimp_deco
 Item = svntest.wc.StateItem
 AnyOutput = svntest.verify.AnyOutput
 
-# If verbose mode is enabled, print the LINE and a newline.
-def verbose_print(line):
-  if main.options.verbose:
-    print(line)
-
-# If verbose mode is enabled, print the (assumed newline-terminated) LINES.
-def verbose_printlines(lines):
-  if main.options.verbose:
-    for line in lines:
-      sys.stdout.write(line)
+logger = logging.getLogger()
 
 ######################################################################
 # Tests
@@ -388,14 +380,14 @@ def ensure_tree_conflict(sbox, operation
   def url_of(repo_relative_path):
     return sbox.repo_url + '/' + repo_relative_path
 
-  verbose_print("")
-  verbose_print("=== Starting a set of '" + operation + "' tests.")
+  logger.debug("")
+  logger.debug("=== Starting a set of '" + operation + "' tests.")
 
   # Path to source branch, relative to wc_dir.
   # Source is where the "incoming" mods are made.
   source_br = "branch1"
 
-  verbose_print("--- Creating changes in repos")
+  logger.debug("--- Creating changes in repos")
   source_wc_dir = os.path.join(wc_dir, source_br)
   source_left_rev, source_right_rev = set_up_repos(wc_dir, source_wc_dir,
                                                    incoming_scenarios)
@@ -430,9 +422,9 @@ def ensure_tree_conflict(sbox, operation
       source_url = url_of(source_br + '/' + scen_name)
       target_path = os.path.join(target_br, scen_name)
 
-      verbose_print("=== " + str(inc_action) + " onto " + str(loc_action))
+      logger.debug("=== " + str(inc_action) + " onto " + str(loc_action))
 
-      verbose_print("--- Making local mods")
+      logger.debug("--- Making local mods")
       for modaction in loc_action:
         modify(modaction, localmod_paths(".", target_path), is_init=False)
       if commit_local_mods:
@@ -444,7 +436,7 @@ def ensure_tree_conflict(sbox, operation
       # For update, verify the pre-condition that WC is out of date.
       # For switch/merge, there is no such precondition.
       if operation == 'update':
-        verbose_print("--- Trying to commit (expecting 'out-of-date' error)")
+        logger.debug("--- Trying to commit (expecting 'out-of-date' error)")
         run_and_verify_commit(".", None, None, "Commit failed",
                               target_path)
 
@@ -462,15 +454,15 @@ def ensure_tree_conflict(sbox, operation
                                                       match_all=False)
       # Do the main action
       if operation == 'update':
-        verbose_print("--- Updating")
+        logger.debug("--- Updating")
         run_and_verify_svn(None, expected_stdout, [],
                            'update', target_path)
       elif operation == 'switch':
-        verbose_print("--- Switching")
+        logger.debug("--- Switching")
         run_and_verify_svn(None, expected_stdout, [],
                            'switch', source_url, target_path)
       elif operation == 'merge':
-        verbose_print("--- Merging")
+        logger.debug("--- Merging")
         run_and_verify_svn(None, expected_stdout, [],
                            'merge', '--ignore-ancestry',
                            '--allow-mixed-revisions',
@@ -479,7 +471,7 @@ def ensure_tree_conflict(sbox, operation
       else:
         raise Exception("unknown operation: '" + operation + "'")
 
-      verbose_print("--- Checking that 'info' reports the conflict")
+      logger.debug("--- Checking that 'info' reports the conflict")
       if operation == 'update' or operation == 'switch':
         incoming_left_rev = target_start_rev
       else:
@@ -495,39 +487,39 @@ def ensure_tree_conflict(sbox, operation
             re.escape(victim_name + '@' + str(incoming_right_rev)) + r')' }
       run_and_verify_info([expected_info], victim_path)
 
-      verbose_print("--- Trying to commit (expecting 'conflict' error)")
+      logger.debug("--- Trying to commit (expecting 'conflict' error)")
       ### run_and_verify_commit() requires an "output_tree" argument, but
       #   here we get away with passing None because we know an implementation
       #   detail: namely that it's not going to look at that argument if it
       #   gets the stderr that we're expecting.
       run_and_verify_commit(".", None, None, ".*conflict.*", victim_path)
 
-      verbose_print("--- Checking that 'status' reports the conflict")
+      logger.debug("--- Checking that 'status' reports the conflict")
       expected_stdout = svntest.verify.RegexOutput("^......C.* " +
                                                    re.escape(victim_path) + "$",
                                                    match_all=False)
       run_and_verify_svn(None, expected_stdout, [],
                          'status', victim_path)
 
-      verbose_print("--- Resolving the conflict")
+      logger.debug("--- Resolving the conflict")
       # Make sure resolving the parent does nothing.
       run_and_verify_resolved([], os.path.dirname(victim_path))
       # The real resolved call.
       run_and_verify_resolved([victim_path])
 
-      verbose_print("--- Checking that 'status' does not report a conflict")
+      logger.debug("--- Checking that 'status' does not report a conflict")
       exitcode, stdout, stderr = run_and_verify_svn(None, None, [],
                                                 'status', victim_path)
       for line in stdout:
         if line[6] == 'C': # and line.endswith(victim_path + '\n'):
           raise svntest.Failure("unexpected status C") # on victim_path
 
-      # verbose_print("--- Committing (should now succeed)")
+      # logger.debug("--- Committing (should now succeed)")
       # run_and_verify_svn(None, None, [],
       #                    'commit', '-m', '', target_path)
       # target_start_rev += 1
 
-      verbose_print("")
+      logger.debug("")
 
     os.chdir(saved_cwd)
 
@@ -1224,7 +1216,7 @@ def actual_only_node_behaviour(sbox):
                      "export", foo_path, sbox.get_tempname())
   # import
   expected_stdout = None
-  expected_stderr = ".*foo.*does not exist.*"
+  expected_stderr = ".*(foo.*does not exist|Can't stat.*foo).*"
   run_and_verify_svn(None, expected_stdout, expected_stderr,
                      "import", '-m', svntest.main.make_log_msg(),
                      foo_path, sbox.repo_url + '/foo_imported')

Modified: subversion/branches/revprop-packing/subversion/tests/cmdline/update_tests.py
URL: http://svn.apache.org/viewvc/subversion/branches/revprop-packing/subversion/tests/cmdline/update_tests.py?rev=1307424&r1=1307423&r2=1307424&view=diff
==============================================================================
--- subversion/branches/revprop-packing/subversion/tests/cmdline/update_tests.py (original)
+++ subversion/branches/revprop-packing/subversion/tests/cmdline/update_tests.py Fri Mar 30 13:55:26 2012
@@ -5696,6 +5696,101 @@ def update_moved_dir_file_move(sbox):
                                         None, None, None,
                                         None, None, 1)
 
+@XFail()
+def update_move_text_mod(sbox):
+  "text mod to moved files"
+
+  sbox.build()
+  wc_dir = sbox.wc_dir
+  svntest.main.file_append(sbox.ospath('A/B/lambda'), "modified\n")
+  svntest.main.file_append(sbox.ospath('A/B/E/beta'), "modified\n")
+  sbox.simple_commit()
+  sbox.simple_update(revision=1)
+
+  sbox.simple_move("A/B/E", "A/E2")
+  sbox.simple_move("A/B/lambda", "A/lambda2")
+
+  expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
+  expected_status.tweak('A/B/E', 'A/B/E/alpha', 'A/B/E/beta', 'A/B/lambda',
+                        status='D ')
+  expected_status.add({
+      'A/E2'        : Item(status='A ', copied='+', wc_rev='-'),
+      'A/E2/alpha'  : Item(status='  ', copied='+', wc_rev='-'),
+      'A/E2/beta'   : Item(status='  ', copied='+', wc_rev='-'),
+      'A/lambda2'   : Item(status='A ', copied='+', wc_rev='-'),
+      })
+
+  svntest.actions.run_and_verify_status(wc_dir, expected_status)
+
+  expected_output = svntest.wc.State(wc_dir, {
+    'A/lambda2' : Item(status='U '),
+    'A/E2/beta' : Item(status='U '),
+  })
+  expected_disk = svntest.main.greek_state.copy()
+  expected_disk.remove('A/B/E/alpha', 'A/B/E/beta', 'A/B/E', 'A/B/lambda')
+  expected_disk.add({
+    'A/E2'        : Item(),
+    'A/E2/alpha'  : Item(contents="This is the file 'alpha'.\n"),
+    'A/E2/beta'   : Item(contents="This is the file 'beta'.\nmodified\n"),
+    'A/lambda2'   : Item(contents="This is the file 'lambda'.\nmodified\n"),
+  })
+  expected_status.tweak(wc_rev=2)
+  expected_status.tweak('A/E2', 'A/E2/alpha', 'A/E2/beta', 'A/lambda2',
+                        wc_rev='-')
+  ### XFAIL 'A/E2/beta' is status R but should be ' '
+  svntest.actions.run_and_verify_update(wc_dir,
+                                        expected_output,
+                                        expected_disk,
+                                        expected_status,
+                                        None, None, None,
+                                        None, None, 1)
+
+@XFail()
+def update_nested_move_text_mod(sbox):
+  "text mod to moved file in moved dir"
+
+  sbox.build()
+  wc_dir = sbox.wc_dir
+  svntest.main.file_append(sbox.ospath('A/B/E/alpha'), "modified\n")
+  sbox.simple_commit()
+  sbox.simple_update(revision=1)
+
+  sbox.simple_move("A/B/E", "A/E2")
+  sbox.simple_move("A/E2/alpha", "A/alpha2")
+
+  expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
+  expected_status.tweak('A/B/E', 'A/B/E/alpha', 'A/B/E/beta', status='D ')
+  expected_status.add({
+      'A/E2'        : Item(status='A ', copied='+', wc_rev='-'),
+      'A/E2/alpha'  : Item(status='D ', copied='+', wc_rev='-'),
+      'A/E2/beta'   : Item(status='  ', copied='+', wc_rev='-'),
+      'A/alpha2'    : Item(status='A ', copied='+', wc_rev='-'),
+      })
+
+  svntest.actions.run_and_verify_status(wc_dir, expected_status)
+
+  expected_output = svntest.wc.State(wc_dir, {
+    'A/alpha2' : Item(status='U '),
+  })
+  expected_disk = svntest.main.greek_state.copy()
+  expected_disk.remove('A/B/E/alpha', 'A/B/E/beta', 'A/B/E')
+  expected_disk.add({
+    'A/E2'        : Item(),
+    'A/E2/beta'   : Item(contents="This is the file 'beta'.\n"),
+    'A/alpha2'    : Item(contents="This is the file 'alpha'.\nmodified\n"),
+  })
+  expected_status.tweak(wc_rev=2)
+  expected_status.tweak('A/E2', 'A/E2/alpha', 'A/E2/beta', 'A/alpha2',
+                        wc_rev='-')
+  ### XFAIL update fails 'No such file'
+  svntest.actions.run_and_verify_update(wc_dir,
+                                        expected_output,
+                                        expected_disk,
+                                        expected_status,
+                                        None, None, None,
+                                        None, None, 1)
+
+
 #######################################################################
 # Run the tests
 
@@ -5768,6 +5863,8 @@ test_list = [ None,
               update_moved_dir_dir_add,
               update_moved_dir_file_move,
               update_binary_file_3,
+              update_move_text_mod,
+              update_nested_move_text_mod,
              ]
 
 if __name__ == '__main__':

Propchange: subversion/branches/revprop-packing/subversion/tests/libsvn_client/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Fri Mar 30 13:55:26 2012
@@ -4,3 +4,4 @@ client-test
 test-patch*
 test-wc*
 test-copy-crash
+test-youngest-common-ancestor

Modified: subversion/branches/revprop-packing/subversion/tests/libsvn_client/client-test.c
URL: http://svn.apache.org/viewvc/subversion/branches/revprop-packing/subversion/tests/libsvn_client/client-test.c?rev=1307424&r1=1307423&r2=1307424&view=diff
==============================================================================
--- subversion/branches/revprop-packing/subversion/tests/libsvn_client/client-test.c (original)
+++ subversion/branches/revprop-packing/subversion/tests/libsvn_client/client-test.c Fri Mar 30 13:55:26 2012
@@ -572,7 +572,7 @@ test_copy_crash(const svn_test_opts_t *o
   /* Create a filesytem and repository containing the Greek tree. */
   SVN_ERR(create_greek_repos(&repos_url, "test-copy-crash", opts, pool));
 
-  svn_client_create_context(&ctx, pool);
+  SVN_ERR(svn_client_create_context(&ctx, pool));
 
   rev.kind = svn_opt_revision_head;
   dest = svn_path_url_add_component2(repos_url, "A/E", pool);
@@ -668,7 +668,7 @@ test_youngest_common_ancestor(const svn_
   /* Create a filesytem and repository containing the Greek tree. */
   SVN_ERR(create_greek_repos(&repos_url, "test-youngest-common-ancestor", opts, pool));
 
-  svn_client_create_context(&ctx, pool);
+  SVN_ERR(svn_client_create_context(&ctx, pool));
 
   /* Copy a file into dir 'A', keeping its own basename. */
   sources = apr_array_make(pool, 1, sizeof(svn_client_copy_source_t *));

Modified: subversion/branches/revprop-packing/subversion/tests/libsvn_wc/db-test.c
URL: http://svn.apache.org/viewvc/subversion/branches/revprop-packing/subversion/tests/libsvn_wc/db-test.c?rev=1307424&r1=1307423&r2=1307424&view=diff
==============================================================================
--- subversion/branches/revprop-packing/subversion/tests/libsvn_wc/db-test.c (original)
+++ subversion/branches/revprop-packing/subversion/tests/libsvn_wc/db-test.c Fri Mar 30 13:55:26 2012
@@ -228,8 +228,12 @@ static const char * const TESTING_DATA =
   "  1, null, 'file', '()', null, '$sha1$" SHA1_1 "', null, 2, " TIME_2s ", '" AUTHOR_2 "',"
   "  10, null, null, null);"
   "insert into nodes values ("
-  "  1, 'moved/file', 0, 'moved', 2, 'moved/file', 2, 'base-deleted',"
-  "  0, 'J/J-d', 'file', '()', null, '$sha1$" SHA1_1 "', null, 2, " TIME_2s ", '" AUTHOR_2 "',"
+  "  1, 'moved/file', 0, 'moved', 2, 'moved/file', 2, 'normal',"
+  "  0, null, 'file', '()', null, '$sha1$" SHA1_1 "', null, 2, " TIME_2s ", '" AUTHOR_2 "',"
+  "  10, null, null, null);"
+  "insert into nodes values ("
+  "  1, 'moved/file', 2, 'moved', 2, 'moved/file', 2, 'base-deleted',"
+  "  0, 'J/J-d', 'file', '()', null, null, null, null, null, null,"
   "  10, null, null, null);"
   "insert into nodes values ("
   "  1, 'J/J-e', 1, 'J', null, null, null, 'normal',"