Author: rhuijben
Date: Tue May 10 16:03:21 2011
New Revision: 1101521

URL: http://svn.apache.org/viewvc?rev=1101521&view=rev
Log:
Add some file externals capable code to svn_wc__db_read_node_install_info() to
make the initial install of file externals work in format 29.

* subversion/libsvn_wc/wc_db.c
  (svn_wc__db_read_node_install_info): Add 3 arguments. Fetch values for
    normal install and fall back to retrieving file external information if
    no node or just a hidden node is found.

* subversion/libsvn_wc/wc_db.h
  (svn_wc__db_read_node_install_info): Update prototype.
* subversion/libsvn_wc/workqueue.c
  (run_file_install): Update caller. Remove separate db call for changed_date
    retrieval. Don't call get_and_record_fileinfo for new style file externals.

Modified:
    subversion/trunk/subversion/libsvn_wc/wc_db.c
    subversion/trunk/subversion/libsvn_wc/wc_db.h
    subversion/trunk/subversion/libsvn_wc/workqueue.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=1101521&r1=1101520&r2=1101521&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Tue May 10 16:03:21 2011
@@ -7145,8 +7145,11 @@ svn_wc__db_read_node_install_info(const 
                                   const svn_checksum_t **sha1_checksum,
                                   const char **target,
                                   apr_hash_t **pristine_props,
+                                  apr_time_t *changed_date,
+                                  svn_boolean_t *is_file_external,
                                   svn_wc__db_t *db,
                                   const char *local_abspath,
+                                  const char *wri_abspath,
                                   apr_pool_t *result_pool,
                                   apr_pool_t *scratch_pool)
 {
@@ -7154,46 +7157,143 @@ svn_wc__db_read_node_install_info(const 
   const char *local_relpath;
   svn_sqlite__stmt_t *stmt;
   svn_error_t *err = NULL;
+  svn_boolean_t have_row;
+  svn_boolean_t try_external = FALSE;
+
+  SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath));
+
+  if (!wri_abspath)
+    wri_abspath = local_abspath;
 
   SVN_ERR(svn_wc__db_wcroot_parse_local_abspath(&wcroot, &local_relpath, db,
-                              local_abspath, scratch_pool, scratch_pool));
+                              wri_abspath, scratch_pool, scratch_pool));
   VERIFY_USABLE_WCROOT(wcroot);
 
+  if (local_abspath != wri_abspath
+      && strcmp(local_abspath, wri_abspath))
+    {
+      if (!svn_dirent_is_ancestor(wcroot->abspath, local_abspath))
+        return svn_error_createf(
+                    SVN_ERR_WC_PATH_NOT_FOUND, NULL,
+                    _("The node '%s' is not in working copy '%s'"),
+                    svn_dirent_local_style(local_abspath, scratch_pool),
+                    svn_dirent_local_style(wcroot->abspath, scratch_pool));
+
+      local_relpath = svn_dirent_skip_ancestor(wcroot->abspath, local_abspath);
+    }
+
   if (wcroot_abspath != NULL)
     *wcroot_abspath = apr_pstrdup(result_pool, wcroot->abspath);
 
+  if (is_file_external)
+    *is_file_external = FALSE;
+
   SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
                                     STMT_SELECT_NODE_INFO));
 
   SVN_ERR(svn_sqlite__bindf(stmt, "is", wcroot->wc_id, local_relpath));
 
-  SVN_ERR(svn_sqlite__step_row(stmt)); /* Row must exist */
+  SVN_ERR(svn_sqlite__step(&have_row, stmt));
 
-  if (status)
+  if (have_row)
     {
-      apr_int64_t op_depth = svn_sqlite__column_int64(stmt, 0);
+      svn_wc__db_status_t db_status;
 
-      *status = svn_sqlite__column_token(stmt, 3, presence_map);
+      apr_int64_t op_depth = svn_sqlite__column_int64(stmt, 0);
+      db_status = svn_sqlite__column_token(stmt, 3, presence_map);
 
       if (op_depth > 0)
-        err = convert_to_working_status(status, *status);
+         err = convert_to_working_status(&db_status, db_status);
+
+      if (status)
+        *status = db_status;
+
+      if (is_file_external
+          && (db_status == svn_wc__db_status_not_present
+              || db_status == svn_wc__db_status_excluded
+              || db_status == svn_wc__db_status_absent))
+        try_external = TRUE;
+
+      if (kind)
+        *kind = svn_sqlite__column_token(stmt, 4, kind_map);
+
+      if (!err && sha1_checksum)
+        err = svn_sqlite__column_checksum(sha1_checksum, stmt, 6, result_pool);
+
+      if (target)
+        *target = svn_sqlite__column_text(stmt, 12, result_pool);
+
+      if (!err && pristine_props)
+        err = svn_sqlite__column_properties(pristine_props, stmt, 14,
+                                            result_pool, scratch_pool);
+
+      if (changed_date)
+        *changed_date = svn_sqlite__column_int64(stmt, 9);
     }
+  else
+    try_external = (is_file_external != NULL);
+
+  SVN_ERR(svn_error_compose_create(err, svn_sqlite__reset(stmt)));
 
-  if (kind)
-    *kind = svn_sqlite__column_token(stmt, 4, kind_map);
+#if SVN_WC__VERSION >= SVN_WC__HAS_EXTERNALS_STORE
+  if (try_external)
+    {
+      SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
+                                        STMT_SELECT_EXTERNAL_INFO));
+
+      SVN_ERR(svn_sqlite__bindf(stmt, "is", wcroot->wc_id, local_relpath));
 
