You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ko...@apache.org on 2021/08/27 13:53:29 UTC

svn commit: r1892648 - in /subversion/branches/pristines-on-demand/subversion/libsvn_wc: adm_crawler.c copy.c externals.c revert.c update_editor.c wc_db_update_move.c

Author: kotkov
Date: Fri Aug 27 13:53:28 2021
New Revision: 1892648

URL: http://svn.apache.org/viewvc?rev=1892648&view=rev
Log:
On the pristines-on-demand branch: Lay some more groundwork for making the
text-bases optional.

For now, let's ensure we only use the explicit version of the file_install
workqueue item, where the caller specifies the install source in the form of
a file path.

(The implicit version of this work item only specifies the checksum of the
pristine text, and its contents is taken from the pristine store when the
work item is processed.  If we make the text-bases optional, supporting
this type of item would probably require additional bookkeeping, where
we'd have to ensure that the contents is still present at the moment when
we process the workqueue item.  Which should be possible, but for now let's
transition into a state where we explicitly specify the target contents,
and maybe at some point we could work our way backwards.

Note that with r1886490, we mostly use the working_file_writer to install
the files, so explicitly providing the contents here shouldn't introduce an
overhead for common checkout and update cases.)

* subversion/libsvn_wc/adm_crawler.c
  (restore_file): Setaside the text-base contents for the work item.

* subversion/libsvn_wc/copy.c
  (): Include textbase.h.
  (restore_file): Setaside the text-base contents for the work item.

* subversion/libsvn_wc/externals.c
  (close_file): Setaside the text-base contents for the work item.
   Use svn_wc__db_pristine_read() instead of the svn_wc__textbase layer,
   because we are just about to call svn_wc__db_external_add_file(), so at
   this point our file external does not yet exist.

* subversion/libsvn_wc/revert.c
  (): Include textbase.h.
  (revert_wc_data): Setaside the text-base contents for the work item.

* subversion/libsvn_wc/update_editor.c
  (update_keywords_after_switch_cb): Setaside the text-base contents for
   the work item.
  (svn_wc_add_repos_file4): Rework to always construct the file_install
   work item with an explicitly provided source file.

* subversion/libsvn_wc/wc_db_update_move.c
  (tc_editor_add_file,
   tc_editor_alter_file,
   tc_editor_update_add_merge_files,
   update_locally_added_node): Setaside the text-base contents for all
   file_install work items.

Modified:
    subversion/branches/pristines-on-demand/subversion/libsvn_wc/adm_crawler.c
    subversion/branches/pristines-on-demand/subversion/libsvn_wc/copy.c
    subversion/branches/pristines-on-demand/subversion/libsvn_wc/externals.c
    subversion/branches/pristines-on-demand/subversion/libsvn_wc/revert.c
    subversion/branches/pristines-on-demand/subversion/libsvn_wc/update_editor.c
    subversion/branches/pristines-on-demand/subversion/libsvn_wc/wc_db_update_move.c

