You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ko...@apache.org on 2022/12/06 20:21:46 UTC

svn commit: r1905812 - in /subversion/branches/pristines-on-demand-on-mwf: ./ subversion/include/private/svn_wc_private.h subversion/libsvn_wc/wc_db_wcroot.c

Author: kotkov
Date: Tue Dec  6 20:21:45 2022
New Revision: 1905812

URL: http://svn.apache.org/viewvc?rev=1905812&view=rev
Log:
On the 'pristines-on-demand-on-mwf' branch: Sync with trunk@1905810.

Resolve conflicts in the svn_wc_private.h and wc_db_wcroot.c files.

Modified:
    subversion/branches/pristines-on-demand-on-mwf/   (props changed)
    subversion/branches/pristines-on-demand-on-mwf/subversion/include/private/svn_wc_private.h
    subversion/branches/pristines-on-demand-on-mwf/subversion/libsvn_wc/wc_db_wcroot.c

Propchange: subversion/branches/pristines-on-demand-on-mwf/
------------------------------------------------------------------------------
  Merged /subversion/trunk:r1905755-1905810

Modified: subversion/branches/pristines-on-demand-on-mwf/subversion/include/private/svn_wc_private.h
URL: http://svn.apache.org/viewvc/subversion/branches/pristines-on-demand-on-mwf/subversion/include/private/svn_wc_private.h?rev=1905812&r1=1905811&r2=1905812&view=diff
==============================================================================
--- subversion/branches/pristines-on-demand-on-mwf/subversion/include/private/svn_wc_private.h (original)
+++ subversion/branches/pristines-on-demand-on-mwf/subversion/include/private/svn_wc_private.h Tue Dec  6 20:21:45 2022
@@ -2233,9 +2233,7 @@ svn_wc__min_supported_format_version(voi
 /**
  * Set @a *format_p and @a *store_pristine_p to the settings of the
  * nearest parent working copy root of @a local_abspath in @a wc_ctx,
- * or to settings of any root stored there, preferring the one with
- * the oldest format. If @a wc_ctx is empty, return the library's
- * default settings.
+ * or to the library's default settings if there are no such roots.
  *
  * Use @a scratch_pool for temporary allocations.
  *

Modified: subversion/branches/pristines-on-demand-on-mwf/subversion/libsvn_wc/wc_db_wcroot.c
URL: http://svn.apache.org/viewvc/subversion/branches/pristines-on-demand-on-mwf/subversion/libsvn_wc/wc_db_wcroot.c?rev=1905812&r1=1905811&r2=1905812&view=diff
==============================================================================
--- subversion/branches/pristines-on-demand-on-mwf/subversion/libsvn_wc/wc_db_wcroot.c (original)
+++ subversion/branches/pristines-on-demand-on-mwf/subversion/libsvn_wc/wc_db_wcroot.c Tue Dec  6 20:21:45 2022
@@ -31,8 +31,6 @@
 #include "svn_pools.h"
 #include "svn_version.h"
 
-#include "private/svn_sorts_private.h"
-
 #include "wc.h"
 #include "adm_files.h"
 #include "wc_db_private.h"
@@ -1070,14 +1068,6 @@ svn_wc__db_drop_root(svn_wc__db_t *db,
 }
 
 
-/*
- * ### 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__settings_from_context(int *format_p,
                               svn_boolean_t *store_pristine_p,
@@ -1085,77 +1075,25 @@ svn_wc__settings_from_context(int *forma
                               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;
-
-  /* This 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)
+  const char *current_path = local_abspath;
+
+  do
     {
-      *format_p = SVN_WC__DEFAULT_VERSION;
-      *store_pristine_p = TRUE;
-      return SVN_NO_ERROR;
-    }
+      svn_wc__db_wcroot_t *wcroot;
 
-  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. */
-  {
-    const char *const here = (index >= keys->nelts ? NULL
-                              : APR_ARRAY_IDX(keys, index, const char*));
-    const char *const prev = (index == 0 ? NULL
-                              : APR_ARRAY_IDX(keys, index - 1, const char*));
-
-    if (here)
-      {
-        const char *const child = svn_dirent_skip_ancestor(here, local_abspath);
-        if (child && !*child)
-          {
-            /* Found an exact match in the WC context. */
-            svn_wc__db_wcroot_t *wcroot = svn_hash_gets(dir_data, here);
-            *format_p = wcroot->format;
-            *store_pristine_p = wcroot->store_pristine;
-            return SVN_NO_ERROR;
-          }
-      }
-
-    if (prev)
-      {
-        const char *const child = svn_dirent_skip_ancestor(prev, local_abspath);
-        if (child)
-          {
-            /* Found the parent path in the WC context. */
-            svn_wc__db_wcroot_t *wcroot = svn_hash_gets(dir_data, prev);
-            *format_p = wcroot->format;
-            *store_pristine_p = wcroot->store_pristine;
-            return SVN_NO_ERROR;
-          }
-      }
-  }
-
-  /* Find the oldest format recorded in the WC context. */
-  {
-    int oldest_format = SVN_WC__VERSION;
-    svn_boolean_t store_pristine = TRUE;
-    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;
-            store_pristine = wcroot->store_pristine;
-          }
-      }
+      wcroot = svn_hash_gets(wc_ctx->db->dir_data, current_path);
+      if (wcroot)
+        {
+          *format_p = wcroot->format;
+          *store_pristine_p = wcroot->store_pristine;
+          return SVN_NO_ERROR;
+        }
 
-    *format_p = oldest_format;
-    *store_pristine_p = store_pristine;
-    return SVN_NO_ERROR;
-  }
+      current_path = svn_dirent_dirname(current_path, scratch_pool);
+    }
+  while (!svn_dirent_is_root(current_path, strlen(current_path)));
+
+  *format_p = SVN_WC__DEFAULT_VERSION;
+  *store_pristine_p = TRUE;
+  return SVN_NO_ERROR;
 }