svn commit: r1897439 - /subversion/trunk/subversion/tests/cmdline/pegrev_parse_tests.py

2022-01-24 Thread danielsh
Author: danielsh
Date: Tue Jan 25 07:33:33 2022
New Revision: 1897439

URL: http://svn.apache.org/viewvc?rev=1897439=rev
Log:
Rename an internal function.  No functional change.

The name of pegrev_parse_tests.run_svn() can be confused with the name of
svntest.main.run_svn() when using one's $EDITOR's "Jump to the definition of
the function named «run_svn»" functionality, or when referring to functions
solely by their basename.  Furthermore, calling the latter function with actual
arguments appropriate for the former doesn't raise any obvious exception; for
instance, calling «svntest.main.run_svn(sbox, None, [], 'info')» actually runs
«svn None "[]" info» and — because «sbox» is true in boolean context, and
svntest.main.run_svn() doesn't inspect its first actual argument in any other
way — doesn't raise any exception when that command returns a non-zero exit
code.

Furthermore, the new name is more descriptive.

* subversion/tests/cmdline/pegrev_parse_tests.py
  (run_svn): Rename to…
  (run_svn_at_wcdir): … this.

Modified:
subversion/trunk/subversion/tests/cmdline/pegrev_parse_tests.py

Modified: subversion/trunk/subversion/tests/cmdline/pegrev_parse_tests.py
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/pegrev_parse_tests.py?rev=1897439=1897438=1897439=diff
==
--- subversion/trunk/subversion/tests/cmdline/pegrev_parse_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/pegrev_parse_tests.py Tue Jan 25 
07:33:33 2022
@@ -52,7 +52,7 @@ Item = wc.StateItem
 # commands, because the parser may have (and as of this writing does have)
 # edge-case bugs that we can only expose in this way. Therefore, these helpers
 # ensure that we run 'svn' with the CWD at the root of the working copy.
-def run_svn(sbox, expected_status, expected_stderr, *varargs):
+def run_svn_at_wcdir(sbox, expected_status, expected_stderr, *varargs):
   if expected_stderr is None:
 expected_stderr = []
 
@@ -96,8 +96,8 @@ def do_add_file(sbox, dst, dst_cmdline,
 expected_status.add({dst: Item(status='A ', wc_rev='-')})
 
   main.file_write(sbox.ospath(dst), "This is file '"  + dst + "'.")
-  run_svn(sbox, expected_status, expected_stderr,
-  'add', dst_cmdline)
+  run_svn_at_wcdir(sbox, expected_status, expected_stderr,
+   'add', dst_cmdline)
 
 def do_add_file_e(sbox, dst, dst_cmdline, expected_stderr=None):
   "like do_add_file() but with an empty sandbox"
@@ -109,8 +109,8 @@ def do_make_dir(sbox, dst, dst_cmdline,
   if expected_status is not None:
 expected_status.add({dst: Item(status='A ', wc_rev='-')})
 
-  run_svn(sbox, expected_status, expected_stderr,
-  'mkdir', dst_cmdline)
+  run_svn_at_wcdir(sbox, expected_status, expected_stderr,
+   'mkdir', dst_cmdline)
 
 def do_make_dir_e(sbox, dst, dst_cmdline, expected_stderr=None):
   "like do_make_dir() but with an empty sandbox"
@@ -121,8 +121,8 @@ def do_remove(sbox, dst, dst_cmdline, ex
   if expected_status is not None and dst in expected_status.desc:
 expected_status.tweak(dst, status='D ')
 
-  run_svn(sbox, expected_status, expected_stderr,
-  'remove', dst_cmdline)
+  run_svn_at_wcdir(sbox, expected_status, expected_stderr,
+   'remove', dst_cmdline)
 
 def do_rename(sbox, src, src_cmdline, dst, dst_cmdline,
   expected_stderr=None):
@@ -132,8 +132,8 @@ def do_rename(sbox, src, src_cmdline, ds
 expected_status.add({dst: Item(status='A ', copied='+',
moved_from=src, wc_rev='-')})
 
-  run_svn(sbox, expected_status, expected_stderr,
-  'rename', src_cmdline, dst_cmdline)
+  run_svn_at_wcdir(sbox, expected_status, expected_stderr,
+   'rename', src_cmdline, dst_cmdline)
 
 
 ##




svn commit: r1897407 - /subversion/trunk/subversion/tests/cmdline/basic_tests.py

2022-01-24 Thread danielsh
Author: danielsh
Date: Mon Jan 24 10:54:16 2022
New Revision: 1897407

URL: http://svn.apache.org/viewvc?rev=1897407=rev
Log:
* subversion/tests/cmdline/basic_tests.py
  (keep_local_reverted_properly): New test.
  (test_list): Run it.

Suggested by: hartmannathan

Modified:
subversion/trunk/subversion/tests/cmdline/basic_tests.py

Modified: subversion/trunk/subversion/tests/cmdline/basic_tests.py
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/basic_tests.py?rev=1897407=1897406=1897407=diff
==
--- subversion/trunk/subversion/tests/cmdline/basic_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/basic_tests.py Mon Jan 24 
10:54:16 2022
@@ -3242,6 +3242,42 @@ def filtered_ls_top_level_path(sbox):
 exit_code, output, error = svntest.actions.run_and_verify_svn(
   [], [], 'ls', f_path, '--search=*/*', *extra_opts)
 
+def keep_local_reverted_properly(sbox):
+  "rm --keep-local, /bin/rm, revert"
+
+  sbox.build(read_only=True)
+  wc_dir = sbox.wc_dir
+
+  lambda_path = sbox.ospath('A/B/lambda')
+  E_path =  sbox.ospath('A/B/E')
+  targets = [ lambda_path, E_path ]
+
+  # Modify
+  sbox.simple_append('A/B/lambda', "added text\n")
+  svntest.main.run_svn(None, 'ps', 'k', 'v', E_path)
+
+  # Schedule for removal
+  svntest.main.run_svn(None, 'rm', '--keep-local', *targets)
+
+  # Remove from disk
+  os.unlink(lambda_path)
+  shutil.rmtree(E_path)
+
+  # Revert
+  svntest.main.run_svn(None, 'revert', *targets)
+
+  # Check that the modifications are absent
+  # 
+  # alpha and beta are still scheduled for deletion because 'revert' doesn't
+  # recurse by default.
+  expected_disk = svntest.main.greek_state.copy()
+  expected_disk.remove('A/B/E/alpha', 'A/B/E/beta')
+  expected_output = svntest.actions.get_virginal_state(wc_dir, 1)
+  expected_output.tweak('A/B/E/alpha', 'A/B/E/beta', status='D ')
+  #
+  svntest.actions.verify_disk(sbox.wc_dir, expected_disk, check_props=True)
+  svntest.actions.run_and_verify_status(wc_dir, expected_output)
+
 
 
 # Run the tests
@@ -3318,6 +3354,7 @@ test_list = [ None,
   null_update_last_changed_revision,
   null_prop_update_last_changed_revision,
   filtered_ls_top_level_path,
+  keep_local_reverted_properly,
  ]
 
 if __name__ == '__main__':