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

Fix for issue 3620 - unlock command

From: Noorul Islam K M <noorul_at_collab.net>
Date: Wed, 03 Nov 2010 22:11:08 +0530

Log

[[[

Make 'svn unlock' verify that both working copy paths and URLs are
not passed.

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

* subversion/svn/unlock-cmd.c
  (svn_cl__diff): 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 1030477)
+++ subversion/tests/cmdline/input_validation_tests.py (working copy)
@@ -173,6 +173,12 @@
     run_and_verify_svn_in_wc(sbox, "svn:.*is not a local path", 'upgrade',
                              target, target)
 
+def invalid_unlock_targets(sbox):
+ "invalid targets for 'unlock'"
+ 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", 'unlock', target1, target2)
 
 ########################################################################
 # Run the tests
@@ -192,6 +198,7 @@
               invalid_log_targets,
               invalid_merge_args,
               invalid_wcpath_upgrade,
+ invalid_unlock_targets,
              ]
 
 if __name__ == '__main__':
Index: subversion/svn/unlock-cmd.c
===================================================================
--- subversion/svn/unlock-cmd.c (revision 1030477)
+++ subversion/svn/unlock-cmd.c (working copy)
@@ -27,6 +27,7 @@
 
 /*** Includes. ***/
 
+#include "svn_path.h"
 #include "svn_pools.h"
 #include "svn_client.h"
 #include "svn_error_codes.h"
@@ -48,6 +49,8 @@
   svn_cl__opt_state_t *opt_state = ((svn_cl__cmd_baton_t *) baton)->opt_state;
   svn_client_ctx_t *ctx = ((svn_cl__cmd_baton_t *) baton)->ctx;
   apr_array_header_t *targets;
+ 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,
@@ -59,6 +62,22 @@
 
   SVN_ERR(svn_cl__eat_peg_revisions(&targets, targets, scratch_pool));
 
+ /* 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"));
+
   return svn_error_return(
     svn_client_unlock(targets, opt_state->force, ctx, scratch_pool));
 }
Received on 2010-11-03 17:42:10 CET

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