You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by rh...@apache.org on 2011/04/05 02:51:25 UTC

svn commit: r1088837 - in /subversion/trunk/subversion: libsvn_client/update.c libsvn_wc/update_editor.c tests/cmdline/update_tests.py

Author: rhuijben
Date: Tue Apr  5 00:51:25 2011
New Revision: 1088837

URL: http://svn.apache.org/viewvc?rev=1088837&view=rev
Log:
Remove another database read transaction for every added file from update,
checkout and switch as we already know that we won't find the node when
retrieving its url.

* subversion/libsvn_client/update.c
  (update_internal): Don't even try to run an invalid update which used to be
    handled as a no-op.

* subversion/libsvn_wc/update_editor.c
  (node_get_relpath_ignore_errors): Remove unneeded helper.
  (make_dir_baton): Directly use svn_wc__db_scan_base_repos() as we only want
    to look at base nodes and we know that there already is one.
    Looking at working nodes is not possible with editor v1, as we need the
    base vs working information for tree conflict handling.

* subversion/tests/cmdline/update_tests.py
  (update_nonexistent_child_of_copy): Update expected result.

Modified:
    subversion/trunk/subversion/libsvn_client/update.c
    subversion/trunk/subversion/libsvn_wc/update_editor.c
    subversion/trunk/subversion/tests/cmdline/update_tests.py

Modified: subversion/trunk/subversion/libsvn_client/update.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/update.c?rev=1088837&r1=1088836&r2=1088837&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/update.c (original)
+++ subversion/trunk/subversion/libsvn_client/update.c Tue Apr  5 00:51:25 2011
@@ -111,6 +111,21 @@ update_internal(svn_revnum_t *result_rev
                              _("'%s' has no URL"),
                              svn_dirent_local_style(anchor_abspath, pool));
 
+  /* Check if our anchor exists in BASE. If it doesn't we can't update.
+     ### For performance reasons this should be handled with the same query
+     ### as retrieving the anchor url. */
+  SVN_ERR(svn_wc__node_get_base_rev(&revnum, ctx->wc_ctx, anchor_abspath,
+                                    pool));
+
+  if (!SVN_IS_VALID_REVNUM(revnum))
+    return svn_error_createf(SVN_ERR_ILLEGAL_TARGET, NULL,
+                             _("'%s' does not exist in the repository yet,"
+                               " which makes it is impossible to update '%s'."),
+                             svn_dirent_local_style(anchor_abspath,
+                                                    pool),
+                             svn_dirent_basename(local_abspath, NULL));
+
+
   /* We may need to crop the tree if the depth is sticky */
   if (depth_is_sticky && depth < svn_depth_infinity)
     {

Modified: subversion/trunk/subversion/libsvn_wc/update_editor.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/update_editor.c?rev=1088837&r1=1088836&r2=1088837&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/update_editor.c (original)
+++ subversion/trunk/subversion/libsvn_wc/update_editor.c Tue Apr  5 00:51:25 2011
@@ -433,56 +433,6 @@ get_empty_tmp_file(const char **tmp_file
                                                   result_pool));
 }
 
-
-/* Return the repository relative path for LOCAL_ABSPATH allocated in
- * RESULT_POOL, or NULL if unable to obtain.
- *
- * Use DB to retrieve information on LOCAL_ABSPATH, and do all temporary
- * allocation in SCRATCH_POOL.
- */
-static const char *
-node_get_relpath_ignore_errors(svn_wc__db_t *db,
-                               const char *local_abspath,
-                               apr_pool_t *result_pool,
-                               apr_pool_t *scratch_pool)
-{
-  svn_wc__db_status_t status;
-  svn_error_t *err;
-  const char *relpath = NULL;
-
-  err = svn_wc__db_read_info(&status, NULL, NULL, &relpath, NULL, NULL, NULL,
-                             NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-                             NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-                             NULL,
-                             db, local_abspath, result_pool, scratch_pool);
-
-  if (err)
-    {
-      svn_error_clear(err);
-      return NULL;
-    }
-
-  if (relpath)
-    return relpath;
-
-  if (status == svn_wc__db_status_added)
-    {
-      svn_error_clear(svn_wc__db_scan_addition(NULL, NULL, &relpath, NULL,
-                                               NULL, NULL, NULL, NULL, NULL,
-                                               db, local_abspath,
-                                               result_pool, scratch_pool));
-    }
-  else if (status != svn_wc__db_status_deleted)
-    {
-      svn_error_clear(svn_wc__db_scan_base_repos(&relpath, NULL, NULL,
-                                                 db, local_abspath,
-                                                 result_pool, scratch_pool));
-    }
-
-  return relpath;
-}
-
-
 /* An APR pool cleanup handler.  This runs the log file for a
    directory baton. */
 static apr_status_t
