You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ju...@apache.org on 2022/02/24 21:50:55 UTC

svn commit: r1898397 - in /subversion/trunk/subversion: include/svn_client.h libsvn_client/upgrade.c svn/cl.h svn/notify.c svn/upgrade-cmd.c

Author: julianfoad
Date: Thu Feb 24 21:50:54 2022
New Revision: 1898397

URL: http://svn.apache.org/viewvc?rev=1898397&view=rev
Log:
Multi-WC-format, issue #4885: Remind the user they can upgrade further.

* subversion/include/svn_client.h,
  subversion/libsvn_client/upgrade.c
  (svn_client_default_wc_version): Fix doc string.
  (svn_client_latest_wc_version): New.

* subversion/svn/cl.h,
  subversion/svn/notify.c
  (notify_baton): Add a flag.
  (svn_cl__notifier_get_wc_was_upgraded): New.
  (notify_body): Set the flag when a wc was upgraded.

* subversion/svn/upgrade-cmd.c
  (svn_cl__upgrade): Remind the user when they can upgrade further.

Modified:
    subversion/trunk/subversion/include/svn_client.h
    subversion/trunk/subversion/libsvn_client/upgrade.c
    subversion/trunk/subversion/svn/cl.h
    subversion/trunk/subversion/svn/notify.c
    subversion/trunk/subversion/svn/upgrade-cmd.c

Modified: subversion/trunk/subversion/include/svn_client.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_client.h?rev=1898397&r1=1898396&r2=1898397&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_client.h (original)
+++ subversion/trunk/subversion/include/svn_client.h Thu Feb 24 21:50:54 2022
@@ -4428,7 +4428,7 @@ svn_client_upgrade(const char *wcroot_di
                    apr_pool_t *scratch_pool);
 
 /**
- * Returns the version related to the library's default
+ * Returns the first version that supported the library's default
  * working copy metadata format.
  *
  * @since New in 1.15.
@@ -4437,6 +4437,15 @@ const svn_version_t *
 svn_client_default_wc_version(apr_pool_t *result_pool);
 
 /**
+ * Returns the first version that supported the library's latest
+ * working copy metadata format.
+ *
+ * @since New in 1.15.
+ */
+const svn_version_t *
+svn_client_latest_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

Modified: subversion/trunk/subversion/libsvn_client/upgrade.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/upgrade.c?rev=1898397&r1=1898396&r2=1898397&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/upgrade.c (original)
+++ subversion/trunk/subversion/libsvn_client/upgrade.c Thu Feb 24 21:50:54 2022
@@ -251,6 +251,15 @@ svn_client_default_wc_version(apr_pool_t
   return &version;
 }
 
+const svn_version_t *
+svn_client_latest_wc_version(apr_pool_t *result_pool)
+{
+  /* NOTE: For consistency, always return the version of the client
+     that first introduced the format. */
+  static const svn_version_t version = { 1, 15, 0, NULL };
+  return &version;
+}
+
 /* Helper for upgrade_externals_from_properties: upgrades one external ITEM
    in EXTERNALS_PARENT. Uses SCRATCH_POOL for temporary allocations. */
 static svn_error_t *

Modified: subversion/trunk/subversion/svn/cl.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/cl.h?rev=1898397&r1=1898396&r2=1898397&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/cl.h (original)
+++ subversion/trunk/subversion/svn/cl.h Thu Feb 24 21:50:54 2022
@@ -733,6 +733,10 @@ svn_cl__check_externals_failed_notify_wr
 svn_error_t *
 svn_cl__notifier_print_conflict_stats(void *baton, apr_pool_t *scratch_pool);
 
+/* Get whether a WC upgrade notification was received. */
+svn_boolean_t
+svn_cl__notifier_get_wc_was_upgraded(void *baton);
+
 
 /*** Log message callback stuffs. ***/
 

Modified: subversion/trunk/subversion/svn/notify.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/notify.c?rev=1898397&r1=1898396&r2=1898397&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/notify.c (original)
+++ subversion/trunk/subversion/svn/notify.c Thu Feb 24 21:50:54 2022
@@ -57,6 +57,7 @@ struct notify_baton
   svn_revnum_t progress_revision;
   svn_boolean_t had_print_error; /* Used to not keep printing error messages
                                     when we've already had one print error. */
+  svn_boolean_t wc_was_upgraded;
 
   svn_cl__conflict_stats_t *conflict_stats;
 
@@ -284,6 +285,14 @@ svn_cl__notifier_print_conflict_stats(vo
   return SVN_NO_ERROR;
 }
 
+svn_boolean_t
+svn_cl__notifier_get_wc_was_upgraded(void *baton)
+{
+  struct notify_baton *nb = baton;
+
+  return nb->wc_was_upgraded;
+}
+
 /* The body for notify() function with standard error handling semantic.
  * Handling of errors implemented at caller side. */
 static svn_error_t *
@@ -1145,6 +1154,7 @@ notify_body(struct notify_baton *nb,
 
     case svn_wc_notify_upgraded_path:
       SVN_ERR(svn_cmdline_printf(pool, _("Upgraded '%s'\n"), path_local));
+      nb->wc_was_upgraded = TRUE;
       break;
 
     case svn_wc_notify_url_redirect:

Modified: subversion/trunk/subversion/svn/upgrade-cmd.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/upgrade-cmd.c?rev=1898397&r1=1898396&r2=1898397&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/upgrade-cmd.c (original)
+++ subversion/trunk/subversion/svn/upgrade-cmd.c Thu Feb 24 21:50:54 2022
@@ -32,6 +32,8 @@
 #include "svn_error_codes.h"
 #include "svn_error.h"
 #include "svn_path.h"
+#include "svn_version.h"
+#include "private/svn_subr_private.h"
 #include "cl.h"
 #include "svn_private_config.h"
 
@@ -50,6 +52,10 @@ svn_cl__upgrade(apr_getopt_t *os,
   apr_array_header_t *targets;
   apr_pool_t *iterpool;
   int i;
+  const svn_version_t *default_version
+    = svn_client_default_wc_version(scratch_pool);
+  const svn_version_t *latest_version
+    = svn_client_latest_wc_version(scratch_pool);
 
   SVN_ERR(svn_cl__args_to_target_array_print_reserved(&targets, os,
                                                       opt_state->targets,
@@ -76,5 +82,24 @@ svn_cl__upgrade(apr_getopt_t *os,
     }
   svn_pool_destroy(iterpool);
 
+  /* Remind the user they can upgrade further if:
+   *   - no upgrade was performed
+   *   - the user did not specify compatible-version explicitly
+   *   - a higher version is available. */
+  if (! svn_cl__notifier_get_wc_was_upgraded(ctx->notify_baton2)
+      && ! opt_state->compatible_version
+      && ! svn_version__at_least(default_version,
+                                 latest_version->major, latest_version->minor, 0)
+      && ! opt_state->quiet)
+    {
+      const char *msg
+        = _("Working copy is already at version %d.%d. "
+            "The highest version supported by this client can be "
+            "specified with '--compatible-version=%d.%d'.\n");
+      SVN_ERR(svn_cmdline_printf(scratch_pool, msg,
+                                 default_version->major, default_version->minor,
+                                 latest_version->major, latest_version->minor));
+    }
+
   return SVN_NO_ERROR;
 }