subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhuij...@apache.org
Subject svn commit: r952016 - in /subversion/trunk/subversion/libsvn_wc: deprecated.c update_editor.c wc-queries.sql wc_db.c wc_db.h
Date Sun, 06 Jun 2010 22:31:37 GMT
Author: rhuijben
Date: Sun Jun  6 22:31:37 2010
New Revision: 952016

URL: http://svn.apache.org/viewvc?rev=952016&view=rev
Log:
As a tiny bit of help in resolving issue #3499, stop retrieving all children
from a parent directory to just to find if a directory is recorded in the
parent.

* subversion/libsvn_wc/deprecated.c
  (svn_wc_is_wc_root): Keep historic behavior.

* subversion/libsvn_wc/update_editor.c
  (already_in_a_tree_conflict): Don't bail if an ancestor is not a working
    copy. (Triggered by externals_tests.py 3)

* subversion/libsvn_wc/wc-queries.sql
  (STMT_SELECT_SUBDIR): New statement.

* subversion/libsvn_wc/wc_db.c
  (navigate_to_parent): Add assertion.
  (svn_wc__db_is_wcroot): New function.

* subversion/libsvn_wc/wc_db.h
  (svn_wc__db_is_wcroot): New function.

Modified:
    subversion/trunk/subversion/libsvn_wc/deprecated.c
    subversion/trunk/subversion/libsvn_wc/update_editor.c
    subversion/trunk/subversion/libsvn_wc/wc-queries.sql
    subversion/trunk/subversion/libsvn_wc/wc_db.c
    subversion/trunk/subversion/libsvn_wc/wc_db.h

