You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2013/10/21 19:13:22 UTC

svn commit: r1534280 - in /subversion/trunk/subversion/tests/cmdline: log_tests.py svntest/main.py

Author: stefan2
Date: Mon Oct 21 17:13:21 2013
New Revision: 1534280

URL: http://svn.apache.org/r1534280
Log:
Add a test case for 'svn log --auto-moves".

* subversion/tests/cmdline/svntest/main.py
  (server_has_auto_move): new feature presense test

* subversion/tests/cmdline/log_tests.py
  (renaming_history_repos): repo creation code factored out from
                            log_multiple_revs_spanning_rename;
                            added a cyclic rename as rev 5
  (log_multiple_revs_spanning_rename): use new function to create the repo
  (verify_move_log,
   log_auto_move): new test code
  (test_list): register new test

Modified:
    subversion/trunk/subversion/tests/cmdline/log_tests.py
    subversion/trunk/subversion/tests/cmdline/svntest/main.py

Modified: subversion/trunk/subversion/tests/cmdline/log_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/log_tests.py?rev=1534280&r1=1534279&r2=1534280&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/log_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/log_tests.py Mon Oct 21 17:13:21 2013
@@ -32,6 +32,7 @@ import svntest
 from svntest import wc
 
 from svntest.main import server_has_mergeinfo
+from svntest.main import server_has_auto_move
 from svntest.main import SVN_PROP_MERGEINFO
 from svntest.mergetrees import set_up_branch
 from diff_tests import make_diff_header, make_no_diff_deleted_header
@@ -407,6 +408,47 @@ def merge_history_repos(sbox):
   # Restore working directory
   os.chdir(was_cwd)
 
+def renaming_history_repos(sbox):
+  "create a repository containing renames and a suitable working copy"
+
+  sbox.build()
+  wc_dir = sbox.wc_dir
+  msg_file=os.path.join(sbox.repo_dir, 'log-msg')
+  msg_file=os.path.abspath(msg_file)
+  mu_path1 = os.path.join(wc_dir, 'A', 'mu')
+  mu_path2 = os.path.join(wc_dir, 'trunk', 'mu')
+
+  # r2 - Change a file.
+  msg=""" Log message for revision 2
+  but with multiple lines
+  to test the code"""
+  svntest.main.file_write(msg_file, msg)
+  svntest.main.file_append(mu_path1, "2")
+  svntest.main.run_svn(None, 'ci', '-F', msg_file, wc_dir)
+
+  # r3 - Rename that file's parent.
+  svntest.main.run_svn(None, 'up', wc_dir)
+  sbox.simple_move('A', 'trunk')
+  svntest.main.run_svn(None, 'ci', '-m', "Log message for revision 3",
+                       wc_dir)
+
+  # r4 - Change the file again.
+  msg=""" Log message for revision 4
+  but with multiple lines
+  to test the code"""
+  svntest.main.file_write(msg_file, msg)
+  svntest.main.file_append(mu_path2, "4")
+  svntest.main.run_svn(None, 'ci', '-F', msg_file, wc_dir)
+  svntest.main.run_svn(None, 'up', wc_dir)
+
+  # r5 - Cyclic exchange.
+  svntest.main.run_svn(None, 'up', wc_dir)
+  sbox.simple_move(os.path.join('trunk', 'D'), os.path.join('trunk', 'X'))
+  sbox.simple_move(os.path.join('trunk', 'C'), os.path.join('trunk', 'D'))
+  sbox.simple_move(os.path.join('trunk', 'X'), os.path.join('trunk', 'C'))
+  svntest.main.run_svn(None, 'ci', '-m', "Log message for revision 5",
+                       wc_dir)
+
 
 # For errors seen while parsing log data.
 class SVNLogParseError(Exception):
