[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Fix for issue 3620 - lock command

From: Noorul Islam K M <noorul_at_collab.net>
Date: Thu, 04 Nov 2010 02:14:32 +0530

Noorul Islam K M <noorul_at_collab.net> writes:

> 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
> (svn_cl__lock): For consistency with other sub-commands, raise the
> SVN_ERR_CL_ARG_PARSING_ERROR if both working copy paths and URLs are
> passed, and use the same error message also used elsewhere.
>
> Patch by: Noorul Islam K M <noorul{_AT_}collab.net>
>
> ]]]
>
> Thanks and Regards
> Noorul
>
> Index: subversion/tests/cmdline/input_validation_tests.py
> ===================================================================
> --- subversion/tests/cmdline/input_validation_tests.py (revision 1030628)
> +++ subversion/tests/cmdline/input_validation_tests.py (working copy)
> @@ -194,6 +194,13 @@
> 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 @@
> invalid_resolve_targets,
> invalid_resolved_targets,
> invalid_revert_targets,
> + invalid_lock_targets,
> ]
>
> if __name__ == '__main__':
> Index: subversion/svn/lock-cmd.c
> ===================================================================
> --- subversion/svn/lock-cmd.c (revision 1030628)
> +++ subversion/svn/lock-cmd.c (working copy)
> @@ -89,6 +89,8 @@
> 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 @@
> 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 *path = APR_ARRAY_IDX(targets, i, const char *);
> + if (! svn_path_is_url(path))
> + 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));
>

Sending updated patch with libsvn_client modifications.

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 the SVN_ERR_CL_ARG_PARSING_ERROR if both working
   copy paths and URLs are passed, and use the same error message also
   used elsewhere.

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

]]]

Thanks and Regards
Noorul

Index: subversion/tests/cmdline/input_validation_tests.py
===================================================================
--- subversion/tests/cmdline/input_validation_tests.py (revision 1030628)
+++ subversion/tests/cmdline/input_validation_tests.py (working copy)
@@ -194,6 +194,13 @@
     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 @@
               invalid_resolve_targets,
               invalid_resolved_targets,
               invalid_revert_targets,
+ invalid_lock_targets,
              ]
 
 if __name__ == '__main__':
Index: subversion/svn/lock-cmd.c
===================================================================
--- subversion/svn/lock-cmd.c (revision 1030628)
+++ subversion/svn/lock-cmd.c (working copy)
@@ -89,6 +89,8 @@
   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 @@
   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));
 
Index: subversion/libsvn_client/locking_commands.c
===================================================================
--- subversion/libsvn_client/locking_commands.c (revision 1030628)
+++ subversion/libsvn_client/locking_commands.c (working copy)
@@ -182,7 +182,24 @@
   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 */
 
   url_mode = ((targets->nelts >= 1) &&
Received on 2010-11-03 21:45:38 CET

This is an archived mail posted to the Subversion Dev mailing list.