Author: julianfoad
Date: Thu Feb 24 15:58:10 2022
New Revision: 1898378

URL: http://svn.apache.org/viewvc?rev=1898378&view=rev
Log:
Multi-WC-format: Clarify the supported versions display.

This patch:

  - Changes the APIs for querying the default WC format and the supported WC
    formats;
  - clarifies the display of supported WC formats in 'svn --version'.

API changes:

  - Remove svn_client_supported_wc_version().
  - Add svn_client_default_wc_version().
  - Add svn_client_supported_wc_formats() and a type it returns.

CLI changes:

  Old display in 'svn --version':

  | Supported working copy (WC) versions: from 1.8 to 1.15

  New display in 'svn --version':

  | Supported working copy (WC) versions:
  |
  | * compatible with Subversion v1.8 to v1.15 (WC format 31)
  | * compatible with Subversion v1.15 (WC format 32)

The list style, along with inclusion of the WC format number, helps show
that each line describes a distinct format. Users sometimes also need to
know about WC format numbers, and the 'version' command is an appropriate
place to show these. The presentation style matches that used for the lists
of RA modules and credential caches.

* subversion/include/svn_client.h,
  subversion/libsvn_client/upgrade.c
  (svn_client_checkout4,
   svn_client_upgrade2): Update doc string.
  (svn_client_supported_wc_version): Remove.
  (svn_client_default_wc_version,
   svn_client_wc_format_t,
   svn_client_supported_wc_formats): New.

* subversion/libsvn_client/checkout.c
  (svn_client_checkout4): Update caller: use svn_client_default_wc_version().

* subversion/libsvn_wc/wc.h
  (SVN_WC__SUPPORTED_VERSION): Update doc string.

* subversion/svn/help-cmd.c
  (print_supported_wc_formats): New.
  (svn_cl__help): Use it to display supported WC formats as a list.

* subversion/svn/svn.c
  (parse_compatible_version): Update caller: use
    svn_client_supported_wc_formats().

* subversion/tests/cmdline/getopt_tests_data/svn--version_stdout,
  subversion/tests/cmdline/getopt_tests_data/svn--version--verbose_stdout
    Update expected output.

Modified:
    subversion/trunk/subversion/include/svn_client.h
    subversion/trunk/subversion/libsvn_client/checkout.c
    subversion/trunk/subversion/libsvn_client/upgrade.c
    subversion/trunk/subversion/libsvn_wc/wc.h
    subversion/trunk/subversion/svn/help-cmd.c
    subversion/trunk/subversion/svn/svn.c
    
subversion/trunk/subversion/tests/cmdline/getopt_tests_data/svn--version--verbose_stdout
    
subversion/trunk/subversion/tests/cmdline/getopt_tests_data/svn--version_stdout

