Author: brane
Date: Wed Jun 18 23:50:44 2025
New Revision: 1926563
URL: http://svn.apache.org/viewvc?rev=1926563&view=rev
Log:
Fix fallout from r1925937: command-line tools should be non-interactive
if the standard input is *not* a terminal. Add tests for this case.
* subversion/libsvn_subr/cmdline.c
(svn_cmdline__be_interactive): Invert the non-interactive condition,
reverting to the way it worked before r1925937.
"Just one good bang short of a jackpot!"
* subversion/tests/cmdline/basic_tests.py
(_basic_commit_common): Rename from basic_commit(), and implement
test modes with and without using an editor for the log message..
(basic_commit, basic_commit_use_editor,
basic_commit_use_editor_force_interactive): New test cases. The
basic_commit() test has the same semantics as before. The other two
exercise interaction with an editor to get the log message.
(test_list): Register the new tests.
* subversion/tests/cmdline/svneditor.py
(prepend_foo): New edit mode, suitable for editing log messages.
* subversion/tests/cmdline/svntest/actions.py
(run_and_verify_commit2): Rename from run_and_verify_commit and add
arguments to decide whether and when to add a log message to the
svn argument list.
(run_and_verify_commit): Wrapper for run_and_verify_commit2, preserving
the old semantics.
Found by: cmpilato
Modified:
subversion/trunk/subversion/libsvn_subr/cmdline.c
subversion/trunk/subversion/tests/cmdline/basic_tests.py
subversion/trunk/subversion/tests/cmdline/svneditor.py
subversion/trunk/subversion/tests/cmdline/svntest/actions.py
Modified: subversion/trunk/subversion/libsvn_subr/cmdline.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/cmdline.c?rev=1926563&r1=1926562&r2=1926563&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/cmdline.c (original)
+++ subversion/trunk/subversion/libsvn_subr/cmdline.c Wed Jun 18 23:50:44 2025
@@ -1239,7 +1239,7 @@ svn_cmdline__be_interactive(svn_boolean_
* be interactive if stdin is a terminal.
* If --force-interactive was passed, always be interactive. */
if (!force_interactive && !*non_interactive)
- *non_interactive = svn_cmdline__stdin_is_a_terminal();
+ *non_interactive = !svn_cmdline__stdin_is_a_terminal();
if (force_interactive)
*non_interactive = FALSE;
Modified: subversion/trunk/subversion/tests/cmdline/basic_tests.py
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/basic_tests.py?rev=1926563&r1=1926562&r2=1926563&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/basic_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/basic_tests.py Wed Jun 18
23:50:44 2025
@@ -115,11 +115,10 @@ def basic_status(sbox):
#----------------------------------------------------------------------
-def basic_commit(sbox):
- "basic commit command"
-
+def _basic_commit_common(sbox, expected_error=[], *args):
sbox.build()
wc_dir = sbox.wc_dir
+ svntest.main.use_editor('prepend_foo')
# Make a couple of local mods to files
mu_path = sbox.ospath('A/mu')
@@ -128,20 +127,48 @@ def basic_commit(sbox):
svntest.main.file_append(rho_path, 'new appended text for rho')
# Created expected output tree for 'svn ci'
- expected_output = wc.State(wc_dir, {
- 'A/mu' : Item(verb='Sending'),
- 'A/D/G/rho' : Item(verb='Sending'),
+ if expected_error:
+ expected_output = []
+ else:
+ expected_output = wc.State(wc_dir, {
+ 'A/mu' : Item(verb='Sending'),
+ 'A/D/G/rho' : Item(verb='Sending'),
})
# Create expected status tree; all local revisions should be at 1,
# but mu and rho should be at revision 2.
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
- expected_status.tweak('A/mu', 'A/D/G/rho', wc_rev=2)
+ if expected_error:
+ expected_status.tweak('A/mu', 'A/D/G/rho', status='M ')
+ else:
+ expected_status.tweak('A/mu', 'A/D/G/rho', wc_rev=2)
- svntest.actions.run_and_verify_commit(wc_dir,
- expected_output,
- expected_status)
+ prepend_wc_dir_name = len(args) > 0
+ append_log_message = not (len(args) or expected_error)
+ svntest.actions.run_and_verify_commit2(wc_dir,
+ expected_output,
+ expected_status,
+ prepend_wc_dir_name,
+ append_log_message,
+ expected_error,
+ *args)
+
+def basic_commit(sbox):
+ "basic commit command"
+
+ return _basic_commit_common(sbox)
+
+def basic_commit_use_editor(sbox):
+ "basic commit using editor"
+
+ # Note: svn's stdin is not a terminal, so it defaults to non-interactive.
+ return _basic_commit_common(sbox,
+ "svn: E205001: .* editor .* non-interactive.*")
+
+def basic_commit_use_editor_force_interactive(sbox):
+ "basic commit using editor and force-interactive"
+ return _basic_commit_common(sbox, [], '--force-interactive')
#----------------------------------------------------------------------
@@ -3355,6 +3382,8 @@ test_list = [ None,
basic_checkout,
basic_status,
basic_commit,
+ basic_commit_use_editor,
+ basic_commit_use_editor_force_interactive,
basic_update,
basic_mkdir_url,
basic_mkdir_url_with_parents,
Modified: subversion/trunk/subversion/tests/cmdline/svneditor.py
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svneditor.py?rev=1926563&r1=1926562&r2=1926563&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svneditor.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svneditor.py Wed Jun 18 23:50:44
2025
@@ -70,6 +70,9 @@ def foo_to_bar(m):
def append_foo(m):
return m + 'foo\n'
+def prepend_foo(m):
+ return 'foo\n' + m
+
def identity(m):
return m
Modified: subversion/trunk/subversion/tests/cmdline/svntest/actions.py
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svntest/actions.py?rev=1926563&r1=1926562&r2=1926563&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svntest/actions.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svntest/actions.py Wed Jun 18
23:50:44 2025
@@ -1533,6 +1533,15 @@ def process_output_for_commit(output, er
def run_and_verify_commit(wc_dir_name, output_tree, status_tree,
expected_stderr=[],
*args):
+ """Like run_and_verify_commit2(), but a log message will always
+ be appended to the command-line arguments."""
+ return run_and_verify_commit2(wc_dir_name, output_tree, status_tree,
+ False, True, expected_stderr, *args)
+
+def run_and_verify_commit2(wc_dir_name, output_tree, status_tree,
+ prepend_wc_dir_name=False, append_log_message=True,
+ expected_stderr=[],
+ *args):
"""Commit and verify results within working copy WC_DIR_NAME,
sending ARGS to the commit subcommand.
@@ -1541,6 +1550,13 @@ def run_and_verify_commit(wc_dir_name, o
be compared. (This is a good way to check that revision numbers
were bumped.)
+ Set PREPEND_WC_DIR_NAME to True to always prepend the working copy
+ directory to the argument list, otherwise it will only be used when
+ ARGS are empty.
+
+ Set APPEND_LOG_MESSAGE to False to prevent adding a log message argument
+ if ARGS doesn't contain one.
+
EXPECTED_STDERR is handled as in run_and_verify_svn()
Return if successful, raise on failure."""
@@ -1549,10 +1565,11 @@ def run_and_verify_commit(wc_dir_name, o
output_tree = output_tree.old_tree()
# Commit.
- if len(args) == 0:
- args = (wc_dir_name,)
- if '-m' not in args and '-F' not in args:
- args = list(args) + ['-m', 'log msg']
+ args = list(args)
+ if len(args) == 0 or prepend_wc_dir_name:
+ args.insert(0, wc_dir_name)
+ if append_log_message and '-m' not in args and '-F' not in args:
+ args.extend(['-m', 'log msg'])
exit_code, output, errput = run_and_verify_svn(None, expected_stderr,
'ci', *args)