subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From julianf...@apache.org
Subject svn commit: r1139360 - in /subversion/trunk/subversion/svn: add-cmd.c changelist-cmd.c cl.h cleanup-cmd.c commit-cmd.c resolve-cmd.c resolved-cmd.c revert-cmd.c status-cmd.c update-cmd.c upgrade-cmd.c util.c
Date Fri, 24 Jun 2011 15:48:12 GMT
Author: julianfoad
Date: Fri Jun 24 15:48:11 2011
New Revision: 1139360

URL: http://svn.apache.org/viewvc?rev=1139360&view=rev
Log:
Factor out a function. This slightly changes the error message seen when a
commit target is a URL; svn will now show two lines:

  Commit targets must be local paths
  'file:///foo' is not a local path

instead of this previous single line (which already differed from 1.6.x):

  'file:///foo' is a URL, but URLs cannot be commit targets

All other subcommands that report this kind of error continue to print just

  'file:///foo' is not a local path

* subversion/svn/cl.h,
  subversion/svn/util.c
  (svn_cl__check_targets_are_local_paths): New function.

* subversion/svn/add-cmd.c (svn_cl__add),
* subversion/svn/changelist-cmd.c (svn_cl__changelist),
* subversion/svn/cleanup-cmd.c (svn_cl__cleanup),
* subversion/svn/commit-cmd.c (svn_cl__commit),
* subversion/svn/resolve-cmd.c (svn_cl__resolve),
* subversion/svn/resolved-cmd.c (svn_cl__resolved),
* subversion/svn/revert-cmd.c (svn_cl__revert),
* subversion/svn/status-cmd.c (svn_cl__status),
* subversion/svn/update-cmd.c (svn_cl__update),
* subversion/svn/upgrade-cmd.c (svn_cl__upgrade):
    Use it instead of in-line code.

Modified:
    subversion/trunk/subversion/svn/add-cmd.c
    subversion/trunk/subversion/svn/changelist-cmd.c
    subversion/trunk/subversion/svn/cl.h
    subversion/trunk/subversion/svn/cleanup-cmd.c
    subversion/trunk/subversion/svn/commit-cmd.c
    subversion/trunk/subversion/svn/resolve-cmd.c
    subversion/trunk/subversion/svn/resolved-cmd.c
    subversion/trunk/subversion/svn/revert-cmd.c
    subversion/trunk/subversion/svn/status-cmd.c
    subversion/trunk/subversion/svn/update-cmd.c
    subversion/trunk/subversion/svn/upgrade-cmd.c
    subversion/trunk/subversion/svn/util.c

Modified: subversion/trunk/subversion/svn/add-cmd.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/add-cmd.c?rev=1139360&r1=1139359&r2=1139360&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/add-cmd.c (original)
+++ subversion/trunk/subversion/svn/add-cmd.c Fri Jun 24 15:48:11 2011
@@ -65,16 +65,7 @@ svn_cl__add(apr_getopt_t *os,
 
   SVN_ERR(svn_cl__eat_peg_revisions(&targets, targets, pool));
 
-  /* Don't even attempt to modify the working copy if any of the
-   * targets look like URLs. URLs are invalid input. */
-  for (i = 0; i < targets->nelts; i++)
-    {
-      const char *target = APR_ARRAY_IDX(targets, i, const char *);
-
-      if (svn_path_is_url(target))
-        return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
-                                 _("'%s' is not a local path"), target);
-    }
+  SVN_ERR(svn_cl__check_targets_are_local_paths(targets));
 
   iterpool = svn_pool_create(pool);
   for (i = 0; i < targets->nelts; i++)

