You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ju...@apache.org on 2010/12/08 14:31:50 UTC

svn commit: r1043409 - in /subversion/trunk/subversion: libsvn_client/update.c svn/update-cmd.c tests/cmdline/basic_tests.py tests/cmdline/externals_tests.py tests/cmdline/input_validation_tests.py tests/cmdline/svntest/actions.py

Author: julianfoad
Date: Wed Dec  8 13:31:50 2010
New Revision: 1043409

URL: http://svn.apache.org/viewvc?rev=1043409&view=rev
Log:
Make 'svn update' verify that URLs are not passed as targets.

* subversion/svn/update-cmd.c
  (svn_cl__update): Raise an error if a URL was passed.

* subversion/libsvn_client/update.c
  (svn_client_update4): Same, and also remove code that notifies 'Skipped'
    message for URL targets.

* subversion/tests/cmdline/input_validation_tests.py
  (invalid_update_targets, test_list): New test

* subversion/tests/cmdline/externals_tests.py
  (cannot_move_or_remove_file_externals,
   can_place_file_external_into_dir_external,
   external_into_path_with_spaces): Remove URL target from 'svn up' command.

* subversion/tests/cmdline/svntest/actions.py
  (inject_conflict_into_wc): Same.

* subversion/tests/cmdline/basic_tests.py
  (basic_update): URLs are no longer accepted as targets. Remove test
    case for 'Skipped' message.

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

Modified:
    subversion/trunk/subversion/libsvn_client/update.c
    subversion/trunk/subversion/svn/update-cmd.c
    subversion/trunk/subversion/tests/cmdline/basic_tests.py
    subversion/trunk/subversion/tests/cmdline/externals_tests.py
    subversion/trunk/subversion/tests/cmdline/input_validation_tests.py
    subversion/trunk/subversion/tests/cmdline/svntest/actions.py

Modified: subversion/trunk/subversion/libsvn_client/update.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/update.c?rev=1043409&r1=1043408&r2=1043409&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/update.c (original)
+++ subversion/trunk/subversion/libsvn_client/update.c Wed Dec  8 13:31:50 2010
@@ -397,10 +397,19 @@ svn_client_update4(apr_array_header_t **
 
   for (i = 0; i < paths->nelts; ++i)
     {
+      path = APR_ARRAY_IDX(paths, i, const char *);
+
+      if (svn_path_is_url(path))
+        return svn_error_createf(SVN_ERR_ILLEGAL_TARGET, NULL,
+                                 _("'%s' is not a local path"), path);
+    }
+
+  for (i = 0; i < paths->nelts; ++i)
+    {
       svn_boolean_t sleep;
-      svn_boolean_t skipped = FALSE;
       svn_error_t *err = SVN_NO_ERROR;
       svn_revnum_t result_rev;
+      const char *local_abspath;
       path = APR_ARRAY_IDX(paths, i, const char *);
 
       svn_pool_clear(subpool);
@@ -408,57 +417,30 @@ svn_client_update4(apr_array_header_t **
       if (ctx->cancel_func && (err = ctx->cancel_func(ctx->cancel_baton)))
         break;
 
-      if (svn_path_is_url(path))
-        {
-          skipped = TRUE;
-        }
-      else
-        {
-          const char *local_abspath;
-
-          SVN_ERR(svn_dirent_get_absolute(&local_abspath, path, subpool));
-          err = svn_client__update_internal(&result_rev, local_abspath,
-                                            revision, depth, depth_is_sticky,
-                                            ignore_externals,
-                                            allow_unver_obstructions,
-                                            &sleep, FALSE, make_parents,
-                                            ctx, subpool);
-
-          if (err && err->apr_err != SVN_ERR_WC_NOT_WORKING_COPY)
-            {
-              return svn_error_return(err);
-            }
+      SVN_ERR(svn_dirent_get_absolute(&local_abspath, path, subpool));
+      err = svn_client__update_internal(&result_rev, local_abspath,
+                                        revision, depth, depth_is_sticky,
+                                        ignore_externals,
+                                        allow_unver_obstructions,
+                                        &sleep, FALSE, make_parents,
+                                        ctx, subpool);
 
-          if (err)
-            {
-              /* SVN_ERR_WC_NOT_WORKING_COPY: it's not versioned */
-              svn_error_clear(err);
-              skipped = TRUE;
-            }
+      if (err && err->apr_err != SVN_ERR_WC_NOT_WORKING_COPY)
+        {
+          return svn_error_return(err);
         }
 
-      if (skipped)
+      if (err)
         {
+          /* SVN_ERR_WC_NOT_WORKING_COPY: it's not versioned */
+          svn_error_clear(err);
           result_rev = SVN_INVALID_REVNUM;
           if (ctx->notify_func2)
             {
               svn_wc_notify_t *notify;
-
-              if (svn_path_is_url(path))
-                {
-                  /* For some historic reason this user error is supported,
-                     and must provide correct notifications. */
-                  notify = svn_wc_create_notify_url(path,
-                                                    svn_wc_notify_skip,
-                                                    subpool);
-                }
-              else
-                {
-                  notify = svn_wc_create_notify(path,
-                                                svn_wc_notify_skip,
-                                                subpool);
-                }
-
+              notify = svn_wc_create_notify(path,
+                                            svn_wc_notify_skip,
+                                            subpool);
               (*ctx->notify_func2)(ctx->notify_baton2, notify, subpool);
             }
         }

Modified: subversion/trunk/subversion/svn/update-cmd.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/update-cmd.c?rev=1043409&r1=1043408&r2=1043409&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/update-cmd.c (original)
+++ subversion/trunk/subversion/svn/update-cmd.c Wed Dec  8 13:31:50 2010
@@ -110,6 +110,7 @@ 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,
@@ -120,29 +121,15 @@ svn_cl__update(apr_getopt_t *os,
 
   SVN_ERR(svn_cl__eat_peg_revisions(&targets, targets, scratch_pool));
 
-  /* If any targets are URLs, notify that we're skipping them and remove
-     them from TARGETS.  Although svn_client_update4() would skip them
-     anyway, we don't want to pass invalid targets to it, and especially
-     not to print_update_summary(). */
-  {
-    apr_array_header_t *new_targets
-      = apr_array_make(scratch_pool, targets->nelts, sizeof(const char *));
-    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))
-          ctx->notify_func2(ctx->notify_baton2,
-                            svn_wc_create_notify_url(
-                              target, svn_wc_notify_skip, scratch_pool),
-                            scratch_pool);
-        else
-          APR_ARRAY_PUSH(new_targets, const char *) = target;
-      }
-    targets = new_targets;
-  }
+  /* 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);
+    }
 
   /* If using changelists, convert targets into a set of paths that
      match the specified changelist(s). */

Modified: subversion/trunk/subversion/tests/cmdline/basic_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/basic_tests.py?rev=1043409&r1=1043408&r2=1043409&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/basic_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/basic_tests.py Wed Dec  8 13:31:50 2010
@@ -211,16 +211,6 @@ def basic_update(sbox):
     "update xx/xx", [], [],
     'update', '--quiet', xx_path)
 
-  # URL's are also skipped.
-  urls = ('http://localhost/a/b/c', 'http://localhost', 'svn://localhost')
-  for url in urls:
-    exit_code, out, err = svntest.actions.run_and_verify_svn(
-      "update " + url,
-      ["Skipped '"+url+"'\n",
-      "Summary of conflicts:\n",
-      "  Skipped paths: 1\n"], [],
-      'update', url)
-
 #----------------------------------------------------------------------
 def basic_mkdir_url(sbox):
   "basic mkdir URL"

Modified: subversion/trunk/subversion/tests/cmdline/externals_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/externals_tests.py?rev=1043409&r1=1043408&r2=1043409&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/externals_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/externals_tests.py Wed Dec  8 13:31:50 2010
@@ -1007,8 +1007,7 @@ def cannot_move_or_remove_file_externals
   # Bring the working copy up to date and check that the file the file
   # external is switched to still exists.
   svntest.actions.run_and_verify_svn(None, None, [],
-                                     'up',
-                                     repo_url, wc_dir)
+                                     'up', wc_dir)
 
   open(os.path.join(wc_dir, 'A', 'D', 'gamma')).close()
 