Modified: subversion/trunk/subversion/include/svn_client.h
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_client.h?rev=1898378&r1=1898377&r2=1898378&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_client.h (original)
+++ subversion/trunk/subversion/include/svn_client.h Thu Feb 24 15:58:10 2022
@@ -1243,8 +1243,8 @@ svn_client_args_to_target_array(apr_arra
  * @param[in] wc_format_version is the version number of the Subversion
  *              client that supports the metadata format of the
  *              created working copy; @c NULL means the library's default
- *              format. The earliest supported version is returned by
- *              svn_client_supported_wc_version().
+ *              format. See svn_client_default_wc_version(),
+ *              svn_client_supported_wc_formats().
  * @param[in] ctx   The standard client context, used for authentication and
  *              notification.
  * @param[in] pool  Used for any temporary allocation.
@@ -4401,8 +4401,8 @@ svn_client_cleanup(const char *dir,
  *
  * @a wc_format_version is the version number of the Subversion client
  * that supports a given WC metadata format; @c NULL means the library's
- * default format. The earliest supported version is returned by
- * svn_client_supported_wc_version().
+ * default format. See svn_client_default_wc_version(),
+ * svn_client_supported_wc_formats().
  *
  * Use @a scratch_pool for any temporary allocations.
  *
@@ -4428,13 +4428,40 @@ svn_client_upgrade(const char *wcroot_di
                    apr_pool_t *scratch_pool);
 
 /**
- * Returns the version related to the earliest supported
+ * Returns the version related to the library's default
  * working copy metadata format.
  *
  * @since New in 1.15.
  */
 const svn_version_t *
-svn_client_supported_wc_version(void);
+svn_client_default_wc_version(apr_pool_t *result_pool);
+
+/**
+ * Information about a WC version.
+ *
+ * Only the @c .major and @c .minor version fields are significant: so a
+ * version_max value of 1.15.0 for example means "up to 1.15.x".
+ */
+typedef struct svn_client_wc_format_t {
+    /* Oldest version of svn libraries known to support this WC version */
+    const svn_version_t *version_min;
+    /* Newest version of svn libraries known to support this WC version. */
+    const svn_version_t *version_max;
+    /* The WC format number of this format, as defined by libsvn_wc. */
+    int wc_format;
+} svn_client_wc_format_t;
+
+/**
+ * Returns a list of the WC formats supported by the client library.
+ *
+ * The list is sorted from oldest to newest, and terminated by an entry
+ * containing all null/zero fields.
+ *
+ * The returned data are allocated in @a result_pool and/or statically.
+ */
+const svn_client_wc_format_t *
+svn_client_supported_wc_formats(apr_pool_t *result_pool,
+                                apr_pool_t *scratch_pool);
 
 /** @} */
 

Modified: subversion/trunk/subversion/libsvn_client/checkout.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/checkout.c?rev=1898378&r1=1898377&r2=1898378&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/checkout.c (original)
+++ subversion/trunk/subversion/libsvn_client/checkout.c Thu Feb 24 15:58:10 
2022
@@ -239,7 +239,7 @@ svn_client_checkout4(svn_revnum_t *resul
 
   /* A NULL wc_format_version translates to the default version. */
   if (!wc_format_version)
-    wc_format_version = svn_client_supported_wc_version();
+    wc_format_version = svn_client_default_wc_version(pool);
 
   err = svn_client__checkout_internal(result_rev, &sleep_here,
                                       URL, local_abspath,

Modified: subversion/trunk/subversion/libsvn_client/upgrade.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/upgrade.c?rev=1898378&r1=1898377&r2=1898378&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/upgrade.c (original)
+++ subversion/trunk/subversion/libsvn_client/upgrade.c Thu Feb 24 15:58:10 2022
@@ -41,6 +41,7 @@
 
 #include "svn_private_config.h"
 #include "private/svn_wc_private.h"
+#include "../libsvn_wc/wc.h"
 
 
 /*** Code. ***/
@@ -199,11 +200,25 @@ svn_client_upgrade2(const char *path,
   return SVN_NO_ERROR;
 }
 
+const svn_client_wc_format_t *
+svn_client_supported_wc_formats(apr_pool_t *result_pool,
+                                apr_pool_t *scratch_pool)
+{
+  static const svn_version_t version_1_8 = { 1, 8, 0, NULL };
+  static const svn_version_t version_1_15 = { 1, 15, 0, NULL };
+  static const svn_client_wc_format_t versions[] = {
+    { &version_1_8,   &version_1_15,  SVN_WC__SUPPORTED_VERSION },
+    { &version_1_15,  &version_1_15,  SVN_WC__VERSION           },
+    { NULL,           NULL,           0 }
+  };
+  return versions;
+}
+
 const svn_version_t *
-svn_client_supported_wc_version(void)
+svn_client_default_wc_version(apr_pool_t *result_pool)
 {
   /* NOTE: For consistency, always return the version of the client
-     that first introduced the earliest supported format. */
+     that first introduced the format. */
   static const svn_version_t version = { 1, 8, 0, NULL };
   return &version;
 }

Modified: subversion/trunk/subversion/libsvn_wc/wc.h
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc.h?rev=1898378&r1=1898377&r2=1898378&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc.h (original)
+++ subversion/trunk/subversion/libsvn_wc/wc.h Thu Feb 24 15:58:10 2022
@@ -169,7 +169,8 @@ extern "C" {
 #define SVN_WC__VERSION 32
 
 /* The minimum WC version supported by the client.
-   IMPORTANT: Update the implementation of svn_client_supported_wc_version()
+   IMPORTANT: Update the implementation of svn_client_default_wc_version()
+              and svn_client_supported_wc_formats()
               whenever you change this value! */
 #define SVN_WC__SUPPORTED_VERSION 31
 

Modified: subversion/trunk/subversion/svn/help-cmd.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/help-cmd.c?rev=1898378&r1=1898377&r2=1898378&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/help-cmd.c (original)
+++ subversion/trunk/subversion/svn/help-cmd.c Thu Feb 24 15:58:10 2022
@@ -41,6 +41,47 @@
 
 /*** Code. ***/
 
+/* Append a textual list of the supported WC formats to OUTPUT. */
+static svn_error_t *
+print_supported_wc_formats(svn_stringbuf_t *output,
+                           const char *prefix,
+                           apr_pool_t *pool)
+{
+  const svn_client_wc_format_t *wc_formats
+    = svn_client_supported_wc_formats(pool, pool);
+  int i;
+
+  for (i = 0; wc_formats[i].version_min; i++)
+    {
+      const svn_client_wc_format_t *v = &wc_formats[i];
+      const char *s;
+
+      if (v->version_min->major == v->version_min->major &&
+          v->version_min->minor == v->version_max->minor)
+        {
+          s = apr_psprintf(
+                pool,
+                _("%scompatible with Subversion v%d.%d (WC format %d)\n"),
+                prefix,
+                v->version_min->major, v->version_min->minor,
+                v->wc_format);
+        }
+      else
+        {
+          s = apr_psprintf(
+                pool,
+                _("%scompatible with Subversion v%d.%d to v%d.%d (WC format 
%d)\n"),
+                prefix,
+                v->version_min->major, v->version_min->minor,
+                v->version_max->major, v->version_max->minor,
+                v->wc_format);
+        }
+
+      svn_stringbuf_appendcstr(output, s);
+    }
+  return SVN_NO_ERROR;
+}
+
 /* This implements the `svn_opt_subcommand_t' interface. */
 svn_error_t *
 svn_cl__help(apr_getopt_t *os,
@@ -50,9 +91,6 @@ svn_cl__help(apr_getopt_t *os,
   svn_cl__opt_state_t *opt_state = NULL;
   svn_stringbuf_t *version_footer = svn_stringbuf_create_empty(pool);
   const char *config_path;
-  const svn_version_t* min_wc_version;
-  const svn_version_t* max_wc_version;
-  const char *wc_version_footer;
 
   char help_header[] =
   N_("usage: svn <subcommand> [options] [args]\n"
@@ -133,27 +171,17 @@ svn_cl__help(apr_getopt_t *os,
       opt_state = cmd_baton->opt_state;
     }
 
-  min_wc_version = svn_client_supported_wc_version();
-  max_wc_version = svn_client_version();
-  if (min_wc_version->major == max_wc_version->major
-      && min_wc_version->minor == max_wc_version->minor)
-    {
-      wc_version_footer =
-        apr_psprintf(pool,
-                     _("Supported working copy (WC) version: %d.%d\n\n"),
-                     min_wc_version->major, min_wc_version->minor);
-    }
-  else
-    {
-      wc_version_footer =
-        apr_psprintf(
-            pool,
-            _("Supported working copy (WC) versions: from %d.%d to %d.%d\n\n"),
-            min_wc_version->major, min_wc_version->minor,
-            max_wc_version->major, max_wc_version->minor);
-    }
-  svn_stringbuf_appendcstr(version_footer, wc_version_footer);
-
+  /*
+   * Show supported working copy versions.
+   */
+  svn_stringbuf_appendcstr(version_footer,
+                           _("Supported working copy (WC) formats:\n\n"));
+  SVN_ERR(print_supported_wc_formats(version_footer, "* ", pool));
+  svn_stringbuf_appendcstr(version_footer, "\n");
+
+  /*
+   * Show available repository access modules.
+   */
   svn_stringbuf_appendcstr(
       version_footer,
       _("The following repository access (RA) modules are available:\n\n"));

Modified: subversion/trunk/subversion/svn/svn.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/svn.c?rev=1898378&r1=1898377&r2=1898378&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/svn.c (original)
+++ subversion/trunk/subversion/svn/svn.c Thu Feb 24 15:58:10 2022
@@ -2031,11 +2031,12 @@ parse_compatible_version(svn_cl__opt_sta
   const char *utf8_opt_arg;
   svn_version_t *target;
 
-  /* Get the the latest and oldest supported version from the current
-     libsvn_client versions. WC formats are always defined by a X.Y.0
-     release, and svn_client_supported_wc_version() should return such
+  /* Get the supported WC formats.  WC formats are always defined by a X.Y.0
+     release, and svn_client_supported_wc_formats() should return such
      a value. */
-  const svn_version_t *supported = svn_client_supported_wc_version();
+  const svn_client_wc_format_t *formats_supported
+    = svn_client_supported_wc_formats(result_pool, result_pool);
+  const svn_version_t *supported = formats_supported[0].version_min;
   const svn_version_t *current = svn_client_version();
   const svn_version_t latest = {current->major, current->minor, 0, NULL};
 

Modified: 
subversion/trunk/subversion/tests/cmdline/getopt_tests_data/svn--version--verbose_stdout
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/getopt_tests_data/svn--version--verbose_stdout?rev=1898378&r1=1898377&r2=1898378&view=diff
==============================================================================
--- 
subversion/trunk/subversion/tests/cmdline/getopt_tests_data/svn--version--verbose_stdout
 (original)
+++ 
subversion/trunk/subversion/tests/cmdline/getopt_tests_data/svn--version--verbose_stdout
 Thu Feb 24 15:58:10 2022
@@ -6,7 +6,10 @@ This software consists of contributions
 see the NOTICE file for more information.
 Subversion is open source software, see http://subversion.apache.org/
 
-Supported working copy (WC) versions: from 1.8 to 1.15
+Supported working copy (WC) formats:
+
+* compatible with Subversion v1.8 to v1.15 (WC format 31)
+* compatible with Subversion v1.15 (WC format 32)
 
 The following repository access (RA) modules are available:
 

Modified: 
subversion/trunk/subversion/tests/cmdline/getopt_tests_data/svn--version_stdout
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/getopt_tests_data/svn--version_stdout?rev=1898378&r1=1898377&r2=1898378&view=diff
==============================================================================
--- 
subversion/trunk/subversion/tests/cmdline/getopt_tests_data/svn--version_stdout 
(original)
+++ 
subversion/trunk/subversion/tests/cmdline/getopt_tests_data/svn--version_stdout 
Thu Feb 24 15:58:10 2022
@@ -6,7 +6,10 @@ This software consists of contributions
 see the NOTICE file for more information.
 Subversion is open source software, see http://subversion.apache.org/
 
-Supported working copy (WC) versions: from 1.8 to 1.15
+Supported working copy (WC) formats:
+
+* compatible with Subversion v1.8 to v1.15 (WC format 31)
+* compatible with Subversion v1.15 (WC format 32)
 
 The following repository access (RA) modules are available:
 


Reply via email to