Modified: subversion/trunk/subversion/svn/changelist-cmd.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/changelist-cmd.c?rev=1139360&r1=1139359&r2=1139360&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/changelist-cmd.c (original)
+++ subversion/trunk/subversion/svn/changelist-cmd.c Fri Jun 24 15:48:11 2011
@@ -45,7 +45,6 @@ svn_cl__changelist(apr_getopt_t *os,
   svn_client_ctx_t *ctx = ((svn_cl__cmd_baton_t *) baton)->ctx;
   apr_array_header_t *targets;
   svn_depth_t depth = opt_state->depth;
-  int i;
 
   /* If we're not removing changelists, then our first argument should
      be the name of a changelist. */
@@ -69,16 +68,7 @@ svn_cl__changelist(apr_getopt_t *os,
   if (! targets->nelts)
     return svn_error_create(SVN_ERR_CL_INSUFFICIENT_ARGS, 0, NULL);
 
-  /* Don't even attempt to modify the working copy if any of the
-   * targets look like URLs. URLs are invalid input. */
-  for (i = 0; i < targets->nelts; i++)
-    {
-      const char *target = APR_ARRAY_IDX(targets, i, const char *);
-
-      if (svn_path_is_url(target))
-        return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
-                                 _("'%s' is not a local path"), target);
-    }
+  SVN_ERR(svn_cl__check_targets_are_local_paths(targets));
 
   if (opt_state->quiet)
     /* FIXME: This is required because svn_client_create_context()

Modified: subversion/trunk/subversion/svn/cl.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/cl.h?rev=1139360&r1=1139359&r2=1139360&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/cl.h (original)
+++ subversion/trunk/subversion/svn/cl.h Fri Jun 24 15:48:11 2011
@@ -823,6 +823,10 @@ svn_cl__opt_parse_path(svn_opt_revision_
 svn_error_t *
 svn_cl__assert_homogeneous_target_type(const apr_array_header_t *targets);
 
+/* Return an error if TARGETS contains a URL; otherwise return SVN_NO_ERROR. */
+svn_error_t *
+svn_cl__check_targets_are_local_paths(const apr_array_header_t *targets);
+
 /* Return a copy of PATH, converted to the local path style, skipping
  * PARENT_PATH if it is non-null and is a parent of or equal to PATH.
  *

Modified: subversion/trunk/subversion/svn/cleanup-cmd.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/cleanup-cmd.c?rev=1139360&r1=1139359&r2=1139360&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/cleanup-cmd.c (original)
+++ subversion/trunk/subversion/svn/cleanup-cmd.c Fri Jun 24 15:48:11 2011
@@ -57,16 +57,7 @@ svn_cl__cleanup(apr_getopt_t *os,
   /* Add "." if user passed 0 arguments */
   svn_opt_push_implicit_dot_target(targets, pool);
 
-  /* Don't even attempt to modify the working copy if any of the
-   * targets look like URLs. URLs are invalid input. */
-  for (i = 0; i < targets->nelts; i++)
-    {
-      const char *target = APR_ARRAY_IDX(targets, i, const char *);
-
-      if (svn_path_is_url(target))
-        return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
-                                 _("'%s' is not a local path"), target);
-    }
+  SVN_ERR(svn_cl__check_targets_are_local_paths(targets));
 
   SVN_ERR(svn_cl__eat_peg_revisions(&targets, targets, pool));
 

Modified: subversion/trunk/subversion/svn/commit-cmd.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/commit-cmd.c?rev=1139360&r1=1139359&r2=1139360&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/commit-cmd.c (original)
+++ subversion/trunk/subversion/svn/commit-cmd.c Fri Jun 24 15:48:11 2011
@@ -106,21 +106,13 @@ svn_cl__commit(apr_getopt_t *os,
   svn_config_t *cfg;
   svn_boolean_t no_unlock = FALSE;
   struct copy_warning_notify_baton cwnb;
-  int i;
 
   SVN_ERR(svn_cl__args_to_target_array_print_reserved(&targets, os,
                                                       opt_state->targets,
                                                       ctx, FALSE, pool));
 
-  /* Check that no targets are URLs */
-  for (i = 0; i < targets->nelts; i++)
-    {
-      const char *target = APR_ARRAY_IDX(targets, i, const char *);
-      if (svn_path_is_url(target))
-        return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
-                                 _("'%s' is a URL, but URLs cannot be "
-                                   "commit targets"), target);
-    }
+  SVN_ERR_W(svn_cl__check_targets_are_local_paths(targets),
+            _("Commit targets must be local paths"));
 
   /* Add "." if user passed 0 arguments. */
   svn_opt_push_implicit_dot_target(targets, pool);