-  if (!err && sha1_checksum)
-    err = svn_sqlite__column_checksum(sha1_checksum, stmt, 6, result_pool);
+      SVN_ERR(svn_sqlite__step(is_file_external, stmt));
 
-  if (target)
-    *target = svn_sqlite__column_text(stmt, 12, result_pool);
+      if (*is_file_external)
+        {
+          svn_wc__db_kind_t external_kind;
+          
+          external_kind = svn_sqlite__column_token(stmt, 0, kind_map);
+
+          if (external_kind == svn_wc__db_kind_file
+              || external_kind == svn_wc__db_kind_symlink)
+            {
+              if (status)
+                *status = svn_wc__db_status_normal;
 
-  if (!err && pristine_props)
-    err = svn_sqlite__column_properties(pristine_props, stmt, 14, result_pool,
-                                        scratch_pool);
+              if (kind)
+                *kind = external_kind;
 
-  return svn_error_compose_create(err,
-                                  svn_sqlite__reset(stmt));
+              if (sha1_checksum)
+                err = svn_sqlite__column_checksum(sha1_checksum, stmt, 5,
+                                                  result_pool);
+
+              if (target)
+                *target = svn_sqlite__column_text(stmt, 6, result_pool);
+
+              if (!err && pristine_props)
+                err = svn_sqlite__column_properties(pristine_props, stmt, 4,
+                                                    result_pool, scratch_pool);
+
+              if (changed_date)
+                *changed_date = svn_sqlite__column_int64(stmt, 8);
+            }
+          else
+            {
+              *is_file_external = FALSE;
+              try_external = FALSE;
+            }
+        }
+
+      SVN_ERR(svn_error_compose_create(err, svn_sqlite__reset(stmt)));
+    }
+#else
+  try_external = FALSE;
+#endif
+
+  if (!have_row && ! try_external)
+    return svn_error_createf(SVN_ERR_WC_PATH_NOT_FOUND, NULL,
+                             _("The node '%s' is not installable"),
+                             svn_dirent_local_style(local_abspath,
+                                                    scratch_pool));
+
+  return SVN_NO_ERROR;
 }
 
 

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.h
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.h?rev=1101521&r1=1101520&r2=1101521&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.h (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.h Tue May 10 16:03:21 2011
@@ -1904,7 +1904,15 @@ svn_wc__db_read_pristine_info(svn_wc__db
    Set WCROOT_ABSPATH to the working copy root, STATUS to the presence of the
    node, KIND to the node kind, SHA1_CHECKSUM to the checksum of the node
    (a valid reference into the pristine store) and PRISTINE_PROPS to the node's
-   pristine properties (to use for installing the file). */
+   pristine properties (to use for installing the file).
+
+   If IS_FILE_EXTERNAL is not NULL, check if the node might be a file external
+   when the node is not present in the working copy and return that information
+   instead and set *IS_FILE_EXTERNAL to true.
+
+   If WRI_ABSPATH is not NULL, check for information in the working copy
+   identified by WRI_ABSPATH.
+   */
 svn_error_t *
 svn_wc__db_read_node_install_info(const char **wcroot_abspath,
                                   svn_wc__db_status_t *status,
@@ -1912,8 +1920,11 @@ svn_wc__db_read_node_install_info(const 
                                   const svn_checksum_t **sha1_checksum,
                                   const char **target,
                                   apr_hash_t **pristine_props,
+                                  apr_time_t *changed_date,
+                                  svn_boolean_t *is_file_external,
                                   svn_wc__db_t *db,
                                   const char *local_abspath,
+                                  const char *wri_abspath,
                                   apr_pool_t *result_pool,
                                   apr_pool_t *scratch_pool);
 

Modified: subversion/trunk/subversion/libsvn_wc/workqueue.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/workqueue.c?rev=1101521&r1=1101520&r2=1101521&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/workqueue.c (original)
+++ subversion/trunk/subversion/libsvn_wc/workqueue.c Tue May 10 16:03:21 2011
@@ -613,7 +613,9 @@ run_file_install(svn_wc__db_t *db,
   const char *wcroot_abspath;
   const char *source_abspath;
   const svn_checksum_t *checksum;
+  svn_boolean_t is_file_external;
   apr_hash_t *props;
+  apr_time_t changed_date;
 
   local_relpath = apr_pstrmemdup(scratch_pool, arg1->data, arg1->len);
   SVN_ERR(svn_wc__db_from_relpath(&local_abspath, db, wri_abspath,
@@ -626,7 +628,9 @@ run_file_install(svn_wc__db_t *db,
 
   SVN_ERR(svn_wc__db_read_node_install_info(&wcroot_abspath, NULL, NULL,
                                             &checksum, NULL, &props,
-                                            db, local_abspath,
+                                            &changed_date,
+                                            &is_file_external,
+                                            db, local_abspath, wri_abspath,
                                             scratch_pool, scratch_pool));
 
   if (arg4 != NULL)
@@ -720,16 +724,6 @@ run_file_install(svn_wc__db_t *db,
 
   if (use_commit_times)
     {
-      apr_time_t changed_date;
-
-      SVN_ERR(svn_wc__db_read_info(NULL, NULL, NULL, NULL, NULL, NULL,
-                                   NULL, &changed_date, 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 (changed_date)
         SVN_ERR(svn_io_set_file_affected_time(changed_date,
                                               local_abspath,
@@ -737,7 +731,7 @@ run_file_install(svn_wc__db_t *db,
     }
 
   /* ### this should happen before we rename the file into place.  */
-  if (record_fileinfo)
+  if (record_fileinfo && !is_file_external)
     {
       SVN_ERR(get_and_record_fileinfo(db, local_abspath,
                                       FALSE /* ignore_enoent */,


Reply via email to