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 2010/11/03 22:38:42 UTC

svn commit: r1030704 - in /subversion/trunk/subversion: libsvn_client/locking_commands.c svn/lock-cmd.c tests/cmdline/input_validation_tests.py

Author: stsp
Date: Wed Nov  3 21:38:42 2010
New Revision: 1030704

URL: http://svn.apache.org/viewvc?rev=1030704&view=rev
Log:
Make 'svn lock' verify that both working copy paths and URLs are
not passed.

* subversion/tests/cmdline/input_validation_tests.py
  (invalid_lock_targets): New test, verifying that svn lock copes well
   with invalid target combinations.

* subversion/svn/lock-cmd.c,
  subversion/libsvn_client/locking_commands.c
  (svn_cl__lock, organize_lock_targets): For consistency with other
   sub-commands, raise SVN_ERR_CL_ARG_PARSING_ERROR (in the CLI client)
   or SVN_ERR_ILLEGAL_TARGET (in libsvn_client) if both working copy paths
   and URLs are passed. Use the same error message also used elsewhere.

Patch by: Noorul Islam K M <noorul{_AT_}collab.net>

Modified:
    subversion/trunk/subversion/libsvn_client/locking_commands.c
    subversion/trunk/subversion/svn/lock-cmd.c
    subversion/trunk/subversion/tests/cmdline/input_validation_tests.py

Modified: subversion/trunk/subversion/libsvn_client/locking_commands.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/locking_commands.c?rev=1030704&r1=1030703&r2=1030704&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/locking_commands.c (original)
+++ subversion/trunk/subversion/libsvn_client/locking_commands.c Wed Nov  3 21:38:42 2010
@@ -182,6 +182,23 @@ organize_lock_targets(const char **commo
   apr_hash_t *rel_targets_ret = apr_hash_make(pool);
   apr_pool_t *subpool = svn_pool_create(pool);
   svn_boolean_t url_mode;
+  svn_boolean_t wc_present = FALSE, url_present = FALSE;
+
+  /* Check to see if at least one of our paths is a working copy
+   * path or a repository url. */
+  for (i = 0; i < targets->nelts; ++i)
+    {
+      const char *target = APR_ARRAY_IDX(targets, i, const char *);
+      if (! svn_path_is_url(target))
+       wc_present = TRUE;
+      else
+       url_present = TRUE;
+    }
+
+  if (url_present && wc_present)
+    return svn_error_createf(SVN_ERR_ILLEGAL_TARGET, NULL,
+                             _("Cannot mix repository and working copy "
+                               "targets"));
 
   /* All targets must be either urls or paths */
 

Modified: subversion/trunk/subversion/svn/lock-cmd.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/lock-cmd.c?rev=1030704&r1=1030703&r2=1030704&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/lock-cmd.c (original)
+++ subversion/trunk/subversion/svn/lock-cmd.c Wed Nov  3 21:38:42 2010
@@ -89,6 +89,8 @@ svn_cl__lock(apr_getopt_t *os,
   svn_client_ctx_t *ctx = ((svn_cl__cmd_baton_t *) baton)->ctx;
   apr_array_header_t *targets;
   const char *comment;
+  svn_boolean_t wc_present = FALSE, url_present = FALSE;
+  int i;
 
   SVN_ERR(svn_cl__args_to_target_array_print_reserved(&targets, os,
                                                       opt_state->targets,
@@ -98,6 +100,22 @@ svn_cl__lock(apr_getopt_t *os,
   if (! targets->nelts)
     return svn_error_create(SVN_ERR_CL_INSUFFICIENT_ARGS, 0, NULL);
 
+  /* Check to see if at least one of our paths is a working copy
+   * path or a repository url. */
+  for (i = 0; i < targets->nelts; ++i)
+    {
+      const char *target = APR_ARRAY_IDX(targets, i, const char *);
+      if (! svn_path_is_url(target))
+       wc_present = TRUE;
+      else
+       url_present = TRUE;
+    }
+
+  if (url_present && wc_present)
+    return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+                        _("Cannot mix repository and working copy "
+                          "targets"));
+
   /* Get comment. */
   SVN_ERR(get_comment(&comment, ctx, opt_state, pool));
 

Modified: subversion/trunk/subversion/tests/cmdline/input_validation_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/input_validation_tests.py?rev=1030704&r1=1030703&r2=1030704&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/input_validation_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/input_validation_tests.py Wed Nov  3 21:38:42 2010
@@ -194,6 +194,13 @@ def invalid_revert_targets(sbox):
     run_and_verify_svn_in_wc(sbox, "svn:.*is not a local path", 'revert',
                              target)
 
+def invalid_lock_targets(sbox):
+  "wc paths and repo URL target mixture for 'lock'"
+  sbox.build(read_only=True)
+  for (target1, target2) in [("iota", "^/"), ("file://", "iota")]:
+    run_and_verify_svn_in_wc(sbox, "svn: Cannot mix repository and working "
+                             "copy targets", 'lock', target1, target2)
+
 ########################################################################
 # Run the tests
 
@@ -215,6 +222,7 @@ test_list = [ None,
               invalid_resolve_targets,
               invalid_resolved_targets,
               invalid_revert_targets,
+              invalid_lock_targets,
              ]
 
 if __name__ == '__main__':