Modified: subversion/trunk/subversion/svn/resolve-cmd.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/resolve-cmd.c?rev=1139360&r1=1139359&r2=1139360&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/resolve-cmd.c (original)
+++ subversion/trunk/subversion/svn/resolve-cmd.c Fri Jun 24 15:48:11 2011
@@ -95,16 +95,7 @@ svn_cl__resolve(apr_getopt_t *os,
 
   SVN_ERR(svn_cl__eat_peg_revisions(&targets, targets, scratch_pool));
 
-  /* Don't even attempt to modify the working copy if any of the
-   * targets look like URLs. URLs are invalid input. */
-  for (i = 0; i < targets->nelts; i++)
-    {
-      const char *target = APR_ARRAY_IDX(targets, i, const char *);
-
-      if (svn_path_is_url(target))
-        return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
-                                 _("'%s' is not a local path"), target);
-    }
+  SVN_ERR(svn_cl__check_targets_are_local_paths(targets));
 
   iterpool = svn_pool_create(scratch_pool);
   for (i = 0; i < targets->nelts; i++)

Modified: subversion/trunk/subversion/svn/resolved-cmd.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/resolved-cmd.c?rev=1139360&r1=1139359&r2=1139360&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/resolved-cmd.c (original)
+++ subversion/trunk/subversion/svn/resolved-cmd.c Fri Jun 24 15:48:11 2011
@@ -66,15 +66,7 @@ svn_cl__resolved(apr_getopt_t *os,
 
   SVN_ERR(svn_cl__eat_peg_revisions(&targets, targets, scratch_pool));
 
-  /* URLs are invalid input. */
-  for (i = 0; i < targets->nelts; i++)
-    {
-      const char *target = APR_ARRAY_IDX(targets, i, const char *);
-
-      if (svn_path_is_url(target))
-        return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
-                                 _("'%s' is not a local path"), target);
-    }
+  SVN_ERR(svn_cl__check_targets_are_local_paths(targets));
 
   iterpool = svn_pool_create(scratch_pool);
   for (i = 0; i < targets->nelts; i++)

