subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r1843066 - in /subversion/branches/better-pristines/subversion: include/private/ libsvn_client/ libsvn_wc/
Date Sun, 07 Oct 2018 17:10:37 GMT
Author: brane
Date: Sun Oct  7 17:10:36 2018
New Revision: 1843066

URL: http://svn.apache.org/viewvc?rev=1843066&view=rev
Log:
On the better-pristines branch: Guess the format of dependent working copies
(e.g., for externals) from the current working copy context.

* subversion/include/private/svn_wc_private.h
  (svn_wc__format_from_context): New.
* subversion/libsvn_wc/wc_db_wcroot.c
  (svn_wc__format_from_context): Implement.
* subversion/libsvn_wc/upgrade.c
  (svn_wc__format_from_version): Do not allow a NULL version parameter.

* subversion/libsvn_client/client.h
  (svn_client__checkout_internal): Update docstring.
* subversion/libsvn_client/upgrade.c
  (svn_client_upgrade2): Use the current libsvn_client version if the
   working copy format version is not supplied.
* subversion/libsvn_client/checkout.c (svn_client_checkout4): Likewise.
  (svn_client__checkout_internal) Use svn_wc__format_from_context to
   determine the default working copy format.

* subversion/libsvn_client/copy.c (repos_to_wc_copy_single),
* subversion/libsvn_client/conflicts.c (merge_incoming_added_dir_replace),
* subversion/libsvn_client/externals.c (switch_dir_external):
   Pass NULL for the default WC format to svn_client__checkout_internal.

Modified:
    subversion/branches/better-pristines/subversion/include/private/svn_wc_private.h
    subversion/branches/better-pristines/subversion/libsvn_client/checkout.c
    subversion/branches/better-pristines/subversion/libsvn_client/client.h
    subversion/branches/better-pristines/subversion/libsvn_client/conflicts.c
    subversion/branches/better-pristines/subversion/libsvn_client/copy.c
    subversion/branches/better-pristines/subversion/libsvn_client/externals.c
    subversion/branches/better-pristines/subversion/libsvn_client/upgrade.c
    subversion/branches/better-pristines/subversion/libsvn_wc/upgrade.c
    subversion/branches/better-pristines/subversion/libsvn_wc/wc_db_wcroot.c

Modified: subversion/branches/better-pristines/subversion/include/private/svn_wc_private.h
URL: http://svn.apache.org/viewvc/subversion/branches/better-pristines/subversion/include/private/svn_wc_private.h?rev=1843066&r1=1843065&r2=1843066&view=diff
==============================================================================
--- subversion/branches/better-pristines/subversion/include/private/svn_wc_private.h (original)
+++ subversion/branches/better-pristines/subversion/include/private/svn_wc_private.h Sun Oct
 7 17:10:36 2018
@@ -2124,6 +2124,21 @@ svn_wc__format_from_version(int *format,
                             apr_pool_t *scratch_pool);
 
 /**
+ * Set @a format to the format of the nearest parent working copy root of
+ * @a local_abspath in @a wc_ctx, or to the oldest format of any root stored
+ * there. If @a wc_ctx is empty, return the newset supported format.
+ *
+ * Use @a scratch_pool for temporary allocations.
+ *
+ * @since New in 1.12.
+ */
+svn_error_t *
+svn_wc__format_from_context(int *format,
+                            svn_wc_context_t *wc_ctx,
+                            const char *local_abspath,
+                            apr_pool_t *scratch_pool);
+
+/**
  * Ensure that an administrative area exists for @a local_abspath, so that @a
  * local_abspath is a working copy subdir with schema version @a target_format
  * based on @a url at @a revision, with depth @a depth, and with repository UUID

Modified: subversion/branches/better-pristines/subversion/libsvn_client/checkout.c
URL: http://svn.apache.org/viewvc/subversion/branches/better-pristines/subversion/libsvn_client/checkout.c?rev=1843066&r1=1843065&r2=1843066&view=diff
==============================================================================
--- subversion/branches/better-pristines/subversion/libsvn_client/checkout.c (original)
+++ subversion/branches/better-pristines/subversion/libsvn_client/checkout.c Sun Oct  7 17:10:36
2018
@@ -98,8 +98,12 @@ svn_client__checkout_internal(svn_revnum
       && (revision->kind != svn_opt_revision_head))
     return svn_error_create(SVN_ERR_CLIENT_BAD_REVISION, NULL, NULL);
 
-  SVN_ERR(svn_wc__format_from_version(&target_format, wc_format_version,
-                                      scratch_pool));
+  if (wc_format_version)
+    SVN_ERR(svn_wc__format_from_version(&target_format, wc_format_version,
+                                        scratch_pool));
+  else
+    SVN_ERR(svn_wc__format_from_context(&target_format, ctx->wc_ctx,
+                                        local_abspath, scratch_pool));
 
   /* Get the RA connection, if needed. */
   if (ra_session)
