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/02/22 14:40:18 UTC

svn commit: r1886796 - in /subversion/trunk/subversion/libsvn_wc: update_editor.c working_file_writer.c working_file_writer.h workqueue.c

Author: kotkov
Date: Mon Feb 22 14:40:18 2021
New Revision: 1886796

URL: http://svn.apache.org/viewvc?rev=1886796&view=rev
Log:
Lay some groundwork to allow using the new working file writer utility
layer outside of the update editor and the workqueue.

To do that, stop accepting a props hash in svn_wc__working_file_writer_open()
and instead of that accept all interesting properties as separate arguments.
This allows using the working file writer in cases where we only have scattered
property values instead of a hash, or, for example, need to build a custom
keywords hash.

* subversion/libsvn_wc/working_file_writer.h
  (): Include svn_subst.h.
  (svn_wc__working_file_writer_open): Accept separate arguments such as
   `svn_boolean_t is_special` instead of the props hash.  Accept the new
   repair_eol argument.  No longer accept the repos_root_url and the
   repos_relpath arguments.

* subversion/libsvn_wc/working_file_writer.c
  (svn_wc__working_file_writer_open): Use the new separate arguments to
   control initialization of the install stream and its translation.
   Keep the special handling of an empty keywords hash here, for
   convenience.  Move and adjust the old code that has been accessing the
   properties in the PROPS hash...

* subversion/libsvn_wc/update_editor.c
  (open_working_file_writer): ...here, and ...

* subversion/libsvn_wc/workqueue.c
  (): Include svn_path.h.
  (run_file_install): ...here.

Modified:
    subversion/trunk/subversion/libsvn_wc/update_editor.c
    subversion/trunk/subversion/libsvn_wc/working_file_writer.c
    subversion/trunk/subversion/libsvn_wc/working_file_writer.h
    subversion/trunk/subversion/libsvn_wc/workqueue.c

