Author: kotkov
Date: Thu Mar  4 15:15:22 2021
New Revision: 1887177

URL: http://svn.apache.org/viewvc?rev=1887177&view=rev
Log:
In the working file writer open() function, accept a single `is_readonly`
parameter instead of three values describing the lock state that is used to
decide on whether the file should be read only.

Under the current circumstances, the new approach should be easier to follow
and less error-prone.

* subversion/include/private/svn_wc_private.h
  (svn_wc__working_file_writer_open): Update declaration.

* subversion/libsvn_wc/working_file_writer.c
  (svn_wc__working_file_writer_open): Accept the new `is_readonly` parameter,
   pass it to the install stream.  Move the code that has been determining
   the read-only state ...

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

* subversion/libsvn_wc/workqueue.c
  (run_file_install): ...and here.

* subversion/libsvn_client/export.c
  (export_node, open_working_file_writer): Update to pass is_readonly=FALSE
   when opening the file writer.

* subversion/tests/libsvn_wc/wc-test.c
  (test_working_file_writer_simple,
   test_working_file_writer_eol_repair,
   test_working_file_writer_eol_inconsistent):
   Update these calling sites of svn_wc__working_file_writer_open().

Modified:
    subversion/trunk/subversion/include/private/svn_wc_private.h
    subversion/trunk/subversion/libsvn_client/export.c
    subversion/trunk/subversion/libsvn_wc/update_editor.c
    subversion/trunk/subversion/libsvn_wc/working_file_writer.c
    subversion/trunk/subversion/libsvn_wc/workqueue.c
    subversion/trunk/subversion/tests/libsvn_wc/wc-test.c

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=1887177&r1=1887176&r2=1887177&view=diff
==============================================================================
--- subversion/trunk/subversion/include/private/svn_wc_private.h (original)
+++ subversion/trunk/subversion/include/private/svn_wc_private.h Thu Mar  4 
15:15:22 2021
@@ -2148,9 +2148,7 @@ svn_wc__working_file_writer_open(svn_wc_
                                  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,
+                                 svn_boolean_t is_readonly,
                                  apr_pool_t *result_pool,
                                  apr_pool_t *scratch_pool);
 

Modified: subversion/trunk/subversion/libsvn_client/export.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/export.c?rev=1887177&r1=1887176&r2=1887177&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/export.c (original)
+++ subversion/trunk/subversion/libsvn_client/export.c Thu Mar  4 15:15:22 2021
@@ -408,9 +408,7 @@ export_node(void *baton,
                                            kw,
                                            special != NULL,
                                            executable != NULL,
-                                           FALSE,
-                                           FALSE,
-                                           FALSE,
+                                           FALSE /* is_readonly */,
                                            scratch_pool,
                                            scratch_pool));
 
@@ -723,9 +721,7 @@ open_working_file_writer(svn_wc__working
                                            keywords,
                                            fb->special,
                                            fb->executable_val != NULL,
-                                           FALSE,
-                                           FALSE,
-                                           FALSE,
+                                           FALSE /* is_readonly */,
                                            result_pool,
                                            scratch_pool));
 