Modified: subversion/trunk/subversion/svn/revert-cmd.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/revert-cmd.c?rev=1139360&r1=1139359&r2=1139360&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/revert-cmd.c (original)
+++ subversion/trunk/subversion/svn/revert-cmd.c Fri Jun 24 15:48:11 2011
@@ -48,7 +48,6 @@ svn_cl__revert(apr_getopt_t *os,
   svn_client_ctx_t *ctx = ((svn_cl__cmd_baton_t *) baton)->ctx;
   apr_array_header_t *targets = NULL;
   svn_error_t *err;
-  int i;
 
   SVN_ERR(svn_cl__args_to_target_array_print_reserved(&targets, os,
                                                       opt_state->targets,
@@ -66,16 +65,7 @@ svn_cl__revert(apr_getopt_t *os,
 
   SVN_ERR(svn_cl__eat_peg_revisions(&targets, targets, scratch_pool));
 
-  /* Don't even attempt to modify the working copy if any of the
-   * targets look like URLs. URLs are invalid input. */
-  for (i = 0; i < targets->nelts; i++)
-    {
-      const char *target = APR_ARRAY_IDX(targets, i, const char *);
-
-      if (svn_path_is_url(target))
-        return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
-                                 _("'%s' is not a local path"), target);
-    }
+  SVN_ERR(svn_cl__check_targets_are_local_paths(targets));
 
   err = svn_client_revert2(targets, opt_state->depth,
                            opt_state->changelists, ctx, scratch_pool);

Modified: subversion/trunk/subversion/svn/status-cmd.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/status-cmd.c?rev=1139360&r1=1139359&r2=1139360&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/status-cmd.c (original)
+++ subversion/trunk/subversion/svn/status-cmd.c Fri Jun 24 15:48:11 2011
@@ -275,15 +275,7 @@ svn_cl__status(apr_getopt_t *os,
   /* Add "." if user passed 0 arguments */
   svn_opt_push_implicit_dot_target(targets, scratch_pool);
 
-  /* URLs are invalid input. */
-  for (i = 0; i < targets->nelts; i++)
-    {
-      const char *target = APR_ARRAY_IDX(targets, i, const char *);
-
-      if (svn_path_is_url(target))
-        return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
-                                 _("'%s' is not a local path"), target);
-    }
+  SVN_ERR(svn_cl__check_targets_are_local_paths(targets));
 
   /* We want our -u statuses to be against HEAD. */
   rev.kind = svn_opt_revision_head;

Modified: subversion/trunk/subversion/svn/update-cmd.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/update-cmd.c?rev=1139360&r1=1139359&r2=1139360&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/update-cmd.c (original)
+++ subversion/trunk/subversion/svn/update-cmd.c Fri Jun 24 15:48:11 2011
@@ -110,7 +110,6 @@ svn_cl__update(apr_getopt_t *os,
   svn_boolean_t depth_is_sticky;
   struct svn_cl__check_externals_failed_notify_baton nwb;
   apr_array_header_t *result_revs;
-  int i;
 
   SVN_ERR(svn_cl__args_to_target_array_print_reserved(&targets, os,
                                                       opt_state->targets,
@@ -122,15 +121,7 @@ svn_cl__update(apr_getopt_t *os,
 
   SVN_ERR(svn_cl__eat_peg_revisions(&targets, targets, scratch_pool));
 
-  /* If any targets are URLs, display error message and exit. */
-  for (i = 0; i < targets->nelts; i++)
-    {
-      const char *target = APR_ARRAY_IDX(targets, i, const char *);
-
-      if (svn_path_is_url(target))
-        return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
-                                 _("'%s' is not a local path"), target);
-    }
+  SVN_ERR(svn_cl__check_targets_are_local_paths(targets));
 
   /* If using changelists, convert targets into a set of paths that
      match the specified changelist(s). */

Modified: subversion/trunk/subversion/svn/upgrade-cmd.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/upgrade-cmd.c?rev=1139360&r1=1139359&r2=1139360&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/upgrade-cmd.c (original)
+++ subversion/trunk/subversion/svn/upgrade-cmd.c Fri Jun 24 15:48:11 2011
@@ -61,16 +61,7 @@ svn_cl__upgrade(apr_getopt_t *os,
 
   SVN_ERR(svn_cl__eat_peg_revisions(&targets, targets, scratch_pool));
 
-  /* Don't even attempt to modify the working copy if any of the
-   * targets look like URLs. URLs are invalid input. */
-  for (i = 0; i < targets->nelts; i++)
-    {
-      const char *target = APR_ARRAY_IDX(targets, i, const char *);
-
-      if (svn_path_is_url(target))
-        return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
-                                 _("'%s' is not a local path"), target);
-    }
+  SVN_ERR(svn_cl__check_targets_are_local_paths(targets));
 
   iterpool = svn_pool_create(scratch_pool);
   for (i = 0; i < targets->nelts; i++)

Modified: subversion/trunk/subversion/svn/util.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/util.c?rev=1139360&r1=1139359&r2=1139360&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/util.c (original)
+++ subversion/trunk/subversion/svn/util.c Fri Jun 24 15:48:11 2011
@@ -1389,6 +1389,22 @@ svn_cl__assert_homogeneous_target_type(c
   return err;
 }
 
+svn_error_t *
+svn_cl__check_targets_are_local_paths(const apr_array_header_t *targets)
+{
+  int i;
+
+  for (i = 0; i < targets->nelts; i++)
+    {
+      const char *target = APR_ARRAY_IDX(targets, i, const char *);
+
+      if (svn_path_is_url(target))
+        return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+                                 _("'%s' is not a local path"), target);
+    }
+  return SVN_NO_ERROR;
+}
+
 const char *
 svn_cl__local_style_skip_ancestor(const char *parent_path,
                                   const char *path,



Mime
View raw message