@@ -231,6 +235,10 @@ svn_client_checkout4(svn_revnum_t *resul
 
   SVN_ERR(svn_dirent_get_absolute(&local_abspath, path, pool));
 
+  /* A NULL wc_format_version translates to the current version. */
+  if (!wc_format_version)
+    wc_format_version = svn_client_version();
+
   err = svn_client__checkout_internal(result_rev, &sleep_here,
                                       URL, local_abspath,
                                       peg_revision, revision, depth,

Modified: subversion/branches/better-pristines/subversion/libsvn_client/client.h
URL: http://svn.apache.org/viewvc/subversion/branches/better-pristines/subversion/libsvn_client/client.h?rev=1843066&r1=1843065&r2=1843066&view=diff
==============================================================================
--- subversion/branches/better-pristines/subversion/libsvn_client/client.h (original)
+++ subversion/branches/better-pristines/subversion/libsvn_client/client.h Sun Oct  7 17:10:36
2018
@@ -540,8 +540,10 @@ svn_client__update_internal(svn_revnum_t
    to fail.
 
    A new working copy, if needed, will be created in the format corresponding
-   to the WC_FORMAT_VERSION of the client, where NULL means the current version
-   number. The format of any existing working copy will remain unchanged.
+   to the WC_FORMAT_VERSION of the client. If this parameter is NULL, the
+   format from CTX->WC_CTX will be and an error will be returned if the format
+   cannot be determined. The format of any existing working copy will remain
+   unchanged.
 
    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.

Modified: subversion/branches/better-pristines/subversion/libsvn_client/conflicts.c
URL: http://svn.apache.org/viewvc/subversion/branches/better-pristines/subversion/libsvn_client/conflicts.c?rev=1843066&r1=1843065&r2=1843066&view=diff
==============================================================================
--- subversion/branches/better-pristines/subversion/libsvn_client/conflicts.c (original)
+++ subversion/branches/better-pristines/subversion/libsvn_client/conflicts.c Sun Oct  7 17:10:36
2018
@@ -8053,7 +8053,7 @@ merge_incoming_added_dir_replace(svn_cli
                                       svn_depth_infinity,
                                       TRUE, /* we want to ignore externals */
                                       FALSE, /* we don't allow obstructions */
-                                      /* FIXME: WC FORMAT! */NULL,
+                                      NULL, /* default WC format */
                                       ra_session, ctx, scratch_pool);
 
   ctx->notify_func2 = old_notify_func2;

Modified: subversion/branches/better-pristines/subversion/libsvn_client/copy.c
URL: http://svn.apache.org/viewvc/subversion/branches/better-pristines/subversion/libsvn_client/copy.c?rev=1843066&r1=1843065&r2=1843066&view=diff
==============================================================================
--- subversion/branches/better-pristines/subversion/libsvn_client/copy.c (original)
+++ subversion/branches/better-pristines/subversion/libsvn_client/copy.c Sun Oct  7 17:10:36
2018
@@ -2419,7 +2419,7 @@ repos_to_wc_copy_single(svn_boolean_t *t
                                                 &pair->src_op_revision,
                                                 svn_depth_infinity,
                                                 ignore_externals, FALSE,
-                                                /* FIXME: WC FORMAT! */NULL,
+                                                NULL, /* default WC format */
                                                 ra_session, ctx, pool);
 
             ctx->notify_func2 = old_notify_func2;

Modified: subversion/branches/better-pristines/subversion/libsvn_client/externals.c
URL: http://svn.apache.org/viewvc/subversion/branches/better-pristines/subversion/libsvn_client/externals.c?rev=1843066&r1=1843065&r2=1843066&view=diff
==============================================================================
--- subversion/branches/better-pristines/subversion/libsvn_client/externals.c (original)
+++ subversion/branches/better-pristines/subversion/libsvn_client/externals.c Sun Oct  7 17:10:36
2018
@@ -412,7 +412,7 @@ switch_dir_external(const char *local_ab
                                         url, local_abspath, peg_revision,
                                         revision, svn_depth_infinity,
                                         FALSE, FALSE,
-                                        /* FIXME: WC FORMAT! */NULL,
+                                        NULL, /* default WC format */
                                         ra_session,
                                         ctx, pool));
 

Modified: subversion/branches/better-pristines/subversion/libsvn_client/upgrade.c
URL: http://svn.apache.org/viewvc/subversion/branches/better-pristines/subversion/libsvn_client/upgrade.c?rev=1843066&r1=1843065&r2=1843066&view=diff
==============================================================================
--- subversion/branches/better-pristines/subversion/libsvn_client/upgrade.c (original)
+++ subversion/branches/better-pristines/subversion/libsvn_client/upgrade.c Sun Oct  7 17:10:36
2018
@@ -192,6 +192,10 @@ svn_client_upgrade2(const char *path,
 {
   int wc_format;
 
+  /* A NULL wc_format_version translates to the current version. */
+  if (!wc_format_version)
+    wc_format_version = svn_client_version();
+
   SVN_ERR(svn_wc__format_from_version(&wc_format,
                                       wc_format_version,
                                       scratch_pool));

Modified: subversion/branches/better-pristines/subversion/libsvn_wc/upgrade.c
URL: http://svn.apache.org/viewvc/subversion/branches/better-pristines/subversion/libsvn_wc/upgrade.c?rev=1843066&r1=1843065&r2=1843066&view=diff
==============================================================================
--- subversion/branches/better-pristines/subversion/libsvn_wc/upgrade.c (original)
+++ subversion/branches/better-pristines/subversion/libsvn_wc/upgrade.c Sun Oct  7 17:10:36
2018
@@ -1646,11 +1646,7 @@ svn_wc__format_from_version(int *format,
                             const svn_version_t* version,
                             apr_pool_t *scratch_pool)
 {
-  if (!version)
-    {
-      *format = SVN_WC__VERSION;
-      return SVN_NO_ERROR;
-    }
+  SVN_ERR_ASSERT(version != NULL);
 
   if (version->major != SVN_VER_MAJOR || version->minor > SVN_VER_MINOR)
     return svn_error_createf(SVN_ERR_UNSUPPORTED_FEATURE, NULL,

Modified: subversion/branches/better-pristines/subversion/libsvn_wc/wc_db_wcroot.c
URL: http://svn.apache.org/viewvc/subversion/branches/better-pristines/subversion/libsvn_wc/wc_db_wcroot.c?rev=1843066&r1=1843065&r2=1843066&view=diff
==============================================================================
--- subversion/branches/better-pristines/subversion/libsvn_wc/wc_db_wcroot.c (original)
+++ subversion/branches/better-pristines/subversion/libsvn_wc/wc_db_wcroot.c Sun Oct  7 17:10:36
2018
@@ -31,6 +31,9 @@
 #include "svn_pools.h"
 #include "svn_version.h"
 
+#include "private/svn_fspath.h"
+#include "private/svn_sorts_private.h"
+
 #include "wc.h"
 #include "adm_files.h"
 #include "wc_db_private.h"
@@ -1028,3 +1031,68 @@ svn_wc__db_drop_root(svn_wc__db_t *db,
 
   return SVN_NO_ERROR;
 }
+
+
+/*
+ * ### FIXME:
+ *
+ * There must surely be a better way to find the nearest enclosing wcroot of a
+ * path than by copying the hash keys to an array and sorting the array.
+ *
+ * TODO: Convert the svn_wc__db_t::dir_data hash to a sorted dictionary?.
+ */
+svn_error_t *
+svn_wc__format_from_context(int *format,
+                            svn_wc_context_t *wc_ctx,
+                            const char *local_abspath,
+                            apr_pool_t *scratch_pool)
+{
+  apr_hash_t *const dir_data = wc_ctx->db->dir_data;
+  apr_array_header_t *keys;
+  int index;
+
+  /* Thsi is what we return if we don't find a concrete format version. */
+  SVN_ERR(svn_hash_keys(&keys, dir_data, scratch_pool));
+  if (0 == keys->nelts)
+    {
+      *format = SVN_WC__VERSION;
+      return SVN_NO_ERROR;
+    }
+
+  svn_sort__array(keys, svn_sort_compare_paths);
+  index = svn_sort__bsearch_lower_bound(keys, &local_abspath,
+                                        svn_sort_compare_paths);
+
+  /* If the previous key is a parent of the local_abspath, use its format. */
+  if (index > 0)
+    {
+      const char* const parent = APR_ARRAY_IDX(keys, index - 1, const char*);
+      const char* const common =
+        svn_fspath__get_longest_ancestor(parent, local_abspath, scratch_pool);
+
+      if (0 == strcmp(common, parent))
+        {
+          svn_wc__db_wcroot_t *wcroot = svn_hash_gets(dir_data, parent);
+          *format = wcroot->format;
+          return SVN_NO_ERROR;
+        }
+    }
+
+  /* Find the oldest format recorded in the WC context. */
+  {
+    int oldest_format = SVN_WC__VERSION;
+    apr_hash_index_t *hi;
+
+    for (hi = apr_hash_first(scratch_pool, dir_data);
+         hi;
+         hi = apr_hash_next(hi))
+      {
+        svn_wc__db_wcroot_t *wcroot = apr_hash_this_val(hi);
+        if (wcroot->format < oldest_format)
+          oldest_format = wcroot->format;
+      }
+
+    *format = oldest_format;
+    return SVN_NO_ERROR;
+  }
+}



Mime
View raw message