Modified: subversion/branches/pristines-on-demand/subversion/libsvn_wc/adm_crawler.c
URL: http://svn.apache.org/viewvc/subversion/branches/pristines-on-demand/subversion/libsvn_wc/adm_crawler.c?rev=1892648&r1=1892647&r2=1892648&view=diff
==============================================================================
--- subversion/branches/pristines-on-demand/subversion/libsvn_wc/adm_crawler.c (original)
+++ subversion/branches/pristines-on-demand/subversion/libsvn_wc/adm_crawler.c Fri Aug 27 13:53:28 2021
@@ -75,13 +75,22 @@ restore_file(svn_wc__db_t *db,
              apr_pool_t *scratch_pool)
 {
   svn_skel_t *work_item;
+  const char *install_from;
+  svn_skel_t *cleanup_work_item;
 
+  SVN_ERR(svn_wc__textbase_setaside_wq(&install_from,
+                                       &cleanup_work_item,
+                                       db, local_abspath, NULL,
+                                       cancel_func, cancel_baton,
+                                       scratch_pool, scratch_pool));
   SVN_ERR(svn_wc__wq_build_file_install(&work_item,
                                         db, local_abspath,
-                                        NULL /* source_abspath */,
+                                        install_from,
                                         use_commit_times,
                                         TRUE /* record_fileinfo */,
                                         scratch_pool, scratch_pool));
+  work_item = svn_wc__wq_merge(work_item, cleanup_work_item, scratch_pool);
+
   /* ### we need an existing path for wq_add. not entirely WRI_ABSPATH yet  */
   SVN_ERR(svn_wc__db_wq_add(db,
                             svn_dirent_dirname(local_abspath, scratch_pool),

Modified: subversion/branches/pristines-on-demand/subversion/libsvn_wc/copy.c
URL: http://svn.apache.org/viewvc/subversion/branches/pristines-on-demand/subversion/libsvn_wc/copy.c?rev=1892648&r1=1892647&r2=1892648&view=diff
==============================================================================
--- subversion/branches/pristines-on-demand/subversion/libsvn_wc/copy.c (original)
+++ subversion/branches/pristines-on-demand/subversion/libsvn_wc/copy.c Fri Aug 27 13:53:28 2021
@@ -38,6 +38,7 @@
 #include "workqueue.h"
 #include "props.h"
 #include "conflicts.h"
+#include "textbase.h"
 
 #include "svn_private_config.h"
 #include "private/svn_wc_private.h"
@@ -138,11 +139,20 @@ copy_to_tmpdir(svn_skel_t **work_item,
 
       if (!modified)
         {
-          /* Why create a temp copy if we can just reinstall from pristine? */
-          SVN_ERR(svn_wc__wq_build_file_install(work_item,
-                                                db, dst_abspath, NULL, FALSE,
-                                                TRUE,
+          const char *install_from;
+          svn_skel_t *cleanup_work_item;
+
+          SVN_ERR(svn_wc__textbase_setaside_wq(&install_from,
+                                               &cleanup_work_item,
+                                               db, src_abspath, NULL,
+                                               cancel_func, cancel_baton,
+                                               result_pool, scratch_pool));
+          SVN_ERR(svn_wc__wq_build_file_install(work_item, db, dst_abspath,
+                                                install_from, FALSE, TRUE,
                                                 result_pool, scratch_pool));
+          *work_item = svn_wc__wq_merge(*work_item, cleanup_work_item,
+                                        result_pool);
+
           return SVN_NO_ERROR;
         }
     }

Modified: subversion/branches/pristines-on-demand/subversion/libsvn_wc/externals.c
URL: http://svn.apache.org/viewvc/subversion/branches/pristines-on-demand/subversion/libsvn_wc/externals.c?rev=1892648&r1=1892647&r2=1892648&view=diff
==============================================================================
--- subversion/branches/pristines-on-demand/subversion/libsvn_wc/externals.c (original)
+++ subversion/branches/pristines-on-demand/subversion/libsvn_wc/externals.c Fri Aug 27 13:53:28 2021
@@ -889,13 +889,40 @@ close_file(void *file_baton,
           }
         if (install_pristine)
           {
+            svn_stream_t *contents;
+            const char *tmpdir_abspath;
+            svn_stream_t *tmpstream;
+            const char *tmpfile_abspath;
+
+            SVN_ERR(svn_wc__db_pristine_read(&contents, NULL, eb->db,
+                                             eb->wri_abspath,
+                                             eb->new_sha1_checksum,
+                                             pool, pool));
+
+            SVN_ERR(svn_wc__db_temp_wcroot_tempdir(&tmpdir_abspath,
+                                                   eb->db, eb->wri_abspath,
+                                                   pool, pool));
+            SVN_ERR(svn_stream_open_unique(&tmpstream, &tmpfile_abspath,
+                                           tmpdir_abspath,
+                                           svn_io_file_del_none,
+                                           pool, pool));
+            SVN_ERR(svn_stream_copy3(contents, tmpstream, eb->cancel_func,
+                                     eb->cancel_baton, pool));
+
             SVN_ERR(svn_wc__wq_build_file_install(&work_item, eb->db,
                                             eb->local_abspath,
-                                            NULL,
+                                            tmpfile_abspath,
                                             eb->use_commit_times, TRUE,
                                             pool, pool));
 
             all_work_items = svn_wc__wq_merge(all_work_items, work_item, pool);
+
+            SVN_ERR(svn_wc__wq_build_file_remove(&work_item, eb->db,
+                                                 eb->wri_abspath,
+                                                 tmpfile_abspath,
+                                                 pool, pool));
+
+            all_work_items = svn_wc__wq_merge(all_work_items, work_item, pool);
           }
       }
     else

Modified: subversion/branches/pristines-on-demand/subversion/libsvn_wc/revert.c
URL: http://svn.apache.org/viewvc/subversion/branches/pristines-on-demand/subversion/libsvn_wc/revert.c?rev=1892648&r1=1892647&r2=1892648&view=diff
==============================================================================
--- subversion/branches/pristines-on-demand/subversion/libsvn_wc/revert.c (original)
+++ subversion/branches/pristines-on-demand/subversion/libsvn_wc/revert.c Fri Aug 27 13:53:28 2021
@@ -42,6 +42,7 @@
 #include "wc.h"
 #include "adm_files.h"
 #include "workqueue.h"
+#include "textbase.h"
 
 #include "svn_private_config.h"
 #include "private/svn_io_private.h"
@@ -714,10 +715,21 @@ revert_wc_data(svn_boolean_t *run_wq,
       if (kind == svn_node_file)
         {
           svn_skel_t *work_item;
+          const char *install_from;
+          svn_skel_t *cleanup_work_item;
 
+          SVN_ERR(svn_wc__textbase_setaside_wq(&install_from,
+                                               &cleanup_work_item,
+                                               db, local_abspath, NULL,
+                                               cancel_func, cancel_baton,
+                                               scratch_pool, scratch_pool));
           SVN_ERR(svn_wc__wq_build_file_install(&work_item, db, local_abspath,
-                                                NULL, use_commit_times, TRUE,
+                                                install_from,
+                                                use_commit_times, TRUE,
                                                 scratch_pool, scratch_pool));
+          work_item = svn_wc__wq_merge(work_item, cleanup_work_item,
+                                       scratch_pool);
+
           SVN_ERR(svn_wc__db_wq_add(db, local_abspath, work_item,
                                     scratch_pool));
           *run_wq = TRUE;

Modified: subversion/branches/pristines-on-demand/subversion/libsvn_wc/update_editor.c
URL: http://svn.apache.org/viewvc/subversion/branches/pristines-on-demand/subversion/libsvn_wc/update_editor.c?rev=1892648&r1=1892647&r2=1892648&view=diff
==============================================================================
--- subversion/branches/pristines-on-demand/subversion/libsvn_wc/update_editor.c (original)
+++ subversion/branches/pristines-on-demand/subversion/libsvn_wc/update_editor.c Fri Aug 27 13:53:28 2021
@@ -4888,6 +4888,7 @@ update_keywords_after_switch_cb(void *ba
   svn_boolean_t record_fileinfo;
   svn_skel_t *work_items;
   const char *install_from;
+  svn_skel_t *cleanup_work_item;
 
   propval = svn_hash_gets(props, SVN_PROP_KEYWORDS);
   if (!propval)
@@ -4913,11 +4914,18 @@ update_keywords_after_switch_cb(void *ba
       SVN_ERR(svn_stream_copy3(working_stream, install_from_stream,
                                eb->cancel_func, eb->cancel_baton,
                                scratch_pool));
+      SVN_ERR(svn_wc__wq_build_file_remove(&cleanup_work_item, eb->db,
+                                           local_abspath, install_from,
+                                           scratch_pool, scratch_pool));
       record_fileinfo = FALSE;
     }
   else
     {
-      install_from = NULL;
+      SVN_ERR(svn_wc__textbase_setaside_wq(&install_from,
+                                           &cleanup_work_item,
+                                           eb->db, local_abspath, NULL,
+                                           eb->cancel_func, eb->cancel_baton,
+                                           scratch_pool, scratch_pool));
       record_fileinfo = TRUE;
     }
 
@@ -4926,15 +4934,7 @@ update_keywords_after_switch_cb(void *ba
                                         eb->use_commit_times,
                                         record_fileinfo,
                                         scratch_pool, scratch_pool));
-  if (install_from)
-    {
-      svn_skel_t *work_item;
-
-      SVN_ERR(svn_wc__wq_build_file_remove(&work_item, eb->db,
-                                           local_abspath, install_from,
-                                           scratch_pool, scratch_pool));
-      work_items = svn_wc__wq_merge(work_items, work_item, scratch_pool);
-    }
+  work_items = svn_wc__wq_merge(work_items, cleanup_work_item, scratch_pool);
 
   SVN_ERR(svn_wc__db_wq_add(eb->db, local_abspath, work_items,
                             scratch_pool));
@@ -5623,33 +5623,38 @@ svn_wc_add_repos_file4(svn_wc_context_t
                                    entry_props, pool, pool));
   }
 
+  {
+    const char *tmp_dir_abspath;
+
+    SVN_ERR(svn_wc__db_temp_wcroot_tempdir(&tmp_dir_abspath,
+                                           db, dir_abspath,
+                                           scratch_pool, scratch_pool));
+
+    SVN_ERR(svn_stream_open_unique(&tmp_base_contents, &tmp_text_base_abspath,
+                                   tmp_dir_abspath, svn_io_file_del_none,
+                                   scratch_pool, scratch_pool));
+  }
+
   /* Copy NEW_BASE_CONTENTS into a temporary file so our log can refer to
      it, and set TMP_TEXT_BASE_ABSPATH to its path.  Compute its
      NEW_TEXT_BASE_MD5_CHECKSUM and NEW_TEXT_BASE_SHA1_CHECKSUM as we copy. */
   if (copyfrom_url)
     {
-      SVN_ERR(svn_wc__textbase_prepare_install(&tmp_base_contents,
+      svn_stream_t *install_stream;
+
+      SVN_ERR(svn_wc__textbase_prepare_install(&install_stream,
                                                &install_data,
                                                &new_text_base_sha1_checksum,
                                                &new_text_base_md5_checksum,
                                                wc_ctx->db, local_abspath,
                                                scratch_pool, scratch_pool));
+
+      tmp_base_contents = svn_stream_tee(install_stream,
+                                         tmp_base_contents,
+                                         scratch_pool);
     }
   else
     {
-      const char *tmp_dir_abspath;
-
-      /* We are not installing a PRISTINE file, but we use the same code to
-         create whatever we want to install */
-
-      SVN_ERR(svn_wc__db_temp_wcroot_tempdir(&tmp_dir_abspath,
-                                             db, dir_abspath,
-                                             scratch_pool, scratch_pool));
-
-      SVN_ERR(svn_stream_open_unique(&tmp_base_contents, &tmp_text_base_abspath,
-                                     tmp_dir_abspath, svn_io_file_del_none,
-                                     scratch_pool, scratch_pool));
-
       new_text_base_sha1_checksum = NULL;
       new_text_base_md5_checksum = NULL;
     }
@@ -5672,6 +5677,10 @@ svn_wc_add_repos_file4(svn_wc_context_t
       SVN_ERR(svn_stream_copy3(new_contents, tmp_contents,
                                cancel_func, cancel_baton, pool));
     }
+  else
+    {
+      source_abspath = tmp_text_base_abspath;
+    }
 
   /* Install new text base for copied files. Added files do NOT have a
      text base.  */
@@ -5707,42 +5716,20 @@ svn_wc_add_repos_file4(svn_wc_context_t
       new_text_base_md5_checksum = NULL;
     }
 
-  /* For added files without NEW_CONTENTS, then generate the working file
-     from the provided "pristine" contents.  */
-  if (new_contents == NULL && copyfrom_url == NULL)
-    source_abspath = tmp_text_base_abspath;
-
-  {
-    svn_boolean_t record_fileinfo;
-
-    /* If new contents were provided, then we do NOT want to record the
-       file information. We assume the new contents do not match the
-       "proper" values for RECORDED_SIZE and RECORDED_TIME.  */
-    record_fileinfo = (new_contents == NULL);
-
-    /* Install the working copy file (with appropriate translation) from
-       the appropriate source. SOURCE_ABSPATH will be NULL, indicating an
-       installation from the pristine (available for copied/moved files),
-       or it will specify a temporary file where we placed a "pristine"
-       (for an added file) or a detranslated local-mods file.  */
-    SVN_ERR(svn_wc__wq_build_file_install(&work_item,
-                                          db, local_abspath,
-                                          source_abspath,
-                                          FALSE /* use_commit_times */,
-                                          record_fileinfo,
-                                          pool, pool));
-    all_work_items = svn_wc__wq_merge(all_work_items, work_item, pool);
-
-    /* If we installed from somewhere besides the official pristine, then
-       it is a temporary file, which needs to be removed.  */
-    if (source_abspath != NULL)
-      {
-        SVN_ERR(svn_wc__wq_build_file_remove(&work_item, db, local_abspath,
-                                             source_abspath,
-                                             pool, pool));
-        all_work_items = svn_wc__wq_merge(all_work_items, work_item, pool);
-      }
-  }
+  /* Install the working copy file (with appropriate translation) from
+     the provided temporary file at SOURCE_ABSPATH.  */
+  SVN_ERR(svn_wc__wq_build_file_install(&work_item,
+                                        db, local_abspath,
+                                        source_abspath,
+                                        FALSE /* use_commit_times */,
+                                        TRUE  /* record_fileinfo */,
+                                        pool, pool));
+  all_work_items = svn_wc__wq_merge(all_work_items, work_item, pool);
+
+  SVN_ERR(svn_wc__wq_build_file_remove(&work_item, db, local_abspath,
+                                       source_abspath,
+                                       pool, pool));
+  all_work_items = svn_wc__wq_merge(all_work_items, work_item, pool);
 
   SVN_ERR(svn_wc__db_op_copy_file(db, local_abspath,
                                   new_base_props,

Modified: subversion/branches/pristines-on-demand/subversion/libsvn_wc/wc_db_update_move.c
URL: http://svn.apache.org/viewvc/subversion/branches/pristines-on-demand/subversion/libsvn_wc/wc_db_update_move.c?rev=1892648&r1=1892647&r2=1892648&view=diff
==============================================================================
--- subversion/branches/pristines-on-demand/subversion/libsvn_wc/wc_db_update_move.c (original)
+++ subversion/branches/pristines-on-demand/subversion/libsvn_wc/wc_db_update_move.c Fri Aug 27 13:53:28 2021
@@ -971,15 +971,28 @@ tc_editor_add_file(node_move_baton_t *nm
     }
   else
     {
+      const char *src_abspath;
+      const char *install_from;
+      svn_skel_t *cleanup_work_item;
+
+      src_abspath = svn_dirent_join(b->wcroot->abspath, nmb->src_relpath,
+                                    scratch_pool);
+
       /* Update working file. */
+      SVN_ERR(svn_wc__textbase_setaside_wq(&install_from,
+                                           &cleanup_work_item,
+                                           b->db, src_abspath, NULL,
+                                           b->cancel_func, b->cancel_baton,
+                                           scratch_pool, scratch_pool));
       SVN_ERR(svn_wc__wq_build_file_install(&work_item, b->db,
                                             svn_dirent_join(b->wcroot->abspath,
                                                             relpath,
                                                             scratch_pool),
-                                            NULL,
+                                            install_from,
                                             FALSE /*FIXME: use_commit_times?*/,
                                             TRUE  /* record_file_info */,
                                             scratch_pool, scratch_pool));
+      work_item = svn_wc__wq_merge(work_item, cleanup_work_item, scratch_pool);
     }
 
   SVN_ERR(update_move_list_add(b->wcroot, relpath, b->db,
@@ -1370,14 +1383,27 @@ tc_editor_alter_file(node_move_baton_t *
                                                scratch_pool));
       if (!is_locally_modified)
         {
+          const char *src_abspath;
+          const char *install_from;
+          svn_skel_t *cleanup_work_item;
+
+          src_abspath = svn_dirent_join(b->wcroot->abspath, nmb->src_relpath,
+                                        scratch_pool);
+
+          SVN_ERR(svn_wc__textbase_setaside_wq(&install_from,
+                                               &cleanup_work_item,
+                                               b->db, src_abspath, NULL,
+                                               b->cancel_func, b->cancel_baton,
+                                               scratch_pool, scratch_pool));
           SVN_ERR(svn_wc__wq_build_file_install(&work_item, b->db,
                                                 local_abspath,
-                                                NULL,
+                                                install_from,
                                                 FALSE /* FIXME: use_commit_times? */,
                                                 TRUE  /* record_file_info */,
                                                 scratch_pool, scratch_pool));
 
           work_items = svn_wc__wq_merge(work_items, work_item, scratch_pool);
+          work_items = svn_wc__wq_merge(work_items, cleanup_work_item, scratch_pool);
 
           content_state = svn_wc_notify_state_changed;
         }
@@ -3166,14 +3192,22 @@ tc_editor_update_add_merge_files(added_n
   if (!is_modified)
     {
       svn_skel_t *work_item = NULL;
+      const char *install_from;
+      svn_skel_t *cleanup_work_item;
 
+      SVN_ERR(svn_wc__textbase_setaside_wq(&install_from,
+                                           &cleanup_work_item,
+                                           b->db, local_abspath, NULL,
+                                           b->cancel_func, b->cancel_baton,
+                                           scratch_pool, scratch_pool));
       SVN_ERR(svn_wc__wq_build_file_install(&work_item, b->db,
-                                            local_abspath, NULL,
+                                            local_abspath, install_from,
                                             /* FIXME: use_commit_times? */
                                             FALSE,
                                             TRUE,  /* record_file_info */
                                             scratch_pool, scratch_pool));
       work_items = svn_wc__wq_merge(work_items, work_item, scratch_pool);
+      work_items = svn_wc__wq_merge(work_items, cleanup_work_item, scratch_pool);
       content_state = svn_wc_notify_state_changed;
     }
   else
@@ -3398,12 +3432,23 @@ update_locally_added_node(added_node_bat
        * is currently not installed because the base tree is shadowed.
        * Queue an installation of this node into the working copy. */
       if (base_kind == svn_node_file || base_kind == svn_node_symlink)
-        SVN_ERR(svn_wc__wq_build_file_install(&work_item, db, local_abspath,
-                                              NULL,
-                                              /* FIXME: use_commit_times? */
-                                              FALSE,
-                                              TRUE,  /* record_file_info */
-                                              scratch_pool, scratch_pool));
+        {
+          const char *install_from;
+          svn_skel_t *cleanup_work_item;
+
+          SVN_ERR(svn_wc__textbase_setaside_wq(&install_from,
+                                               &cleanup_work_item,
+                                               db, local_abspath, NULL,
+                                               b->cancel_func, b->cancel_baton,
+                                               scratch_pool, scratch_pool));
+          SVN_ERR(svn_wc__wq_build_file_install(&work_item, db, local_abspath,
+                                                install_from,
+                                                /* FIXME: use_commit_times? */
+                                                FALSE,
+                                                TRUE,  /* record_file_info */
+                                                scratch_pool, scratch_pool));
+          work_item = svn_wc__wq_merge(work_item, cleanup_work_item, scratch_pool);
+        }
       else if (base_kind == svn_node_dir)
         SVN_ERR(svn_wc__wq_build_dir_install(&work_item, db, local_abspath,
                                              scratch_pool, scratch_pool));