@@ -2369,36 +2411,9 @@ def merge_sensitive_log_with_search(sbox
 def log_multiple_revs_spanning_rename(sbox):
   "log for multiple revs which span a rename"
 
-  sbox.build()
-  wc_dir = sbox.wc_dir
-  msg_file=os.path.join(sbox.repo_dir, 'log-msg')
-  msg_file=os.path.abspath(msg_file)
-  mu_path1 = os.path.join(wc_dir, 'A', 'mu')
-  mu_path2 = os.path.join(wc_dir, 'trunk', 'mu')
-  trunk_path = os.path.join(wc_dir, 'trunk')
-
-  # r2 - Change a file.
-  msg=""" Log message for revision 2
-  but with multiple lines
-  to test the code"""
-  svntest.main.file_write(msg_file, msg)
-  svntest.main.file_append(mu_path1, "2")
-  svntest.main.run_svn(None, 'ci', '-F', msg_file, wc_dir)
+  trunk_path = os.path.join(sbox.wc_dir, 'trunk')
 
-  # r3 - Rename that file's parent.
-  svntest.main.run_svn(None, 'up', wc_dir)
-  sbox.simple_move('A', 'trunk')
-  svntest.main.run_svn(None, 'ci', '-m', "Log message for revision 3",
-                       wc_dir)
-
-  # r4 - Change the file again.
-  msg=""" Log message for revision 4
-  but with multiple lines
-  to test the code"""
-  svntest.main.file_write(msg_file, msg)
-  svntest.main.file_append(mu_path2, "4")
-  svntest.main.run_svn(None, 'ci', '-F', msg_file, wc_dir)
-  svntest.main.run_svn(None, 'up', wc_dir)
+  renaming_history_repos(sbox)
 
   # Check that log can handle a revision range that spans a rename.
   exit_code, output, err = svntest.actions.run_and_verify_svn(
@@ -2489,6 +2504,52 @@ def log_multiple_revs_spanning_rename(sb
   log_chain = parse_log_output(output)
   check_log_chain(log_chain, [1,4])
 
+#----------------------------------------------------------------------
+def verify_move_log(sbox, flag, has_moves):
+  "result checker for log_auto_move"
+
+  trunk_path = os.path.join(sbox.wc_dir, 'trunk')
+
+  exit_code, output, err = svntest.actions.run_and_verify_svn(
+    None, None, [], 'log', '-r3', '-v', trunk_path, flag)
+  log_chain = parse_log_output(output)
+  check_log_chain(log_chain, [3], [2])
+
+  paths = log_chain[0]['paths']
+  if paths[0][0] != 'D' or paths[0][1] != '/A':
+    raise SVNLogParseError("Deletion of '/A' expected, %s of %s found" % paths[0])
+  if has_moves:
+    if paths[1][0] != 'V' or paths[1][1] != '/trunk (from /A:2)':
+      raise SVNLogParseError("Move of '/A' to '/trunk' expected, %s of %s found" % paths[1])
+  else:
+    if paths[1][0] != 'A' or paths[1][1] != '/trunk (from /A:2)':
+      raise SVNLogParseError("Addition of '/A' to '/trunk' expected, %s of %s found" % paths[1])
+
+  exit_code, output, err = svntest.actions.run_and_verify_svn(
+    None, None, [], 'log', '-r5', '-v', trunk_path, flag)
+  log_chain = parse_log_output(output)
+  check_log_chain(log_chain, [5], [2])
+
+  paths = log_chain[0]['paths']
+  if has_moves:
+    if paths[0][0] != 'E' or paths[0][1] != '/trunk/C (from /trunk/D:4)':
+      raise SVNLogParseError("Replacing move of '/trunk/C' with '/trunk/D' expected, %s of %s found" % paths[0])
+    if paths[1][0] != 'E' or paths[1][1] != '/trunk/D (from /trunk/C:4)':
+      raise SVNLogParseError("Replacing move of '/trunk/D' with '/trunk/C' expected, %s of %s found" % paths[1])
+  else:
+    if paths[0][0] != 'R' or paths[0][1] != '/trunk/C (from /trunk/D:4)':
+      raise SVNLogParseError("Replace of '/trunk/C' with '/trunk/D' expected, %s of %s found" % paths[0])
+    if paths[1][0] != 'R' or paths[1][1] != '/trunk/D (from /trunk/C:4)':
+      raise SVNLogParseError("Replace of '/trunk/D' with '/trunk/C' expected, %s of %s found" % paths[1])
+
+@Issue(4355)
+def log_auto_move(sbox):
+  "test --auto-moves flag"
+
+  renaming_history_repos(sbox)
+  verify_move_log(sbox, '--auto-moves', server_has_auto_move())
+  verify_move_log(sbox, '-v', 0)
+
 ########################################################################
 # Run the tests
 
@@ -2535,6 +2596,7 @@ test_list = [ None,
               log_search,
               merge_sensitive_log_with_search,
               log_multiple_revs_spanning_rename,
+              log_auto_move,
              ]
 
 if __name__ == '__main__':

Modified: subversion/trunk/subversion/tests/cmdline/svntest/main.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svntest/main.py?rev=1534280&r1=1534279&r2=1534280&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svntest/main.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svntest/main.py Mon Oct 21 17:13:21 2013
@@ -1381,6 +1381,9 @@ def server_has_atomic_revprop():
 def server_has_reverse_get_file_revs():
   return options.server_minor_version >= 8
 
+def server_has_auto_move():
+  return options.server_minor_version >= 9
+
 def is_plaintext_password_storage_disabled():
   try:
     predicate = re.compile("^WARNING: Plaintext password storage is enabled!")