Author: kotkov
Date: Thu Mar  2 11:09:02 2023
New Revision: 1907963

URL: http://svn.apache.org/viewvc?rev=1907963&view=rev
Log:
Slightly refactor the svn_client__checkout_internal() function so that all
parameter processing would happen in one place.

Before this change, this logic was scattered between svn_client_checkout4()
and svn_client__checkout_internal(), with an additional downside that the
internal function could only accept specific parameter combinations.

With this change, all processing happens in svn_client__checkout_internal(),
without any assertions on those parameter combinations.

* subversion/libsvn_client/client.h
  (svn_client__checkout_internal): Accept new `settings_from_context` parameter.
   Adjust docstring.

* subversion/libsvn_client/checkout.c
  (svn_client_checkout4): Move part of the parameter processing into …
  (svn_client__checkout_internal): …this function.

* subversion/libsvn_client/copy.c
  (svn_client__repos_to_wc_copy_dir):
   Adjust calling site of svn_client__checkout_internal().

* subversion/libsvn_client/externals.c
  (switch_dir_external): Adjust calling site of svn_client__checkout_internal().

* subversion/libsvn_client/shelf.c
  (shelf_copy_base): Adjust calling site of svn_client__checkout_internal().

Modified:
    subversion/trunk/subversion/libsvn_client/checkout.c
    subversion/trunk/subversion/libsvn_client/client.h
    subversion/trunk/subversion/libsvn_client/copy.c
    subversion/trunk/subversion/libsvn_client/externals.c
    subversion/trunk/subversion/libsvn_client/shelf.c