Modified: subversion/trunk/subversion/libsvn_wc/update_editor.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/update_editor.c?rev=1887177&r1=1887176&r2=1887177&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/update_editor.c (original)
+++ subversion/trunk/subversion/libsvn_wc/update_editor.c Thu Mar  4 15:15:22 
2021
@@ -3634,6 +3634,7 @@ open_working_file_writer(svn_wc__working
   apr_time_t cmt_date;
   const char *cmt_author;
   apr_time_t final_mtime;
+  svn_boolean_t is_readonly;
 
   SVN_ERR(get_file_base_props(&base_props, fb, scratch_pool));
   props = svn_prop__patch(base_props, fb->propchanges, scratch_pool);
@@ -3686,6 +3687,11 @@ open_working_file_writer(svn_wc__working
   else
     final_mtime = -1;
 
+  if (needs_lock && !lock_token && !fb->adding_file)
+    is_readonly = TRUE;
+  else
+    is_readonly = FALSE;
+
   SVN_ERR(svn_wc__working_file_writer_open(writer_p,
                                            temp_dir_abspath,
                                            final_mtime,
@@ -3695,9 +3701,7 @@ open_working_file_writer(svn_wc__working
                                            keywords,
                                            is_special,
                                            is_executable,
-                                           needs_lock,
-                                           lock_token != NULL,
-                                           fb->adding_file,
+                                           is_readonly,
                                            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=1887177&r1=1887176&r2=1887177&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/working_file_writer.c (original)
+++ subversion/trunk/subversion/libsvn_wc/working_file_writer.c Thu Mar  4 
15:15:22 2021
@@ -63,9 +63,7 @@ svn_wc__working_file_writer_open(svn_wc_
                                  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,
+                                 svn_boolean_t is_readonly,
                                  apr_pool_t *result_pool,
                                  apr_pool_t *scratch_pool)
 {
@@ -76,7 +74,7 @@ svn_wc__working_file_writer_open(svn_wc_
   SVN_ERR(svn_stream__create_for_install(&install_stream, tmp_abspath,
                                          result_pool, scratch_pool));
 
-  if (needs_lock && !is_added && !has_lock)
+  if (is_readonly)
     svn_stream__install_set_read_only(install_stream, TRUE);
   if (is_executable)
     svn_stream__install_set_executable(install_stream, TRUE);

Modified: subversion/trunk/subversion/libsvn_wc/workqueue.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/workqueue.c?rev=1887177&r1=1887176&r2=1887177&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/workqueue.c (original)
+++ subversion/trunk/subversion/libsvn_wc/workqueue.c Thu Mar  4 15:15:22 2021
@@ -512,6 +512,7 @@ run_file_install(work_item_baton_t *wqb,
   svn_wc__working_file_writer_t *file_writer;
   apr_time_t record_mtime;
   apr_off_t record_size;
+  svn_boolean_t is_readonly;
 
   local_relpath = apr_pstrmemdup(scratch_pool, arg1->data, arg1->len);
   SVN_ERR(svn_wc__db_from_relpath(&local_abspath, db, wri_abspath,
@@ -608,6 +609,11 @@ run_file_install(work_item_baton_t *wqb,
   else
     final_mtime = -1;
 
+  if (needs_lock && !lock && status != svn_wc__db_status_added)
+    is_readonly = TRUE;
+  else
+    is_readonly = FALSE;
+
   SVN_ERR(svn_wc__working_file_writer_open(&file_writer,
                                            temp_dir_abspath,
                                            final_mtime,
@@ -617,9 +623,7 @@ run_file_install(work_item_baton_t *wqb,
                                            keywords,
                                            is_special,
                                            is_executable,
-                                           needs_lock,
-                                           lock != NULL,
-                                           status == svn_wc__db_status_added,
+                                           is_readonly,
                                            scratch_pool,
                                            scratch_pool));
 

Modified: subversion/trunk/subversion/tests/libsvn_wc/wc-test.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_wc/wc-test.c?rev=1887177&r1=1887176&r2=1887177&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_wc/wc-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_wc/wc-test.c Thu Mar  4 15:15:22 
2021
@@ -510,7 +510,7 @@ test_working_file_writer_simple(const sv
   SVN_ERR(svn_wc__working_file_writer_open(&writer, tmp_dir, -1,
                                            svn_subst_eol_style_none, NULL,
                                            FALSE, NULL, FALSE, FALSE,
-                                           FALSE, FALSE, FALSE,
+                                           FALSE,
                                            pool, pool));
 
   stream = svn_wc__working_file_writer_get_stream(writer);
@@ -548,7 +548,7 @@ test_working_file_writer_eol_repair(cons
                                            svn_subst_eol_style_fixed, "\r\n",
                                            TRUE /* repair_eol */,
                                            NULL, FALSE, FALSE,
-                                           FALSE, FALSE, FALSE,
+                                           FALSE,
                                            pool, pool));
 
   stream = svn_wc__working_file_writer_get_stream(writer);
@@ -586,7 +586,7 @@ test_working_file_writer_eol_inconsisten
                                            svn_subst_eol_style_fixed, "\r\n",
                                            FALSE /* repair_eol */,
                                            NULL, FALSE, FALSE,
-                                           FALSE, FALSE, FALSE,
+                                           FALSE,
                                            pool, pool));
 
   /* With REPAIR_EOL disabled, expect to see an error when the line ending


Reply via email to