I'm resending this as a new patch since I have hacked in some
simple failure tests and normalized an existing error message to
make it easier to test. (Is it ok to change the failure text??)
Additional failure tests for non-cp commands can be added as
a separate patch.
Comments welcome.
Kevin R.
[[[
Consistently log an error when copy targets exist and
add some expected failure tests.
* contrib/client-side/svnmucc/svnmucc.c
(build): If copy target path exists log an error
* contrib/client-side/svnmucc/svnmucc-test.py
(xrun_svnmucc): Added expected failure test
(main): Added cp failure tests
]]]
Index: contrib/client-side/svnmucc/svnmucc.c
===================================================================
--- contrib/client-side/svnmucc/svnmucc.c (revision 34099)
+++ contrib/client-side/svnmucc/svnmucc.c (working copy)
@@ -480,11 +480,33 @@
"than base revision");
operation->operation =
operation->operation == OP_DELETE ? OP_REPLACE : OP_ADD;
+ if (operation->operation == OP_ADD)
+ {
+ /* There is a bug in the current version of mod_dav_svn
+ which incorrectly replaces existing directories.
+ Therefore we need to check if the target exists
+ and raise an error here. */
+ SVN_ERR(svn_ra_check_path(session,
+ copy_src ? copy_src : path,
+ copy_src ? copy_rev : head,
+ &operation->kind, pool));
+ if (operation->kind != svn_node_none)
+ {
+ if (copy_src && strcmp(path, copy_src))
+ return svn_error_createf(SVN_ERR_BAD_URL, NULL,
+ "'%s' (from '%s:%ld') already exists",
+ path, copy_src, copy_rev);
+ else
+ return svn_error_createf(SVN_ERR_BAD_URL, NULL,
+ "'%s' already exists", path);
+ }
+ }
SVN_ERR(svn_ra_check_path(session, subtract_anchor(anchor, url, pool),
rev, &operation->kind, pool));
if (operation->kind == svn_node_none)
return svn_error_createf(SVN_ERR_BAD_URL, NULL,
- "'%s' not found", url);
+ "'%s' not found",
+ subtract_anchor(anchor, url, pool));
operation->url = url;
operation->rev = rev;
}
Index: contrib/client-side/svnmucc/svnmucc-test.py
===================================================================
--- contrib/client-side/svnmucc/svnmucc-test.py (revision 34099)
+++ contrib/client-side/svnmucc/svnmucc-test.py (working copy)
@@ -52,7 +52,29 @@
_svnmucc_re = re.compile('^(r[0-9]+) committed by svnmuccuser at (.*)$')
_log_re = re.compile('^ ([ADRM] /[^\(]+($| \(from .*:[0-9]+\)$))')
+_err_re = re.compile('^svnmucc: (.*)$')
+def xrun_svnmucc(expected_errors, *varargs):
+ """Run svnmucc with the list of SVNMUCC_ARGS arguments. Verify that
+ its run results match the list of EXPECTED_ERRORS."""
+
+ # First, run svnmucc.
+ exit_code, outlines, errlines = \
+ svntest.main.run_command(svnmucc_binary, 1, 0,
+ '-U', repos_url,
+ '-u', 'svnmuccuser',
+ '-p', 'svnmuccpass',
+ '--config-dir', 'dummy',
+ *varargs)
+ errors = []
+ for line in errlines:
+ match = _err_re.match(line)
+ if match:
+ errors.append(line.rstrip('\n\r'))
+ if errors != expected_errors:
+ raise svntest.main.SVNUnmatchedError(str(errors))
+
+
def run_svnmucc(expected_path_changes, *varargs):
"""Run svnmucc with the list of SVNMUCC_ARGS arguments. Verify that
its run results in a new commit with 'svn log -rHEAD' changed paths
@@ -233,6 +255,33 @@
run_svnmucc(['M /foo/bar'], #---------
'propdel', 'testprop', 'foo/bar')
+ # Expected missing revision error
+ xrun_svnmucc(['svnmucc: \'a\' is not a revision'
+ ], #---------
+ 'cp', 'a', 'b')
+
+ # Expected cannot be younger error
+ xrun_svnmucc(['svnmucc: Copy source revision cannot be younger ' +
+ 'than base revision',
+ ], #---------
+ 'cp', '42', 'a', 'b')
+
+ # Expected already exists error
+ xrun_svnmucc(["svnmucc: 'foo' already exists",
+ ], #---------
+ 'cp', '17', 'a', 'foo')
+
+ # Expected copy_src already exists error
+ xrun_svnmucc(["svnmucc: 'a/bar' (from 'foo/bar:17') already exists",
+ ], #---------
+ 'cp', '17', 'foo', 'a',
+ 'cp', '17', 'foo/foo', 'a/bar')
+
+ # Expected not found error
+ xrun_svnmucc(['svnmucc: \'a\' not found',
+ ], #---------
+ 'cp', '17', 'a', 'b')
+
if __name__ == "__main__":
try:
# remove any previously existing repository, then create a new one
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: dev-help_at_subversion.tigris.org
Received on 2008-11-10 22:39:14 CET