@@ -1036,8 +1035,7 @@ def can_place_file_external_into_dir_ext
   # Bring the working copy up to date and check that the file the file
   # external is switched to still exists.
   svntest.actions.run_and_verify_svn(None, None, [],
-                                     'up',
-                                     repo_url, wc_dir)
+                                     'up', wc_dir)
 
   beta1_path = os.path.join(wc_dir, 'A', 'B', 'E', 'beta')
   beta1_contents = open(beta1_path).read()
@@ -1064,8 +1062,7 @@ def can_place_file_external_into_dir_ext
                                       None,
                                       expected_error,
                                       1,
-                                      'up',
-                                      repo_url, wc_dir)
+                                      'up', wc_dir)
 
 #----------------------------------------------------------------------
 
@@ -1082,8 +1079,7 @@ def external_into_path_with_spaces(sbox)
   change_external(wc_dir, ext)
 
   svntest.actions.run_and_verify_svn(None, None, [],
-                                     'up',
-                                     repo_url, wc_dir)
+                                     'up', wc_dir)
   probe_paths_exist([
       os.path.join(wc_dir, 'A', 'copy of D'),
       os.path.join(wc_dir, 'A', 'another copy of D'),
@@ -1334,8 +1330,7 @@ def relegate_external(sbox):
   externals_desc = '^/A/B/E        external'
   change_external(A_path, externals_desc)
   svntest.actions.run_and_verify_svn(None, None, [],
-                                     'up',
-                                     repo_url, wc_dir)
+                                     'up', wc_dir)
 
   # create another repository
   other_repo_dir, other_repo_url = sbox.add_repo_path('other')

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=1043409&r1=1043408&r2=1043409&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/input_validation_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/input_validation_tests.py Wed Dec  8 13:31:50 2010
@@ -242,6 +242,12 @@ def invalid_mkdir_targets(sbox):
   run_and_verify_svn_in_wc(sbox, "svn: Cannot mix repository and working "
                            "copy targets", 'mkdir', "folder", "^/folder")
 
+def invalid_update_targets(sbox):
+  "non-working copy paths for 'update'"
+  sbox.build(read_only=True)
+  run_and_verify_svn_in_wc(sbox, "svn:.*is not a local path", 'update',
+                           "^/")
+
 ########################################################################
 # Run the tests
 
@@ -270,6 +276,7 @@ test_list = [ None,
               invalid_switch_targets,
               invalid_relocate_targets,
               invalid_mkdir_targets,
+              invalid_update_targets,
              ]
 
 if __name__ == '__main__':

Modified: subversion/trunk/subversion/tests/cmdline/svntest/actions.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svntest/actions.py?rev=1043409&r1=1043408&r2=1043409&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svntest/actions.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svntest/actions.py Wed Dec  8 13:31:50 2010
@@ -1852,7 +1852,6 @@ def inject_conflict_into_wc(sbox, state_
                                       conflicting_contents, contents,
                                       merged_rev)
   exit_code, output, errput = main.run_svn(None, "up", "-r", str(merged_rev),
-                                           sbox.repo_url + "/" + state_path,
                                            file_path)
   if expected_status:
     expected_status.tweak(state_path, wc_rev=merged_rev)