Modified: subversion/trunk/subversion/libsvn_wc/update_editor.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/update_editor.c?rev=1886796&r1=1886795&r2=1886796&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/update_editor.c (original)
+++ subversion/trunk/subversion/libsvn_wc/update_editor.c Mon Feb 22 14:40:18 2021
@@ -3620,10 +3620,17 @@ open_working_file_writer(svn_wc__working
 {
   apr_hash_t *base_props;
   apr_hash_t *props;
+  svn_boolean_t is_special;
+  svn_boolean_t is_executable;
+  svn_boolean_t needs_lock;
+  const char *eol_propval;
+  svn_subst_eol_style_t eol_style;
+  const char *eol;
+  const char *keywords_propval;
+  apr_hash_t *keywords;
   const char *lock_token;
   const char *temp_dir_abspath;
   const char *cmt_rev_str;
-  svn_revnum_t cmt_rev;
   const char *cmt_date_str;
   apr_time_t cmt_date;
   const char *cmt_author;
@@ -3632,15 +3639,14 @@ open_working_file_writer(svn_wc__working
   SVN_ERR(get_file_base_props(&base_props, fb, scratch_pool));
   props = svn_prop__patch(base_props, fb->propchanges, scratch_pool);
 
+  is_special = svn_prop_get_value(props, SVN_PROP_SPECIAL) != NULL;
+  is_executable = svn_prop_get_value(props, SVN_PROP_EXECUTABLE) != NULL;
+  needs_lock = svn_prop_get_value(props, SVN_PROP_NEEDS_LOCK) != NULL;
+
+  eol_propval = svn_prop_get_value(props, SVN_PROP_EOL_STYLE);
+  svn_subst_eol_style_from_value(&eol_style, &eol, eol_propval);
+
   cmt_rev_str = svn_prop_get_value(props, SVN_PROP_ENTRY_COMMITTED_REV);
-  if (cmt_rev_str)
-    {
-      apr_int64_t rev;
-      SVN_ERR(svn_cstring_atoi64(&rev, cmt_rev_str));
-      cmt_rev = (svn_revnum_t)rev;
-    }
-  else
-    cmt_rev = SVN_INVALID_REVNUM;
 
   cmt_date_str = svn_prop_get_value(props, SVN_PROP_ENTRY_COMMITTED_DATE);
   if (cmt_date_str)
@@ -3650,10 +3656,24 @@ open_working_file_writer(svn_wc__working
 
   cmt_author = svn_prop_get_value(props, SVN_PROP_ENTRY_LAST_AUTHOR);
 
-  if (fb->edit_baton->use_commit_times && cmt_date)
-    final_mtime = cmt_date;
+  keywords_propval = svn_prop_get_value(props, SVN_PROP_KEYWORDS);
+  if (keywords_propval)
+    {
+      const char *url =
+        svn_path_url_add_component2(fb->edit_baton->repos_root,
+                                    fb->new_repos_relpath,
+                                    scratch_pool);
+
+      SVN_ERR(svn_subst_build_keywords3(&keywords, keywords_propval,
+                                        cmt_rev_str, url,
+                                        fb->edit_baton->repos_root,
+                                        cmt_date, cmt_author,
+                                        scratch_pool));
+    }
   else
-    final_mtime = -1;
+    {
+      keywords = NULL;
+    }
 
   lock_token = svn_prop_get_value(props, SVN_PROP_ENTRY_LOCK_TOKEN);
 
@@ -3662,17 +3682,23 @@ open_working_file_writer(svn_wc__working
                                          fb->edit_baton->wcroot_abspath,
                                          scratch_pool, scratch_pool));
 
+  if (fb->edit_baton->use_commit_times && cmt_date)
+    final_mtime = cmt_date;
+  else
+    final_mtime = -1;
+
   SVN_ERR(svn_wc__working_file_writer_open(writer_p,
                                            temp_dir_abspath,
                                            final_mtime,
-                                           props,
-                                           cmt_rev,
-                                           cmt_date,
-                                           cmt_author,
+                                           eol_style,
+                                           eol,
+                                           TRUE /* repair_eol */,
+                                           keywords,
+                                           is_special,
+                                           is_executable,
+                                           needs_lock,
                                            lock_token != NULL,
                                            fb->adding_file,
-                                           fb->edit_baton->repos_root,
-                                           fb->new_repos_relpath,
                                            result_pool,
                                            scratch_pool));
 

Modified: subversion/trunk/subversion/libsvn_wc/working_file_writer.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/working_file_writer.c?rev=1886796&r1=1886795&r2=1886796&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/working_file_writer.c (original)
+++ subversion/trunk/subversion/libsvn_wc/working_file_writer.c Mon Feb 22 14:40:18 2021
@@ -58,51 +58,23 @@ svn_error_t *
 svn_wc__working_file_writer_open(svn_wc__working_file_writer_t **writer_p,
                                  const char *tmp_abspath,
                                  apr_time_t final_mtime,
-                                 apr_hash_t *props,
-                                 svn_revnum_t changed_rev,
-                                 apr_time_t changed_date,
-                                 const char *changed_author,
+                                 svn_subst_eol_style_t eol_style,
+                                 const char *eol,
+                                 svn_boolean_t repair_eol,
+                                 apr_hash_t *keywords,
+                                 svn_boolean_t is_special,
+                                 svn_boolean_t is_executable,
+                                 svn_boolean_t needs_lock,
                                  svn_boolean_t has_lock,
                                  svn_boolean_t is_added,
-                                 const char *repos_root_url,
-                                 const char *repos_relpath,
                                  apr_pool_t *result_pool,
                                  apr_pool_t *scratch_pool)
 {
   svn_wc__working_file_writer_t *writer;
-  const char *url;
-  svn_boolean_t special;
-  svn_boolean_t executable;
-  svn_boolean_t needs_lock;
-  const char *keywords_propval;
-  apr_hash_t *keywords;
-  const char *eol_propval;
-  svn_subst_eol_style_t eol_style;
-  const char *eol;
   svn_stream_t *install_stream;
   svn_stream_t *write_stream;
 
-  url = svn_path_url_add_component2(repos_root_url, repos_relpath, scratch_pool);
-
-  special = svn_prop_get_value(props, SVN_PROP_SPECIAL) != NULL;
-  executable = svn_prop_get_value(props, SVN_PROP_EXECUTABLE) != NULL;
-  needs_lock = svn_prop_get_value(props, SVN_PROP_NEEDS_LOCK) != NULL;
-
-  eol_propval = svn_prop_get_value(props, SVN_PROP_EOL_STYLE);
-  svn_subst_eol_style_from_value(&eol_style, &eol, eol_propval);
-
-  keywords_propval = svn_prop_get_value(props, SVN_PROP_KEYWORDS);
-  if (keywords_propval)
-    {
-      SVN_ERR(svn_subst_build_keywords3(&keywords, keywords_propval,
-                                        apr_psprintf(scratch_pool, "%ld",
-                                                     changed_rev),
-                                        url, repos_root_url, changed_date,
-                                        changed_author, scratch_pool));
-      if (apr_hash_count(keywords) <= 0)
-        keywords = NULL;
-    }
-  else
+  if (keywords && apr_hash_count(keywords) <= 0)
     keywords = NULL;
 
   SVN_ERR(svn_stream__create_for_install(&install_stream, tmp_abspath,
@@ -110,7 +82,7 @@ svn_wc__working_file_writer_open(svn_wc_
 
   if (needs_lock && !is_added && !has_lock)
     svn_stream__install_set_read_only(install_stream, TRUE);
-  if (executable)
+  if (is_executable)
     svn_stream__install_set_executable(install_stream, TRUE);
   if (final_mtime >= 0)
     svn_stream__install_set_affected_time(install_stream, final_mtime);
@@ -119,11 +91,11 @@ svn_wc__working_file_writer_open(svn_wc_
 
   if (svn_subst_translation_required(eol_style, eol, keywords,
                                      FALSE /* special */,
-                                     TRUE /* force_eol_check */))
+                                     repair_eol))
     {
       write_stream = svn_subst_stream_translated(write_stream,
                                                  eol,
-                                                 TRUE /* repair */,
+                                                 repair_eol,
                                                  keywords,
                                                  TRUE /* expand */,
                                                  result_pool);
@@ -132,7 +104,7 @@ svn_wc__working_file_writer_open(svn_wc_
   writer = apr_pcalloc(result_pool, sizeof(*writer));
   writer->pool = result_pool;
   writer->tmp_abspath = apr_pstrdup(result_pool, tmp_abspath);
-  writer->is_special = special;
+  writer->is_special = is_special;
   writer->install_stream = install_stream;
   writer->write_stream = write_stream;
 

Modified: subversion/trunk/subversion/libsvn_wc/working_file_writer.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/working_file_writer.h?rev=1886796&r1=1886795&r2=1886796&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/working_file_writer.h (original)
+++ subversion/trunk/subversion/libsvn_wc/working_file_writer.h Mon Feb 22 14:40:18 2021
@@ -27,6 +27,7 @@
 #include <apr_pools.h>
 #include "svn_types.h"
 #include "svn_io.h"
+#include "svn_subst.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -45,14 +46,15 @@ svn_error_t *
 svn_wc__working_file_writer_open(svn_wc__working_file_writer_t **writer_p,
                                  const char *tmp_abspath,
                                  apr_time_t final_mtime,
-                                 apr_hash_t *props,
-                                 svn_revnum_t changed_rev,
-                                 apr_time_t changed_date,
-                                 const char *changed_author,
+                                 svn_subst_eol_style_t eol_style,
+                                 const char *eol,
+                                 svn_boolean_t repair_eol,
+                                 apr_hash_t *keywords,
+                                 svn_boolean_t is_special,
+                                 svn_boolean_t is_executable,
+                                 svn_boolean_t needs_lock,
                                  svn_boolean_t has_lock,
                                  svn_boolean_t is_added,
-                                 const char *repos_root_url,
-                                 const char *repos_relpath,
                                  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=1886796&r1=1886795&r2=1886796&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/workqueue.c (original)
+++ subversion/trunk/subversion/libsvn_wc/workqueue.c Mon Feb 22 14:40:18 2021
@@ -30,6 +30,7 @@
 #include "svn_subst.h"
 #include "svn_hash.h"
 #include "svn_io.h"
+#include "svn_path.h"
 
 #include "wc.h"
 #include "wc_db.h"
@@ -471,6 +472,14 @@ run_file_install(work_item_baton_t *wqb,
   const char *source_abspath;
   const svn_checksum_t *checksum;
   apr_hash_t *props;
+  svn_boolean_t is_special;
+  svn_boolean_t is_executable;
+  svn_boolean_t needs_lock;
+  const char *eol_propval;
+  svn_subst_eol_style_t eol_style;
+  const char *eol;
+  const char *keywords_propval;
+  apr_hash_t *keywords;
   apr_time_t changed_date;
   svn_revnum_t changed_rev;
   const char *changed_author;
@@ -547,6 +556,30 @@ run_file_install(work_item_baton_t *wqb,
                                         db, local_abspath,
                                         scratch_pool, scratch_pool));
 
+  is_special = svn_prop_get_value(props, SVN_PROP_SPECIAL) != NULL;
+  is_executable = svn_prop_get_value(props, SVN_PROP_EXECUTABLE) != NULL;
+  needs_lock = svn_prop_get_value(props, SVN_PROP_NEEDS_LOCK) != NULL;
+
+  eol_propval = svn_prop_get_value(props, SVN_PROP_EOL_STYLE);
+  svn_subst_eol_style_from_value(&eol_style, &eol, eol_propval);
+
+  keywords_propval = svn_prop_get_value(props, SVN_PROP_KEYWORDS);
+  if (keywords_propval)
+    {
+      const char *url =
+        svn_path_url_add_component2(repos_root_url, repos_relpath, scratch_pool);
+
+      SVN_ERR(svn_subst_build_keywords3(&keywords, keywords_propval,
+                                        apr_psprintf(scratch_pool, "%ld",
+                                                     changed_rev),
+                                        url, repos_root_url, changed_date,
+                                        changed_author, scratch_pool));
+    }
+  else
+    {
+      keywords = NULL;
+    }
+
   if (use_commit_times && changed_date)
     final_mtime = changed_date;
   else
@@ -555,14 +588,15 @@ run_file_install(work_item_baton_t *wqb,
   SVN_ERR(svn_wc__working_file_writer_open(&file_writer,
                                            temp_dir_abspath,
                                            final_mtime,
-                                           props,
-                                           changed_rev,
-                                           changed_date,
-                                           changed_author,
+                                           eol_style,
+                                           eol,
+                                           TRUE /* repair_eol */,
+                                           keywords,
+                                           is_special,
+                                           is_executable,
+                                           needs_lock,
                                            lock != NULL,
                                            status == svn_wc__db_status_added,
-                                           repos_root_url,
-                                           repos_relpath,
                                            scratch_pool,
                                            scratch_pool));