subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhuij...@apache.org
Subject svn commit: r1412636 - in /subversion/trunk/subversion/libsvn_wc: lock.c props.c update_editor.c wc_db.c wc_db.h
Date Thu, 22 Nov 2012 18:37:09 GMT
Author: rhuijben
Date: Thu Nov 22 18:37:07 2012
New Revision: 1412636

URL: http://svn.apache.org/viewvc?rev=1412636&view=rev
Log:
Following up on r1412632, fix name of new svn_wc__db_ function and use this
function for all calculations on where to obtain a working copy lock.

* subversion/libsvn_wc/lock.c
  (child_is_disjoint): Simplify function by using svn_wc__db_is_switched().
  (svn_wc__acquire_write_lock): Use svn_wc__db_is_switched() instead of all
    the separate db calls. Remove tests on cases that could never happen since
    the switch to a single database per working copy.

* subversion/libsvn_wc/props.c
  (svn_wc__internal_get_iprops): Update caller.

* subversion/libsvn_wc/update_editor.c
  (svn_wc__check_wc_root): Update caller.

* subversion/libsvn_wc/wc_db.c
  (db_is_switched): Return error on 'hidden' nodes, even when they have a
    repos_relpath.
  (svn_wc_db__is_switched): Rename to...
  (svn_wc__db_is_switched): ... this.

* subversion/libsvn_wc/wc_db.h
  (svn_wc_db__is_switched): Rename to...
  (svn_wc__db_is_switched): ... this.

Modified:
    subversion/trunk/subversion/libsvn_wc/lock.c
    subversion/trunk/subversion/libsvn_wc/props.c
    subversion/trunk/subversion/libsvn_wc/update_editor.c
    subversion/trunk/subversion/libsvn_wc/wc_db.c
    subversion/trunk/subversion/libsvn_wc/wc_db.h

Modified: subversion/trunk/subversion/libsvn_wc/lock.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/lock.c?rev=1412636&r1=1412635&r2=1412636&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/lock.c (original)
+++ subversion/trunk/subversion/libsvn_wc/lock.c Thu Nov 22 18:37:07 2012
@@ -1066,75 +1066,21 @@ child_is_disjoint(svn_boolean_t *disjoin
                   const char *local_abspath,
                   apr_pool_t *scratch_pool)
 {
-  const char *node_repos_root, *node_repos_relpath, *node_repos_uuid;
-  const char *parent_repos_root, *parent_repos_relpath, *parent_repos_uuid;
-  svn_wc__db_status_t parent_status;
-  const char *parent_abspath, *base;
+  svn_boolean_t is_switched;
 
   /* Check if the parent directory knows about this node */
-  SVN_ERR(svn_wc__db_is_wcroot(disjoint, db, local_abspath, scratch_pool));
+  SVN_ERR(svn_wc__db_is_switched(disjoint, &is_switched, NULL,
+                                 db, local_abspath, scratch_pool));
 
   if (*disjoint)
     return SVN_NO_ERROR;
 
-  svn_dirent_split(&parent_abspath, &base, local_abspath, scratch_pool);
-
-  SVN_ERR(svn_wc__db_read_info(NULL, NULL, NULL, &node_repos_relpath,
-                               &node_repos_root, &node_repos_uuid, NULL, NULL,
-                               NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-                               NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-                               NULL, NULL, NULL,
-                               db, local_abspath,
-                               scratch_pool, scratch_pool));
-
-  /* If the node does not have its own repos_relpath, its value is inherited
-     from a parent node, which implies that the node is not disjoint. */
-  if (node_repos_relpath == NULL)
-    {
-      *disjoint = FALSE;
-      return SVN_NO_ERROR;
-    }
-
-  SVN_ERR(svn_wc__db_read_info(&parent_status, NULL, NULL,
-                               &parent_repos_relpath, &parent_repos_root,
-                               &parent_repos_uuid, NULL, NULL,
-                               NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-                               NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-                               NULL, NULL, NULL,
-                               db, parent_abspath,
-                               scratch_pool, scratch_pool));
-
-  if (parent_repos_relpath == NULL)
-    {
-      if (parent_status == svn_wc__db_status_added)
-        SVN_ERR(svn_wc__db_scan_addition(NULL, NULL, &parent_repos_relpath,
-                                         &parent_repos_root,
-                                         &parent_repos_uuid,
-                                         NULL, NULL, NULL, NULL, NULL, NULL,
-                                         db, parent_abspath,
-                                         scratch_pool, scratch_pool));
-      else
-        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(parent_repos_root, node_repos_root) != 0 ||
-      strcmp(parent_repos_uuid, node_repos_uuid) != 0 ||
-      strcmp(svn_relpath_join(parent_repos_relpath, base, scratch_pool),
-             node_repos_relpath) != 0)
-    {
-      *disjoint = TRUE;
-    }
-  else
-    *disjoint = FALSE;
+  if (is_switched)
+    *disjoint = TRUE;
 
   return SVN_NO_ERROR;
 }
 