@@ -610,34 +560,9 @@ make_dir_baton(struct dir_baton **d_p,
         }
       else
         {
-          /* Get the original REPOS_RELPATH. An update will not be
-             changing its value.  */
-          svn_wc__db_status_t status;
-          const char *repos_relpath, *original_repos_relpath;
-          SVN_ERR(svn_wc__db_read_info(&status, NULL, NULL, &repos_relpath,
-                                       NULL, NULL, NULL, NULL, NULL, NULL,
-                                       NULL, NULL, NULL, NULL, NULL,
-                                       &original_repos_relpath,
-                                       NULL, NULL, NULL, NULL, NULL, NULL,
-                                       NULL, NULL,
-                                       eb->db, d->local_abspath,
-                                       dir_pool, scratch_pool));
-          if (status == svn_wc__db_status_added)
-            SVN_ERR(svn_wc__db_scan_addition(NULL, NULL,
-                                             &repos_relpath, NULL, NULL,
-                                             &original_repos_relpath, NULL, NULL,
-                                             NULL,
+          SVN_ERR(svn_wc__db_scan_base_repos(&d->new_relpath, NULL, NULL,
                                              eb->db, d->local_abspath,
                                              dir_pool, scratch_pool));
-
-          if (original_repos_relpath)
-            d->new_relpath = original_repos_relpath;
-          else if (repos_relpath)
-            d->new_relpath = repos_relpath;
-          else
-            SVN_ERR(svn_wc__db_scan_base_repos(&d->new_relpath, NULL, NULL,
-                                               eb->db, d->local_abspath,
-                                               dir_pool, scratch_pool));
           SVN_ERR_ASSERT(d->new_relpath);
         }
     }
@@ -1001,17 +926,17 @@ make_file_baton(struct file_baton **f_p,
   f->local_abspath = svn_dirent_join(pb->local_abspath, f->name, file_pool);
 
   /* Figure out the new_URL for this file. */
-  if (pb->edit_baton->switch_relpath)
+  if (adding || pb->edit_baton->switch_relpath)
     f->new_relpath = svn_relpath_join(pb->new_relpath, f->name, file_pool);
   else
-    f->new_relpath = node_get_relpath_ignore_errors(pb->edit_baton->db,
-                                                    f->local_abspath,
-                                                    file_pool, scratch_pool);
-
-  /* ### why the complicated logic above. isn't it always this way?
-     ### file externals are probably special/different?  */
-  if (f->new_relpath == NULL)
-    f->new_relpath = svn_relpath_join(pb->new_relpath, f->name, file_pool);
+    {
+      SVN_ERR(svn_wc__db_scan_base_repos(&f->new_relpath, NULL, NULL,
+                                         pb->edit_baton->db,
+                                         f->local_abspath,
+                                         file_pool, scratch_pool));
+
+      SVN_ERR_ASSERT(f->new_relpath);
+    }
 
   f->pool              = file_pool;
   f->edit_baton        = pb->edit_baton;

Modified: subversion/trunk/subversion/tests/cmdline/update_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/update_tests.py?rev=1088837&r1=1088836&r2=1088837&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/update_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/update_tests.py Tue Apr  5 00:51:25 2011
@@ -5355,11 +5355,12 @@ def update_nonexistent_child_of_copy(sbo
   svntest.main.run_svn(None, 'copy', 'A', 'A2')
 
   # Try updating a nonexistent path in the copied dir.
-  svntest.main.run_svn(None, 'update', os.path.join('A2', 'nonexistent'))
+  expected_error = "svn: E200009: '.*' does not exist in the repository yet"
+  svntest.main.run_svn(expected_error, 'update', os.path.join('A2', 'nonexistent'))
 
   # Try updating a deleted path in the copied dir.
   svntest.main.run_svn(None, 'delete', os.path.join('A2', 'mu'))
-  svntest.main.run_svn(None, 'update', os.path.join('A2', 'mu'))
+  svntest.main.run_svn(expected_error, 'update', os.path.join('A2', 'mu'))
   if os.path.exists('A2/mu'):
     raise svntest.Failure("A2/mu improperly revived")