Modified: subversion/trunk/subversion/libsvn_client/checkout.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/checkout.c?rev=1907963&r1=1907962&r2=1907963&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/checkout.c (original)
+++ subversion/trunk/subversion/libsvn_client/checkout.c Thu Mar  2 11:09:02 
2023
@@ -80,6 +80,7 @@ svn_client__checkout_internal(svn_revnum
                               svn_depth_t depth,
                               svn_boolean_t ignore_externals,
                               svn_boolean_t allow_unver_obstructions,
+                              svn_boolean_t settings_from_context,
                               const svn_version_t *wc_format_version,
                               svn_tristate_t store_pristine,
                               svn_ra_session_t *ra_session,
@@ -103,7 +104,7 @@ svn_client__checkout_internal(svn_revnum
       && (revision->kind != svn_opt_revision_head))
     return svn_error_create(SVN_ERR_CLIENT_BAD_REVISION, NULL, NULL);
 
-  if (wc_format_version == NULL && store_pristine == svn_tristate_unknown)
+  if (settings_from_context)
     {
       SVN_ERR(svn_wc__settings_from_context(&target_format,
                                             &target_store_pristine,
@@ -112,17 +113,41 @@ svn_client__checkout_internal(svn_revnum
     }
   else
     {
-      SVN_ERR_ASSERT(wc_format_version != NULL);
+      const svn_version_t *target_format_version;
 
-      SVN_ERR(svn_wc__format_from_version(&target_format, wc_format_version,
-                                          scratch_pool));
-
-      SVN_ERR_ASSERT(store_pristine != svn_tristate_unknown);
-
-      if (store_pristine == svn_tristate_true)
+      if (store_pristine == svn_tristate_unknown)
+        target_store_pristine = TRUE;
+      else if (store_pristine == svn_tristate_true)
         target_store_pristine = TRUE;
       else
         target_store_pristine = FALSE;
+
+      if (wc_format_version)
+        {
+          target_format_version = wc_format_version;
+        }
+      else
+        {
+          /* A NULL wc_format_version translates to the minimum compatible
+             version. */
+          target_format_version = svn_client_default_wc_version(scratch_pool);
+
+          if (!target_store_pristine)
+            {
+              const svn_version_t *required_version =
+                
svn_client__compatible_wc_version_optional_pristine(scratch_pool);
+
+              if (!svn_version__at_least(target_format_version,
+                                         required_version->major,
+                                         required_version->minor,
+                                         required_version->patch))
+                target_format_version = required_version;
+            }
+        }
+
+      SVN_ERR(svn_wc__format_from_version(&target_format,
+                                          target_format_version,
+                                          scratch_pool));
     }
 
   /* Get the RA connection, if needed. */
@@ -271,32 +296,12 @@ svn_client_checkout4(svn_revnum_t *resul
 
   SVN_ERR(svn_dirent_get_absolute(&local_abspath, path, pool));
 
-  if (store_pristine == svn_tristate_unknown)
-    store_pristine = svn_tristate_true;
-
-  /* A NULL wc_format_version translates to the minimum compatible version. */
-  if (!wc_format_version)
-    {
-      wc_format_version = svn_client_default_wc_version(pool);
-
-      if (store_pristine == svn_tristate_false)
-        {
-          const svn_version_t *required_version =
-            svn_client__compatible_wc_version_optional_pristine(pool);
-
-          if (!svn_version__at_least(wc_format_version,
-                                     required_version->major,
-                                     required_version->minor,
-                                     required_version->patch))
-            wc_format_version = required_version;
-        }
-    }
-
   err = svn_client__checkout_internal(result_rev, &sleep_here,
                                       URL, local_abspath,
                                       peg_revision, revision, depth,
                                       ignore_externals,
                                       allow_unver_obstructions,
+                                      FALSE, /* settings_from_context */
                                       wc_format_version,
                                       store_pristine,
                                       NULL /* ra_session */,

Modified: subversion/trunk/subversion/libsvn_client/client.h
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/client.h?rev=1907963&r1=1907962&r2=1907963&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/client.h (original)
+++ subversion/trunk/subversion/libsvn_client/client.h Thu Mar  2 11:09:02 2023
@@ -539,18 +539,20 @@ svn_client__update_internal(svn_revnum_t
    the repos are tolerated; if FALSE, these obstructions cause the checkout
    to fail.
 
-   A new working copy, if needed, will be created in the format corresponding
-   to the WC_FORMAT_VERSION of the client.  The format of any existing working
-   copy will remain unchanged.
+   If SETTINGS_FROM_CONTEXT is TRUE, the working copy settings such as
+   WC_FORMAT_VERSION and STORE_PRISTINE will be determined from context
+   (see svn_wc__settings_from_context) and the values of the corresponding
+   arguments are ignored.  Otherwise, their values take effect as described
+   below:
 
-   If STORE_PRISTINE is svn_tristate_true, the pristine contents of all
-   files in the working copy will be stored on disk.  If STORE_PRISTINE is
-   svn_tristate_false, the pristine contents will be fetched on-demand when
-   required by the operation.
+   - A new working copy, if needed, will be created in the format corresponding
+     to the WC_FORMAT_VERSION of the client.  The format of any existing
+     working copy will remain unchanged.
 
-   If WC_FORMAT_VERSION is NULL and STORE_PRISTINE is svn_tristate_unknown, the
-   settings will be determined from context (see 
svn_wc__settings_from_context).
-   Otherwise, both WC_FORMAT_VERSION and STORE_PRISTINE must be defined.
+   - If STORE_PRISTINE is svn_tristate_true, the pristine contents of all
+     files in the working copy will be stored on disk.  If STORE_PRISTINE is
+     svn_tristate_false, the pristine contents will be fetched on-demand when
+     required by the operation.
 
    If RA_SESSION is NOT NULL, it may be used to avoid creating a new
    session. The session may point to a different URL after returning.
@@ -565,6 +567,7 @@ svn_client__checkout_internal(svn_revnum
                               svn_depth_t depth,
                               svn_boolean_t ignore_externals,
                               svn_boolean_t allow_unver_obstructions,
+                              svn_boolean_t settings_from_context,
                               const svn_version_t *wc_format_version,
                               svn_tristate_t store_pristine,
                               svn_ra_session_t *ra_session,

Modified: subversion/trunk/subversion/libsvn_client/copy.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/copy.c?rev=1907963&r1=1907962&r2=1907963&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/copy.c (original)
+++ subversion/trunk/subversion/libsvn_client/copy.c Thu Mar  2 11:09:02 2023
@@ -2487,8 +2487,8 @@ svn_client__repos_to_wc_copy_dir(svn_boo
                                         svn_depth_infinity,
                                         TRUE /*ignore_externals*/,
                                         FALSE, /* we don't allow obstructions 
*/
-                                        NULL, /* default WC format */
-                                        svn_tristate_unknown,
+                                        TRUE, /*settings_from_context*/
+                                        NULL, svn_tristate_unknown,
                                         ra_session, ctx, scratch_pool);
 
     ctx->notify_func2 = old_notify_func2;

Modified: subversion/trunk/subversion/libsvn_client/externals.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/externals.c?rev=1907963&r1=1907962&r2=1907963&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/externals.c (original)
+++ subversion/trunk/subversion/libsvn_client/externals.c Thu Mar  2 11:09:02 
2023
@@ -412,8 +412,8 @@ switch_dir_external(const char *local_ab
                                         url, local_abspath, peg_revision,
                                         revision, svn_depth_infinity,
                                         FALSE, FALSE,
-                                        NULL, /* default WC format */
-                                        svn_tristate_unknown,
+                                        TRUE, /*settings_from_context*/
+                                        NULL, svn_tristate_unknown,
                                         ra_session,
                                         ctx, pool));
 

Modified: subversion/trunk/subversion/libsvn_client/shelf.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/shelf.c?rev=1907963&r1=1907962&r2=1907963&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/shelf.c (original)
+++ subversion/trunk/subversion/libsvn_client/shelf.c Thu Mar  2 11:09:02 2023
@@ -1036,8 +1036,8 @@ shelf_copy_base(svn_client__shelf_versio
                                         svn_depth_infinity,
                                         TRUE /*ignore_externals*/,
                                         FALSE /*allow_unver_obstructions*/,
-                                        NULL, /* default WC format */
-                                        svn_tristate_unknown,
+                                        TRUE, /*settings_from_context*/
+                                        NULL, svn_tristate_unknown,
                                         ra_session,
                                         ctx, scratch_pool));
   /* ### hopefully we won't eventually need to sleep_here... */


Reply via email to