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/13 09:49:30 UTC

svn commit: r1905955 [6/6] - in /subversion/trunk: ./ build/ build/generator/ notes/i525/ subversion/include/ subversion/include/private/ subversion/libsvn_client/ subversion/libsvn_fs_x/ subversion/libsvn_ra/ subversion/libsvn_ra_local/ subversion/lib...

Modified: subversion/trunk/subversion/tests/libsvn_wc/wc-queries-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_wc/wc-queries-test.c?rev=1905955&r1=1905954&r2=1905955&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_wc/wc-queries-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_wc/wc-queries-test.c Tue Dec 13 09:49:29 2022
@@ -106,14 +106,24 @@ static const int slow_statements[] =
   STMT_SELECT_PRESENT_HIGHEST_WORKING_NODES_BY_BASENAME_AND_KIND,
   STMT_SELECT_COPIES_OF_REPOS_RELPATH,
 
-  /* Designed as slow to avoid penalty on other queries */
-  STMT_SELECT_UNREFERENCED_PRISTINES,
-
   /* Slow, but just if foreign keys are enabled:
    * STMT_DELETE_PRISTINE_IF_UNREFERENCED,
    */
   STMT_HAVE_STAT1_TABLE, /* Queries sqlite_master which has no index */
 
+  /* Currently uses a temporary B-tree for GROUP BY */
+  STMT_TEXTBASE_SYNC,
+
+  -1 /* final marker */
+};
+
+/* These statements are slow in WC format 31, but not in latest format. */
+static const int slow_statements_f31[] =
+{
+  /* Format 31: "designed as slow to avoid penalty on other queries"
+   * Format 32: now indexed. */
+  STMT_SELECT_UNREFERENCED_PRISTINES,
+
   -1 /* final marker */
 };
 
@@ -145,7 +155,9 @@ in_list(const int list[], int stmt_idx)
 }
 
 /* Helpers to determine if a statement is in a common list */
-#define is_slow_statement(stmt_idx) in_list(slow_statements, stmt_idx)
+#define is_slow_statement(stmt_idx, wc_format) \
+    (in_list(slow_statements, stmt_idx) \
+     || (wc_format == 31 && in_list(slow_statements_f31, stmt_idx)))
 #define is_schema_statement(stmt_idx) \
     ((stmt_idx >= STMT_SCHEMA_FIRST) || in_list(schema_statements, stmt_idx))
 
@@ -216,6 +228,40 @@ test_sqlite_version(apr_pool_t *scratch_
 #endif
 }
 
