Author: rhuijben
Date: Wed May  4 10:35:22 2011
New Revision: 1099399

URL: http://svn.apache.org/viewvc?rev=1099399&view=rev
Log:
Add a new commit helper function in preparation for handling not-present
descendants of a copy outside the commit harvester step.

* subversion/include/private/svn_wc_private.h
  (svn_wc__get_not_present_descendants): New function.

* subversion/libsvn_wc/node.c
  (svn_wc__get_not_present_descendants): New function.

* subversion/libsvn_wc/wc-queries.sql
  (STMT_SELECT_not_present_DESCENDANTS): New query.
  (STMT_COMMIT_DESCENDANT_TO_BASE): Make every descendant node that is not
    status 'normal' 'not-present'. This applies only to nodes that you see
    as status deleted.

* subversion/libsvn_wc/wc_db.c
  (svn_wc__db_get_not_present_descendants): New function.

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

Modified:
    subversion/trunk/subversion/include/private/svn_wc_private.h
    subversion/trunk/subversion/libsvn_wc/node.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/include/private/svn_wc_private.h
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/include/private/svn_wc_private.h?rev=1099399&r1=1099398&r2=1099399&view=diff
==============================================================================
--- subversion/trunk/subversion/include/private/svn_wc_private.h (original)
+++ subversion/trunk/subversion/include/private/svn_wc_private.h Wed May  4 
10:35:22 2011
@@ -898,6 +898,19 @@ svn_wc__node_get_commit_status(svn_node_
                                apr_pool_t *result_pool,
                                apr_pool_t *scratch_pool);
 