-
 /* */
 static svn_error_t *
 open_anchor(svn_wc_adm_access_t **anchor_access,
@@ -1522,13 +1468,25 @@ svn_wc__acquire_write_lock(const char **
                            apr_pool_t *scratch_pool)
 {
   svn_wc__db_t *db = wc_ctx->db;
+  svn_boolean_t is_wcroot;
+  svn_boolean_t is_switched;
   svn_kind_t kind;
   svn_error_t *err;
 
-  SVN_ERR(svn_wc__db_read_kind(&kind, wc_ctx->db, local_abspath,
-                               (lock_root_abspath != NULL) /* allow_missing*/,
-                               FALSE /* show_hidden */,
-                               scratch_pool));
+  err = svn_wc__db_is_switched(&is_wcroot, &is_switched, &kind,
+                               db, local_abspath, scratch_pool);
+
+  if (err)
+    {
+      if (err->apr_err != SVN_ERR_WC_PATH_NOT_FOUND)
+        return svn_error_trace(err);
+
+      svn_error_clear(err);
+
+      kind = svn_kind_none;
+      is_wcroot = FALSE;
+      is_switched = FALSE;
+    }
 
   if (!lock_root_abspath && kind != svn_kind_dir)
     return svn_error_createf(SVN_ERR_WC_NOT_DIRECTORY, NULL,
@@ -1538,15 +1496,6 @@ svn_wc__acquire_write_lock(const char **
 
   if (lock_anchor && kind == svn_kind_dir)
     {
-      svn_boolean_t is_wcroot;
-
-      SVN_ERR_ASSERT(lock_root_abspath != NULL);
-
-      /* Perform a cheap check to avoid looking for a parent working copy,
-         which might be very expensive in some specific scenarios */
-      SVN_ERR(svn_wc__db_is_wcroot(&is_wcroot, db, local_abspath,
-                                   scratch_pool));
-
       if (is_wcroot)
         lock_anchor = FALSE;
     }
@@ -1554,58 +1503,48 @@ svn_wc__acquire_write_lock(const char **
   if (lock_anchor)
     {
       const char *parent_abspath;
-      svn_kind_t parent_kind;
-
       SVN_ERR_ASSERT(lock_root_abspath != NULL);
 
       parent_abspath = svn_dirent_dirname(local_abspath, scratch_pool);
-      err = svn_wc__db_read_kind(&parent_kind, db, parent_abspath,
-                                 TRUE /* allow_missing */,
-                                 FALSE /* show_missing */,
-                                 scratch_pool);
-      if (err && SVN_WC__ERR_IS_NOT_CURRENT_WC(err))
+
+      if (kind == svn_kind_dir)
         {
-          svn_error_clear(err);
-          parent_kind = svn_kind_unknown;
+          if (! is_switched)
+            local_abspath = parent_abspath;
+        }
+      else if (kind != svn_kind_none && kind != svn_kind_unknown)
+        {
+          /* In the single-DB world we know parent exists */
+          local_abspath = parent_abspath;
         }
       else
-        SVN_ERR(err);
-
-      if (kind == svn_kind_dir && parent_kind == svn_kind_dir)
         {
-          svn_boolean_t disjoint;
-          SVN_ERR(child_is_disjoint(&disjoint, wc_ctx->db, local_abspath,
-                                    scratch_pool));
-          if (!disjoint)
-            local_abspath = parent_abspath;
+          /* Can't lock parents that don't exist */
+          svn_kind_t parent_kind;
+          err = svn_wc__db_read_kind(&parent_kind, db, parent_abspath,
+                                     TRUE /* allow_missing */,
+                                     FALSE /* show_hidden */,
+                                     scratch_pool);
+          if (err && SVN_WC__ERR_IS_NOT_CURRENT_WC(err))
+            {
+              svn_error_clear(err);
+              parent_kind = svn_kind_unknown;
+            }
+          else
+            SVN_ERR(err);
+
+          if (parent_kind != svn_kind_dir)
+            return svn_error_createf(SVN_ERR_WC_NOT_WORKING_COPY, NULL,
+                                     _("'%s' is not a working copy"),
+                                     svn_dirent_local_style(local_abspath,
+                                                            scratch_pool));
+
+          local_abspath = parent_abspath;
         }
-      else if (parent_kind == svn_kind_dir)
-        local_abspath = parent_abspath;
-      else if (kind != svn_kind_dir)
-        return svn_error_createf(SVN_ERR_WC_NOT_WORKING_COPY, NULL,
-                                 _("'%s' is not a working copy"),
-                                 svn_dirent_local_style(local_abspath,
-                                                        scratch_pool));
     }
   else if (kind != svn_kind_dir)
     {
       local_abspath = svn_dirent_dirname(local_abspath, scratch_pool);
-
-      /* Can't lock parents that don't exist */
-      if (kind == svn_kind_unknown)
-        {
-          SVN_ERR(svn_wc__db_read_kind(&kind, db, local_abspath,
-                                       FALSE /* allow_missing */,
-                                       FALSE /* show_hidden */,
-                                       scratch_pool));
-
-          if (kind != svn_kind_dir)
-            return svn_error_createf(
-                             SVN_ERR_WC_NOT_DIRECTORY, NULL,
-                             _("Can't obtain lock on non-directory '%s'."),
-                             svn_dirent_local_style(local_abspath,
-                                                    scratch_pool));
-        }
     }
 
   if (lock_root_abspath)

Modified: subversion/trunk/subversion/libsvn_wc/props.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/props.c?rev=1412636&r1=1412635&r2=1412636&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/props.c (original)
+++ subversion/trunk/subversion/libsvn_wc/props.c Thu Nov 22 18:37:07 2012
@@ -2386,7 +2386,7 @@ svn_wc__internal_get_iprops(apr_array_he
 
       svn_pool_clear(iterpool);
 
-      SVN_ERR(svn_wc_db__is_switched(&is_wc_root, &is_switched, NULL,
+      SVN_ERR(svn_wc__db_is_switched(&is_wc_root, &is_switched, NULL,
                                      db, parent_abspath, iterpool));
 
       if (is_switched || is_wc_root)

Modified: subversion/trunk/subversion/libsvn_wc/update_editor.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/update_editor.c?rev=1412636&r1=1412635&r2=1412636&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/update_editor.c (original)
+++ subversion/trunk/subversion/libsvn_wc/update_editor.c Thu Nov 22 18:37:07 2012
@@ -4999,7 +4999,7 @@ svn_wc__check_wc_root(svn_boolean_t *wc_
                       apr_pool_t *scratch_pool)
 {
   return svn_error_trace(
-            svn_wc_db__is_switched(wc_root, switched, kind,
+            svn_wc__db_is_switched(wc_root, switched, kind,
                                    db, local_abspath,
                                    scratch_pool));
 }

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=1412636&r1=1412635&r2=1412636&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Thu Nov 22 18:37:07 2012
@@ -12484,17 +12484,9 @@ db_is_switched(void *baton,
                     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                     wcroot, local_relpath, scratch_pool, scratch_pool));
 
-  if (! repos_relpath)
-    {
-      /* Node is shadowed; easy out */
-      if (isb->is_switched)
-        *isb->is_switched = FALSE;
-
-      return SVN_NO_ERROR;
-    }
-  else if (status == svn_wc__db_status_server_excluded
-           || status == svn_wc__db_status_excluded
-           || status == svn_wc__db_status_not_present)
+  if (status == svn_wc__db_status_server_excluded
+      || status == svn_wc__db_status_excluded
+      || status == svn_wc__db_status_not_present)
     {
       return svn_error_createf(
                     SVN_ERR_WC_PATH_NOT_FOUND, NULL,
@@ -12502,6 +12494,14 @@ db_is_switched(void *baton,
                     path_for_error_message(wcroot, local_relpath,
                                            scratch_pool));
     }
+  else if (! repos_relpath)
+    {
+      /* Node is shadowed; easy out */
+      if (isb->is_switched)
+        *isb->is_switched = FALSE;
+
+      return SVN_NO_ERROR;
+    }
 
   if (! isb->is_switched)
     return SVN_NO_ERROR;
@@ -12531,7 +12531,7 @@ db_is_switched(void *baton,
 }
 
 svn_error_t *
-svn_wc_db__is_switched(svn_boolean_t *is_wcroot,
+svn_wc__db_is_switched(svn_boolean_t *is_wcroot,
                        svn_boolean_t *is_switched,
                        svn_kind_t *kind,
                        svn_wc__db_t *db,

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.h?rev=1412636&r1=1412635&r2=1412636&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.h (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.h Thu Nov 22 18:37:07 2012
@@ -2297,7 +2297,7 @@ svn_wc__db_is_wcroot(svn_boolean_t *is_r
    interesting to the caller
  */
 svn_error_t *
-svn_wc_db__is_switched(svn_boolean_t *is_wcroot,
+svn_wc__db_is_switched(svn_boolean_t *is_wcroot,
                        svn_boolean_t *is_switched,
                        svn_kind_t *kind,
                        svn_wc__db_t *db,



Mime
View raw message