Modified: subversion/trunk/subversion/libsvn_wc/deprecated.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/deprecated.c?rev=952016&r1=952015&r2=952016&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/deprecated.c (original)
+++ subversion/trunk/subversion/libsvn_wc/deprecated.c Sun Jun  6 22:31:37 2010
@@ -2746,13 +2746,25 @@ svn_wc_is_wc_root(svn_boolean_t *wc_root
 {
   svn_wc_context_t *wc_ctx;
   const char *local_abspath;
+  svn_error_t *err;
 
   SVN_ERR(svn_dirent_get_absolute(&local_abspath, path, pool));
   SVN_ERR(svn_wc__context_create_with_db(&wc_ctx, NULL /* config */,
                                          svn_wc__adm_get_db(adm_access),
                                          pool));
 
-  SVN_ERR(svn_wc_is_wc_root2(wc_root, wc_ctx, local_abspath, pool));
+  err = svn_wc_is_wc_root2(wc_root, wc_ctx, local_abspath, pool);
+
+  if (err
+      && (err->apr_err == SVN_ERR_WC_NOT_WORKING_COPY
+          || err->apr_err == SVN_ERR_WC_PATH_NOT_FOUND))
+    {
+      /* Subversion <= 1.6 just said that a not versioned path is not a root */
+      svn_error_clear(err);
+      *wc_root = FALSE;
+    }
+  else
+    SVN_ERR(err);
 
   return svn_error_return(svn_wc_context_destroy(wc_ctx));
 }

Modified: subversion/trunk/subversion/libsvn_wc/update_editor.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/update_editor.c?rev=952016&r1=952015&r2=952016&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/update_editor.c (original)
+++ subversion/trunk/subversion/libsvn_wc/update_editor.c Sun Jun  6 22:31:37 2010
@@ -1965,8 +1965,18 @@ already_in_a_tree_conflict(svn_boolean_t
       if (svn_dirent_is_root(ancestor_abspath, strlen(ancestor_abspath)))
         break;
 
-      SVN_ERR(svn_wc__check_wc_root(&is_wc_root, NULL, NULL,
-                                    db, ancestor_abspath, iterpool));
+      err = svn_wc__check_wc_root(&is_wc_root, NULL, NULL,
+                                  db, ancestor_abspath, iterpool);
+
+      if (err
+          && (err->apr_err == SVN_ERR_WC_PATH_NOT_FOUND
+              || err->apr_err == SVN_ERR_WC_NOT_WORKING_COPY))
+        {
+          svn_error_clear(err);
+          return SVN_NO_ERROR;
+        }
+      else
+        SVN_ERR(err);
 
       ancestor_abspath = svn_dirent_dirname(ancestor_abspath, scratch_pool);
     }
@@ -5525,7 +5535,6 @@ svn_wc__check_wc_root(svn_boolean_t *wc_
 {
   const char *parent_abspath, *name;
   const char *repos_relpath, *repos_root, *repos_uuid;
-  svn_error_t *err;
   svn_wc__db_status_t status;
   svn_wc__db_kind_t my_kind;
 
@@ -5535,7 +5544,6 @@ svn_wc__check_wc_root(svn_boolean_t *wc_
     kind = &my_kind;
 
   *wc_root = TRUE;
-  *kind = svn_node_dir;
   if (switched)
     *switched = FALSE;
 
@@ -5580,71 +5588,49 @@ svn_wc__check_wc_root(svn_boolean_t *wc_
   svn_dirent_split(local_abspath, &parent_abspath, &name, scratch_pool);
 
   /* Check if the node is recorded in the parent */
-  {
-    const apr_array_header_t *children;
-    svn_boolean_t found = FALSE;
-    int i;
-
-    err = svn_wc__db_read_children(&children, db, parent_abspath,
-                                   scratch_pool, scratch_pool);
-    if (err)
-      {
-        if (err->apr_err != SVN_ERR_WC_PATH_NOT_FOUND
-            && err->apr_err != SVN_ERR_WC_NOT_WORKING_COPY
-            && err->apr_err != SVN_ERR_WC_UPGRADE_REQUIRED)
-          return svn_error_return(err);
+  if (*wc_root)
+    {
+      svn_boolean_t is_root;
+      SVN_ERR(svn_wc__db_is_wcroot(&is_root, db, local_abspath, scratch_pool));
 
-        svn_error_clear(err);
-        return SVN_NO_ERROR;
-      }
-    else
-      for (i = 0; i < children->nelts; i++)
+      if (is_root)
         {
-          if (strcmp(APR_ARRAY_IDX(children, i, const char *), name) == 0)
-            {
-              found = TRUE;
-              break;
-            }
+          /* We're not in the (versioned) parent directory's list of
+             children, so we must be the root of a distinct working copy.  */
+          return SVN_NO_ERROR;
         }
+    }
+
+  {
+    const char *parent_repos_root;
+    const char *parent_repos_relpath;
+    const char *parent_repos_uuid;
+
+    SVN_ERR(svn_wc__db_scan_base_repos(&parent_repos_relpath,
+                                       &parent_repos_root,
+                                       &parent_repos_uuid,
+                                       db, parent_abspath,
+                                       scratch_pool, scratch_pool));
 
-    if (!found)
+    if (strcmp(repos_root, parent_repos_root) != 0
+        || strcmp(repos_uuid, parent_repos_uuid) != 0)
       {
-        /* We're not in the (versioned) parent directory's list of
-           children, so we must be the root of a distinct working copy.  */
+        /* This should never happen (### until we get mixed-repos working
+           copies). If we're in the parent, then we should be from the
+           same repository. For this situation, just declare us the root
+           of a separate, unswitched working copy.  */
         return SVN_NO_ERROR;
       }
-  }
-
-    {
-      const char *parent_repos_root;
-      const char *parent_repos_relpath;
-      const char *parent_repos_uuid;
-
-      SVN_ERR(svn_wc__db_scan_base_repos(&parent_repos_relpath,
-                                         &parent_repos_root,
-                                         &parent_repos_uuid,
-                                         db, parent_abspath,
-                                         scratch_pool, scratch_pool));
-
-      if (strcmp(repos_root, parent_repos_root) != 0
-          || strcmp(repos_uuid, parent_repos_uuid) != 0)
-        {
-          /* This should never happen (### until we get mixed-repos working
-             copies). If we're in the parent, then we should be from the
-             same repository. For this situation, just declare us the root
-             of a separate, unswitched working copy.  */
-          return SVN_NO_ERROR;
-        }
 
-      *wc_root = FALSE;
+    *wc_root = FALSE;
 
-      if (switched)
-        {
-          const char *expected_relpath = svn_relpath_join(parent_repos_relpath,
-                                                          name, scratch_pool);
+    if (switched)
+      {
+        const char *expected_relpath = svn_relpath_join(parent_repos_relpath,
+                                                        name, scratch_pool);
 
-          *switched = (strcmp(expected_relpath, repos_relpath) != 0);
-        }
+        *switched = (strcmp(expected_relpath, repos_relpath) != 0);
+      }
     }
 
   return SVN_NO_ERROR;

Modified: subversion/trunk/subversion/libsvn_wc/wc-queries.sql
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc-queries.sql?rev=952016&r1=952015&r2=952016&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc-queries.sql (original)
+++ subversion/trunk/subversion/libsvn_wc/wc-queries.sql Sun Jun  6 22:31:37 2010
@@ -446,6 +446,11 @@ SELECT wc_id, ?3 AS local_relpath, ?4 AS
      prop_reject, changelist, text_mod, tree_conflict_data FROM ACTUAL_NODE
 WHERE wc_id = ?1 AND local_relpath = ?2;
 
+-- STMT_SELECT_SUBDIR
+SELECT 1 FROM BASE_NODE WHERE wc_id = ?1 and local_relpath = ?2 and kind = 'subdir'
+UNION
+SELECT 0 FROM WORKING_NODE WHERE wc_id = ?1 and local_relpath = ?2 and kind = 'subdir';
+
 /* ------------------------------------------------------------------------- */
 
 /* these are used in entries.c  */

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=952016&r1=952015&r2=952016&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Sun Jun  6 22:31:37 2010
@@ -531,6 +531,10 @@ navigate_to_parent(svn_wc__db_pdh_t **pa
       && (*parent_pdh)->wcroot != NULL)
     return SVN_NO_ERROR;
 
+  /* Make sure we don't see the root as its own parent */
+  SVN_ERR_ASSERT(!svn_dirent_is_root(child_pdh->local_abspath,
+                                     strlen(child_pdh->local_abspath)));
+
   parent_abspath = svn_dirent_dirname(child_pdh->local_abspath, scratch_pool);
   SVN_ERR(svn_wc__db_pdh_parse_local_abspath(parent_pdh, &local_relpath, db,
                               parent_abspath, smode,
@@ -6825,6 +6829,68 @@ svn_wc__db_node_hidden(svn_boolean_t *hi
   return SVN_NO_ERROR;
 }
 
+svn_error_t *
+svn_wc__db_is_wcroot(svn_boolean_t *is_root,
+                     svn_wc__db_t *db,
+                     const char *local_abspath,
+                     apr_pool_t *scratch_pool)
+{
+  svn_wc__db_pdh_t *pdh;
+  const char *local_relpath;
+  svn_sqlite__stmt_t *stmt;
+  svn_boolean_t got_row;
+
+  SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath));
+
+  SVN_ERR(svn_wc__db_pdh_parse_local_abspath(&pdh, &local_relpath, db,
+                              local_abspath, svn_sqlite__mode_readwrite,
+                              scratch_pool, scratch_pool));
+  VERIFY_USABLE_PDH(pdh);
+
+  if (*local_relpath != '\0')
+    {
+      *is_root = FALSE; /* Node is a file, or has a parent directory within
+                           the same wcroot */
+      return SVN_NO_ERROR;
+    }
+
+#ifndef SINGLE_DB
+  if (!svn_dirent_is_root(local_abspath, strlen(local_abspath)))
+    {
+      svn_error_t *err = navigate_to_parent(&pdh, db, pdh,
+                                            svn_sqlite__mode_readwrite,
+                                            scratch_pool);
+
+      if (err && err->apr_err == SVN_ERR_WC_NOT_WORKING_COPY)
+        {
+          svn_error_clear(err);
+          *is_root = TRUE;
+          return SVN_NO_ERROR;
+        }
+      SVN_ERR(err);
+
+      VERIFY_USABLE_PDH(pdh);
+
+      SVN_ERR(svn_sqlite__get_statement(&stmt, pdh->wcroot->sdb,
+                                     STMT_SELECT_SUBDIR));
+
+      SVN_ERR(svn_sqlite__bindf(stmt, "is", pdh->wcroot->wc_id,
+                                svn_dirent_basename(local_abspath, NULL)));
+
+      SVN_ERR(svn_sqlite__step(&got_row, stmt));
+      SVN_ERR(svn_sqlite__reset(stmt));
+
+      if (got_row)
+        {
+          *is_root = FALSE;
+          return SVN_NO_ERROR;
+        }
+    }  
+#endif
+   *is_root = TRUE;
+
+   return SVN_NO_ERROR;
+}
 
 svn_error_t *
 svn_wc__db_temp_wcroot_tempdir(const char **temp_dir_abspath,

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.h?rev=952016&r1=952015&r2=952016&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.h (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.h Sun Jun  6 22:31:37 2010
@@ -1613,6 +1613,17 @@ svn_wc__db_node_hidden(svn_boolean_t *hi
    ### changelist usage -- we may already assume the list fits in memory.
 */
 
+/* Checks if LOCAL_ABSPATH has a parent directory that knows about its
+ * existance. Set *IS_ROOT to FALSE if a parent is found, and to TRUE
+ * if there is no such parent.
+ */
+svn_error_t *
+svn_wc__db_is_wcroot(svn_boolean_t *is_root,
+                     svn_wc__db_t *db,
+                     const char *local_abspath,
+                     apr_pool_t *scratch_pool);
+
+
 
 /* @} */
 



Mime
View raw message