+/* Return TRUE iff statement STMT_NUM is valid in the schema for
+ * WC format FORMAT. */
+static svn_boolean_t
+stmt_matches_wc_format(int stmt_num,
+                       const svn_test_opts_t *opts,
+                       apr_pool_t *pool)
+{
+  int wc_format = -1;
+
+  svn_error_clear(svn_wc__format_from_version(
+                    &wc_format, opts->wc_format_version, pool));
+  switch (stmt_num)
+    {
+    case STMT_INSERT_OR_IGNORE_PRISTINE_F31:
+    case STMT_UPSERT_PRISTINE_F31:
+    case STMT_SELECT_PRISTINE_F31:
+    case STMT_SELECT_COPY_PRISTINES_F31:
+      return (wc_format <= 31);
+    case STMT_INSERT_OR_IGNORE_PRISTINE_F32:
+    case STMT_UPSERT_PRISTINE_F32:
+    case STMT_SELECT_PRISTINE_F32:
+    case STMT_SELECT_COPY_PRISTINES_F32:
+    case STMT_UPDATE_PRISTINE_HYDRATED:
+    case STMT_TEXTBASE_ADD_REF:
+    case STMT_TEXTBASE_REMOVE_REF:
+    case STMT_TEXTBASE_WALK:
+    case STMT_TEXTBASE_SYNC:
+    case STMT_SELECT_SETTINGS:
+    case STMT_UPSERT_SETTINGS:
+      return (wc_format >= 32);
+    }
+  return TRUE;
+}
+
 /* Parse all normal queries */
 static svn_error_t *
 test_parsable(const svn_test_opts_t *opts,
@@ -234,6 +280,9 @@ test_parsable(const svn_test_opts_t *opt
       if (is_schema_statement(i))
         continue;
 
+      if (!stmt_matches_wc_format(i, opts, scratch_pool))
+        continue;
+
       /* Some of our statement texts contain multiple queries. We prepare
          them all. */
       while (*text != '\0')
@@ -651,6 +700,10 @@ test_query_expectations(const svn_test_o
   apr_pool_t *iterpool = svn_pool_create(scratch_pool);
   svn_error_t *warnings = NULL;
   svn_boolean_t supports_query_info;
+  int wc_format;
+
+  SVN_ERR(svn_wc__format_from_version(&wc_format, opts->wc_format_version,
+                                      scratch_pool));
 
   SVN_ERR(create_memory_db(&sdb, opts, scratch_pool));
 
@@ -674,6 +727,9 @@ test_query_expectations(const svn_test_o
       if (is_schema_statement(i))
         continue;
 
+      if (!stmt_matches_wc_format(i, opts, scratch_pool))
+        continue;
+
       /* Prepare statement to find if it is a single statement. */
       r = sqlite3_prepare_v2(sdb, wc_queries[i], -1, &stmt, &tail);
 
@@ -734,7 +790,7 @@ test_query_expectations(const svn_test_o
               && item->automatic_index)
             {
               warned = TRUE;
-              if (!is_slow_statement(i))
+              if (!is_slow_statement(i, wc_format))
                 {
                   warnings = svn_error_createf(SVN_ERR_TEST_FAILED, warnings,
                                 "%s: "
@@ -761,7 +817,7 @@ test_query_expectations(const svn_test_o
                      statements is not our concern here. */
 
                   /* "Slow" statements do expect to see a warning, however. */
-                  if (is_slow_statement(i))
+                  if (is_slow_statement(i, wc_format))
                     warned = TRUE;
                 }
               else if (in_list(primary_key_statements, i))
@@ -770,7 +826,7 @@ test_query_expectations(const svn_test_o
                      as table scan in 3.8+, while the execution plan is
                      identical: read first record from table */
                 }
-              else if (!is_slow_statement(i))
+              else if (!is_slow_statement(i, wc_format))
                 {
                   warned = TRUE;
                   warnings = svn_error_createf(SVN_ERR_TEST_FAILED, warnings,
@@ -786,7 +842,7 @@ test_query_expectations(const svn_test_o
           else if (item->search && !item->index)
             {
               warned = TRUE;
-              if (!is_slow_statement(i))
+              if (!is_slow_statement(i, wc_format))
                 warnings = svn_error_createf(SVN_ERR_TEST_FAILED, warnings,
                                 "%s: "
                                 "Query on %s doesn't use an index:\n%s",
@@ -795,7 +851,7 @@ test_query_expectations(const svn_test_o
           else if (item->scan && !is_result_table(item->table))
             {
               warned = TRUE;
-              if (!is_slow_statement(i))
+              if (!is_slow_statement(i, wc_format))
                 warnings = svn_error_createf(SVN_ERR_TEST_FAILED, warnings,
                                 "Query %s: "
                                 "Performs scan on %s:\n%s",
@@ -804,7 +860,7 @@ test_query_expectations(const svn_test_o
           else if (item->create_btree)
             {
               warned = TRUE;
-              if (!is_slow_statement(i))
+              if (!is_slow_statement(i, wc_format))
                 warnings = svn_error_createf(SVN_ERR_TEST_FAILED, warnings,
                                 "Query %s: Creates a temporary B-TREE:\n%s",
                                 wc_query_info[i][0], wc_queries[i]);
@@ -813,13 +869,13 @@ test_query_expectations(const svn_test_o
       SQLITE_ERR(sqlite3_reset(stmt));
       SQLITE_ERR(sqlite3_finalize(stmt));
 
-      if (!warned && is_slow_statement(i))
+      if (!warned && is_slow_statement(i, wc_format))
         {
           printf("DBG: Expected %s to be reported as slow, but it wasn't\n",
                  wc_query_info[i][0]);
         }
 
-      if (rows && warned != is_slow_statement(i))
+      if (rows && warned != is_slow_statement(i, wc_format))
         {
           int w;
           svn_error_t *info = NULL;

Modified: subversion/trunk/subversion/tests/libsvn_wc/wc-test-queries.sql
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_wc/wc-test-queries.sql?rev=1905955&r1=1905954&r2=1905955&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_wc/wc-test-queries.sql (original)
+++ subversion/trunk/subversion/tests/libsvn_wc/wc-test-queries.sql Tue Dec 13 09:49:29 2022
@@ -60,12 +60,18 @@ DELETE FROM actual_node;
 INSERT INTO actual_node (local_relpath, parent_relpath, changelist, wc_id)
                 VALUES (?1, ?2, ?3, 1)
 
--- STMT_ENSURE_EMPTY_PRISTINE
+-- STMT_ENSURE_EMPTY_PRISTINE_F31
 INSERT OR IGNORE INTO pristine (checksum, md5_checksum, size, refcount)
   VALUES ('$sha1$da39a3ee5e6b4b0d3255bfef95601890afd80709',
           '$md5 $d41d8cd98f00b204e9800998ecf8427e',
           0, 0)
 
+-- STMT_ENSURE_EMPTY_PRISTINE_F32
+INSERT OR IGNORE INTO pristine (checksum, md5_checksum, size, refcount, hydrated)
+  VALUES ('$sha1$da39a3ee5e6b4b0d3255bfef95601890afd80709',
+          '$md5 $d41d8cd98f00b204e9800998ecf8427e',
+          0, 0, 1)
+
 -- STMT_NODES_SET_FILE
 UPDATE nodes
    SET kind = 'file',

Modified: subversion/trunk/subversion/tests/libsvn_wc/wc-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_wc/wc-test.c?rev=1905955&r1=1905954&r2=1905955&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_wc/wc-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_wc/wc-test.c Tue Dec 13 09:49:29 2022
@@ -771,6 +771,52 @@ test_internal_file_modified_eol_style(co
   return SVN_NO_ERROR;
 }
 
+static svn_error_t *
+test_get_pristine_copy_path(const svn_test_opts_t *opts, apr_pool_t *pool)
+{
+  svn_test__sandbox_t b;
+  svn_boolean_t store_pristine;
+  const char *pristine_path;
+  svn_node_kind_t kind;
+  svn_stringbuf_t *actual_content;
+
+  SVN_ERR(svn_test__sandbox_create(&b, "get_pristine_copy_path", opts, pool));
+
+  SVN_ERR(svn_wc__db_get_settings(NULL, &store_pristine,
+                                  b.wc_ctx->db, b.wc_abspath, pool));
+  if (!store_pristine)
+    return svn_error_create(SVN_ERR_TEST_SKIPPED, NULL,
+                            "Test assumes a working copy with pristine");
+
+  SVN_ERR(sbox_file_write(&b, "file", "content"));
+  SVN_ERR(sbox_wc_add(&b, "file"));
+
+  SVN_ERR(svn_wc_get_pristine_copy_path(sbox_wc_path(&b, "file"),
+                                        &pristine_path, pool));
+  SVN_ERR(svn_io_check_path(pristine_path, &kind, pool));
+  SVN_TEST_INT_ASSERT(kind, svn_node_none);
+
+  SVN_ERR(sbox_wc_commit(&b, ""));
+
+  SVN_ERR(svn_wc_get_pristine_copy_path(sbox_wc_path(&b, "file"),
+                                        &pristine_path, pool));
+  SVN_ERR(svn_io_check_path(pristine_path, &kind, pool));
+  SVN_TEST_INT_ASSERT(kind, svn_node_file);
+  SVN_ERR(svn_stringbuf_from_file2(&actual_content, pristine_path, pool));
+  SVN_TEST_STRING_ASSERT(actual_content->data, "content");
+
+  SVN_ERR(sbox_wc_copy(&b, "file", "file2"));
+
+  SVN_ERR(svn_wc_get_pristine_copy_path(sbox_wc_path(&b, "file2"),
+                                        &pristine_path, pool));
+  SVN_ERR(svn_io_check_path(pristine_path, &kind, pool));
+  SVN_TEST_INT_ASSERT(kind, svn_node_file);
+  SVN_ERR(svn_stringbuf_from_file2(&actual_content, pristine_path, pool));
+  SVN_TEST_STRING_ASSERT(actual_content->data, "content");
+
+  return SVN_NO_ERROR;
+}
+
 /* ---------------------------------------------------------------------- */
 /* The list of test functions */
 
@@ -803,6 +849,8 @@ static struct svn_test_descriptor_t test
                        "test internal_file_modified with keywords"),
     SVN_TEST_OPTS_PASS(test_internal_file_modified_eol_style,
                        "test internal_file_modified with eol-style"),
+    SVN_TEST_OPTS_PASS(test_get_pristine_copy_path,
+                       "test svn_wc_get_pristine_copy_path"),
     SVN_TEST_NULL
   };
 

Modified: subversion/trunk/subversion/tests/svn_test.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/svn_test.h?rev=1905955&r1=1905954&r2=1905955&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/svn_test.h (original)
+++ subversion/trunk/subversion/tests/svn_test.h Tue Dec 13 09:49:29 2022
@@ -219,6 +219,7 @@ typedef struct svn_test_opts_t
   /* WC format version to use for all tests (except tests for a specific format) */
   const svn_version_t *wc_format_version;
   svn_boolean_t verbose;
+  svn_tristate_t store_pristine;
   /* Add future "arguments" here. */
 } svn_test_opts_t;
 

Modified: subversion/trunk/subversion/tests/svn_test_main.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/svn_test_main.c?rev=1905955&r1=1905954&r2=1905955&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/svn_test_main.c (original)
+++ subversion/trunk/subversion/tests/svn_test_main.c Tue Dec 13 09:49:29 2022
@@ -111,7 +111,8 @@ enum test_options_e {
   mode_filter_opt,
   sqlite_log_opt,
   parallel_opt,
-  fsfs_version_opt
+  fsfs_version_opt,
+  store_pristine_opt
 };
 
 static const apr_getopt_option_t cl_options[] =
@@ -157,6 +158,8 @@ static const apr_getopt_option_t cl_opti
                     N_("enable SQLite logging")},
   {"parallel",      parallel_opt, 0,
                     N_("allow concurrent execution of tests")},
+  {"store-pristine", store_pristine_opt, 1,
+                    N_("set the WC pristine mode")},
   {0,               0, 0, 0}
 };
 
@@ -808,6 +811,7 @@ svn_test_main(int argc, const char *argv
   svn_test_opts_t opts = { NULL };
 
   opts.fs_type = DEFAULT_FS_TYPE;
+  opts.store_pristine = svn_tristate_unknown;
 
   /* Initialize APR (Apache pools) */
   if (apr_initialize() != APR_SUCCESS)
@@ -1024,6 +1028,18 @@ svn_test_main(int argc, const char *argv
           parallel = TRUE;
           break;
 #endif
+        case store_pristine_opt:
+          {
+            const char *utf8_opt_arg;
+            SVN_INT_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
+            opts.store_pristine = svn_tristate__from_word(utf8_opt_arg);
+            if (opts.store_pristine == svn_tristate_unknown)
+              {
+                fprintf(stderr, "FAIL: Invalid --store-pristine option.\n");
+                exit(1);
+              }
+            break;
+          }
       }
     }
   opts.verbose = verbose_mode;

Propchange: subversion/trunk/tools/buildbot/slaves/win32-vcpkg/
------------------------------------------------------------------------------
  Merged /subversion/branches/pristines-on-demand-on-mwf/tools/buildbot/slaves/win32-vcpkg:r1897945-1905954

Modified: subversion/trunk/tools/client-side/bash_completion
URL: http://svn.apache.org/viewvc/subversion/trunk/tools/client-side/bash_completion?rev=1905955&r1=1905954&r2=1905955&view=diff
==============================================================================
--- subversion/trunk/tools/client-side/bash_completion (original)
+++ subversion/trunk/tools/client-side/bash_completion Tue Dec 13 09:49:29 2022
@@ -882,7 +882,7 @@ _svn()
 		;;
 	checkout|co)
 		cmdOpts="$rOpts $qOpts $nOpts $pOpts --ignore-externals \
-                         --force"
+                         --force --store-pristine"
 		;;
 	cleanup)
 		cmdOpts="$pOpts --include-externals -q --quiet\

Modified: subversion/trunk/win-tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/win-tests.py?rev=1905955&r1=1905954&r2=1905955&view=diff
==============================================================================
--- subversion/trunk/win-tests.py (original)
+++ subversion/trunk/win-tests.py Tue Dec 13 09:49:29 2022
@@ -115,6 +115,7 @@ def _usage_exit():
   print("  --fsfs-packing         : Run 'svnadmin pack' automatically")
   print("  --fsfs-compression=VAL : Set compression type to VAL (for fsfs)")
   print("  --wc-format-version=VAL: Set the WC format version")
+  print("  --store-pristine=VAL   : Set the WC pristine mode")
   print("  -q, --quiet            : Deprecated; this is the default.")
   print("                           Use --set-log-level instead.")
 
@@ -147,6 +148,7 @@ opts, args = my_getopt(sys.argv[1:], 'hr
                         'ssl-cert=', 'exclusive-wc-locks', 'memcached-server=',
                         'skip-c-tests', 'dump-load-cross-check', 'memcached-dir=',
                         'fsfs-compression=', 'wc-format-version=',
+                        'store-pristine='
                         ])
 if len(args) > 1:
   print('Warning: non-option arguments after the first one will be ignored')
@@ -195,6 +197,7 @@ dump_load_cross_check = None
 fsfs_compression = None
 fsfs_dir_deltification = None
 wc_format_version = None
+store_pristine = None
 
 for opt, val in opts:
   if opt in ('-h', '--help'):
@@ -295,6 +298,8 @@ for opt, val in opts:
     fsfs_dir_deltification = val
   elif opt == '--wc-format-version':
     wc_format_version = val
+  elif opt == '--store-pristine':
+    store_pristine = val
 
 # Calculate the source and test directory names
 abs_srcdir = os.path.abspath("")
@@ -1137,6 +1142,7 @@ if not test_javahl and not test_swig:
   opts.fsfs_compression = fsfs_compression
   opts.fsfs_dir_deltification = fsfs_dir_deltification
   opts.wc_format_version = wc_format_version
+  opts.store_pristine = store_pristine
   th = run_tests.TestHarness(abs_srcdir, abs_builddir,
                              log_file, fail_log_file, opts)
   old_cwd = os.getcwd()