+/* Gets an array of const char *repos_relpaths of descendants of LOCAL_ABSPATH,
+ * which must be the op root of an addition, copy or move. The descendants
+ * returned are at the same op_depth, but are to be deleted by the commit
+ * processing because they are not present in the local copy.
+ */
+svn_error_t *
+svn_wc__get_not_present_descendants(const apr_array_header_t **descendants,
+                                    svn_wc_context_t *wc_ctx,
+                                    const char *local_abspath,
+                                    apr_pool_t *result_pool,
+                                    apr_pool_t *scratch_pool);
+
+
 /* Checks a node LOCAL_ABSPATH in WC_CTX for several kinds of obstructions
  * for tasks like merge processing.
  *

Modified: subversion/trunk/subversion/libsvn_wc/node.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/node.c?rev=1099399&r1=1099398&r2=1099399&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/node.c (original)
+++ subversion/trunk/subversion/libsvn_wc/node.c Wed May  4 10:35:22 2011
@@ -1605,6 +1605,21 @@ svn_wc__node_get_commit_status(svn_node_
 }
 
 svn_error_t *
+svn_wc__get_not_present_descendants(const apr_array_header_t **descendants,
+                                    svn_wc_context_t *wc_ctx,
+                                    const char *local_abspath,
+                                    apr_pool_t *result_pool,
+                                    apr_pool_t *scratch_pool)
+{
+  return svn_error_return(
+                svn_wc__db_get_not_present_descendants(descendants,
+                                                       wc_ctx->db,
+                                                       local_abspath,
+                                                       result_pool,
+                                                       scratch_pool));
+}
+
+svn_error_t *
 svn_wc__rename_wc(svn_wc_context_t *wc_ctx,
                   const char *from_abspath,
                   const char *dst_abspath,

Modified: subversion/trunk/subversion/libsvn_wc/wc-queries.sql
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc-queries.sql?rev=1099399&r1=1099398&r2=1099399&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc-queries.sql (original)
+++ subversion/trunk/subversion/libsvn_wc/wc-queries.sql Wed May  4 10:35:22 
2011
@@ -170,15 +170,18 @@ WHERE wc_id = ?1
   AND (op_depth < ?3
        OR (op_depth = ?3 AND presence = 'base-deleted'))
 
+-- STMT_SELECT_NOT_PRESENT_DESCENDANTS
+SELECT local_relpath FROM nodes
+WHERE wc_id = ?1 AND op_depth = ?3
+  AND (parent_relpath = ?2
+       OR ((parent_relpath > ?2 || '/') AND (parent_relpath < ?2 || '0')))
+  AND presence == 'not-present'
+
 -- STMT_COMMIT_DESCENDANT_TO_BASE
 UPDATE NODES SET op_depth = 0, repos_id = ?4, repos_path = ?5, revision = ?6,
   moved_here = NULL, moved_to = NULL, dav_cache = NULL,
-  presence = CASE WHEN presence IN ('not-present', 'excluded')
-                       AND EXISTS(SELECT 1 FROM NODES WHERE wc_id = ?1 
-                                   AND local_relpath = ?2 AND op_depth > ?3)
-                  THEN 'excluded' ELSE presence END
+  presence = CASE presence WHEN 'normal' THEN 'normal' ELSE 'not-present' END
 WHERE wc_id = ?1 AND local_relpath = ?2 and op_depth = ?3
-  AND presence IN ('normal', 'excluded', 'not-present')
 
 -- STMT_SELECT_NODE_CHILDREN
 /* Return all paths that are children of the directory (?1, ?2) in any

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=1099399&r1=1099398&r2=1099399&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Wed May  4 10:35:22 2011
@@ -10607,6 +10607,58 @@ svn_wc__db_info_below_working(svn_boolea
   return SVN_NO_ERROR;
 }
 
+svn_error_t *
+svn_wc__db_get_not_present_descendants(const apr_array_header_t **descendants,
+                                       svn_wc__db_t *db,
+                                       const char *local_abspath,
+                                       apr_pool_t *result_pool,
+                                       apr_pool_t *scratch_pool)
+{
+  svn_wc__db_wcroot_t *wcroot;
+  const char *local_relpath;
+  svn_sqlite__stmt_t *stmt;
+  svn_boolean_t have_row;
+
+  SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath));
+
+  SVN_ERR(svn_wc__db_wcroot_parse_local_abspath(&wcroot, &local_relpath, db,
+                              local_abspath, scratch_pool, scratch_pool));
+  VERIFY_USABLE_WCROOT(wcroot);
+
+  SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
+                                    STMT_SELECT_NOT_PRESENT_DESCENDANTS));
+
+  SVN_ERR(svn_sqlite__bindf(stmt, "isi",
+                            wcroot->wc_id,
+                            local_relpath,
+                            (apr_int64_t)relpath_depth(local_relpath)));
+
+  SVN_ERR(svn_sqlite__step(&have_row, stmt));
+
+  if (have_row)
+    {
+      apr_array_header_t *paths;
+
+      paths = apr_array_make(result_pool, 4, sizeof(const char*));
+      while (have_row)
+        {
+          const char *found_relpath = svn_sqlite__column_text(stmt, 0, NULL);
+
+          APR_ARRAY_PUSH(paths, const char *)
+              = svn_relpath_is_child(local_relpath, found_relpath,
+                                     result_pool);
+
+          SVN_ERR(svn_sqlite__step(&have_row, stmt));
+        }
+
+      *descendants = paths;
+    }
+  else
+    *descendants = apr_array_make(result_pool, 0, sizeof(const char*));
+
+  return svn_error_return(svn_sqlite__reset(stmt));
+}
+
 
 /* Like svn_wc__db_min_max_revisions(),
  * but accepts a WCROOT/LOCAL_RELPATH pair. */

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.h
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.h?rev=1099399&r1=1099398&r2=1099399&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.h (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.h Wed May  4 10:35:22 2011
@@ -2710,6 +2710,18 @@ svn_wc__db_info_below_working(svn_boolea
                               apr_pool_t *scratch_pool);
 
 
+/* Gets an array of const char *local_relpaths of descendants of LOCAL_ABSPATH,
+ * which itself must be the op root of an addition, copy or move.
+ * The descendants returned are at the same op_depth, but are to be deleted
+ * by the commit processing because they are not present in the local copy.
+ */
+svn_error_t *
+svn_wc__db_get_not_present_descendants(const apr_array_header_t **descendants,
+                                       svn_wc__db_t *db,
+                                       const char *local_abspath,
+                                       apr_pool_t *result_pool,
+                                       apr_pool_t *scratch_pool);
+
 /* Gather revision status information about a working copy using DB.
  * 
  * Set *MIN_REVISION and *MAX_REVISION to the lowest and highest revision


Reply via email to