subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danie...@apache.org
Subject svn commit: r1465147 - in /subversion/trunk/subversion: include/svn_repos.h libsvn_repos/repos.c libsvn_repos/repos.h tests/libsvn_repos/repos-test.c
Date Fri, 05 Apr 2013 22:05:18 GMT
Author: danielsh
Date: Fri Apr  5 22:05:18 2013
New Revision: 1465147

URL: http://svn.apache.org/r1465147
Log:
Redesign and implement "fetch repository info".

Introduce independent functions, replacing the info struct.  Remove hooks
support for now; it could be added by reusing hooks.c:check_hook_cmd().

* subversion/include/svn_repos.h
  (svn_repos_capabilities): Point to this function from the "if you add a new
    capability" comment.
  (svn_repos_info_format): New function.
  (svn_repos_info, svn_repos_info_t, svn_repos_info_dup):
    Delete declarations (which have never been implemented)..

* subversion/libsvn_repos/repos.c
  (svn_repos_capabilities): Implement.
  (svn_repos_info_format): Implement.
  (svn_repos_info, svn_repos_info_t, svn_repos_info_dup):
    Delete stub definitions.

* subversion/tests/libsvn_repos/repos-test.c
  (svn_hash.h, svn_version.h): Include.
  (test_repos_info): New function.
  (test_funcs): Run it.

* subversion/libsvn_repos/repos.h
  (SVN_REPOS__FORMAT_NUMBER, SVN_REPOS__FORMAT_NUMBER_1_4):
    Juggle macros a little to ensure that svn_repos_info_format() would trip
    if we increment the format number without changing the "format number to
    version number" logic therein.

Modified:
    subversion/trunk/subversion/include/svn_repos.h
    subversion/trunk/subversion/libsvn_repos/repos.c
    subversion/trunk/subversion/libsvn_repos/repos.h
    subversion/trunk/subversion/tests/libsvn_repos/repos-test.c

Modified: subversion/trunk/subversion/include/svn_repos.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_repos.h?rev=1465147&r1=1465146&r2=1465147&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_repos.h (original)
+++ subversion/trunk/subversion/include/svn_repos.h Fri Apr  5 22:05:18 2013
@@ -528,6 +528,8 @@ svn_repos_capabilities(apr_hash_t **capa
  * colons for their own reasons.  While this RA limitation has no
  * direct impact on repository capabilities, there's no reason to be
  * gratuitously different either.
+ *
+ * If you add a capability, update svn_repos_capabilities().
  */
 
 
@@ -2484,6 +2486,25 @@ svn_repos_node_editor(const svn_delta_ed
 svn_repos_node_t *
 svn_repos_node_from_baton(void *edit_baton);
 
+/**
+ * Return repository format information for @a repos.
+ *
+ * Set @a *repos_format to the repository format number of @a repos, which is
+ * an integer that increases when incompatible changes are made (such as
+ * by #svn_repos_upgrade).
+ *
+ * Set @a *supports_version to the version number of the minimum Subversion GA
+ * release that can read and write @a repos.
+ *
+ * @since New in 1.8.
+ */
+svn_error_t *
+svn_repos_info_format(int *repos_format,
+                      svn_version_t **supports_version,
+                      svn_repos_t *repos,
+                      apr_pool_t *result_pool,
+                      apr_pool_t *scratch_pool);
+
 /** @} */
 
 /* ---------------------------------------------------------------*/
@@ -3406,77 +3427,6 @@ svn_repos_remember_client_capabilities(s
                                        const apr_array_header_t *capabilities);
 
 
-
-/** Info. **/
-/**
- * @defgroup repos_info Repository information subsystem
- * @{
- */
-
-/**
- * A structure that provides some information about a repository.
- * Returned by svn_repos_info().
- *
- * @note Fields may be added to the end of this structure in future
- * versions.  Therefore, users shouldn't allocate structures of this
- * type, to preserve binary compatibility.
- *
- * @since New in 1.8.
- */
-typedef struct svn_repos_info_t {
-
-  /** Repository format number: an integer that increases when incompatible
-   * changes are made (such as by #svn_repos_upgrade). */
-  int repos_format;
-
-  /** The oldest Subversion GA release that can read and write this
-   * repository. */
-  svn_version_t *supports_version;
-
-  /** Set of basenames of hook scripts which have been installed.
-   * Keys are C strings such as "post-commit", values are undefined. */
-  apr_hash_t *hooks_enabled;
-
-  /** Set of basenames of hook scripts which are respected by this version of
-   * Subversion.  Keys are C strings such as "post-commit", values are
-   * undefined.
-   *
-   * @note Hooks are sometimes extended (e.g., by passing additional arguments
-   * to them).  In the future we might extend the semantics of this hash to
-   * describe that case, for example by adding keys or defining a meaning for
-   * the values.
-   */
-  apr_hash_t *hooks_known;
-
-  /** @see svn_fs_info(), svn_repos_fs() */
-  svn_fs_info_t *fs_info;
-
-} svn_repos_info_t;
-
-/**
- * Set @a *info to an info struct describing @a repos.
- *
- * @see #svn_repos_info_t, svn_repos_capabilities()
- *
- * @since New in 1.8.
- */
-svn_error_t *
-svn_repos_info(const svn_repos_info_t **info,
-               svn_repos_t *repos,
-               apr_pool_t *result_pool,
-               apr_pool_t *scratch_pool);
-
-/**
- * Return a duplicate of @a info, allocated in @a pool. No part of the new
- * structure will be shared with @a info.
- *
- * @since New in 1.8.
- */
-svn_repos_info_t *
-svn_repos_info_dup(const svn_repos_info_t *info,
-                   apr_pool_t *result_pool);
-
-
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */

Modified: subversion/trunk/subversion/libsvn_repos/repos.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/repos.c?rev=1465147&r1=1465146&r2=1465147&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/repos.c (original)
+++ subversion/trunk/subversion/libsvn_repos/repos.c Fri Apr  5 22:05:18 2013
@@ -1683,9 +1683,47 @@ svn_repos_capabilities(apr_hash_t **capa
                        apr_pool_t *result_pool,
                        apr_pool_t *scratch_pool)
 {
-  SVN__NOT_IMPLEMENTED();
+  static const char *const queries[] = {
+    SVN_REPOS_CAPABILITY_MERGEINFO,
+    NULL
+  };
+  const char *const *i;
+
+  *capabilities = apr_hash_make(result_pool);
+
+  for (i = queries; *i; i++)
+    {
+      svn_boolean_t has;
+      SVN_ERR(svn_repos_has_capability(repos, &has, *i, scratch_pool));
+      if (has)
+        svn_hash_sets(*capabilities, *i, *i);
+    }
+
+  return SVN_NO_ERROR;
 }
 
+svn_error_t *
+svn_repos_info_format(int *repos_format,
+                      svn_version_t **supports_version,
+                      svn_repos_t *repos,
+                      apr_pool_t *result_pool,
+                      apr_pool_t *scratch_pool)
+{
+  *repos_format = repos->format;
+  *supports_version = apr_palloc(result_pool, sizeof(svn_version_t));
+
+  (*supports_version)->major = SVN_VER_MAJOR;
+  (*supports_version)->minor = 0;
+  (*supports_version)->patch = 0;
+  (*supports_version)->tag = "";
+
+  if (repos->format == SVN_REPOS__FORMAT_NUMBER_1_4)
+    (*supports_version)->minor = 4;
+  else
+    SVN_ERR_ASSERT(repos->format == SVN_REPOS__FORMAT_NUMBER_LEGACY);
+
+  return SVN_NO_ERROR;
+}
 
 svn_fs_t *
 svn_repos_fs(svn_repos_t *repos)
@@ -2140,23 +2178,3 @@ svn_repos__fs_type(const char **fs_type,
                      svn_dirent_join(repos_path, SVN_REPOS__DB_DIR, pool),
                      pool);
 }
-
-
-/** info **/
-svn_error_t *
-svn_repos_info(const svn_repos_info_t **info,
-               svn_repos_t *repos,
-               apr_pool_t *result_pool,
-               apr_pool_t *scratch_pool)
-{
-  SVN__NOT_IMPLEMENTED();
-}
-
-svn_repos_info_t *
-svn_repos_info_dup(const svn_repos_info_t *info,
-                   apr_pool_t *result_pool)
-{
-  /* Not implemented. */
-  SVN_ERR_MALFUNCTION_NO_RETURN();
-  return NULL;
-}

Modified: subversion/trunk/subversion/libsvn_repos/repos.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/repos.h?rev=1465147&r1=1465146&r2=1465147&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/repos.h (original)
+++ subversion/trunk/subversion/libsvn_repos/repos.h Fri Apr  5 22:05:18 2013
@@ -47,7 +47,8 @@ extern "C" {
    formats are accepted by some versions of Subversion which do not
    pay attention to the FS format number.
 */
-#define SVN_REPOS__FORMAT_NUMBER         5
+#define SVN_REPOS__FORMAT_NUMBER         SVN_REPOS__FORMAT_NUMBER_1_4
+#define SVN_REPOS__FORMAT_NUMBER_1_4     5
 #define SVN_REPOS__FORMAT_NUMBER_LEGACY  3
 
 

Modified: subversion/trunk/subversion/tests/libsvn_repos/repos-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_repos/repos-test.c?rev=1465147&r1=1465146&r2=1465147&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_repos/repos-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_repos/repos-test.c Fri Apr  5 22:05:18 2013
@@ -29,11 +29,13 @@
 #include "svn_pools.h"
 #include "svn_error.h"
 #include "svn_fs.h"
+#include "svn_hash.h"
 #include "svn_repos.h"
 #include "svn_path.h"
 #include "svn_delta.h"
 #include "svn_config.h"
 #include "svn_props.h"
+#include "svn_version.h"
 
 #include "../svn_test_fs.h"
 
@@ -3254,6 +3256,45 @@ filename_with_control_chars(const svn_te
 
   return SVN_NO_ERROR;
 }
+
+static svn_error_t *
+test_repos_info(const svn_test_opts_t *opts,
+                apr_pool_t *pool)
+{
+  svn_repos_t *repos;
+  svn_test_opts_t opts2;
+  apr_hash_t *capabilities;
+  svn_version_t *supports_version;
+  svn_version_t v1_0_0 = {1, 0, 0, ""};
+  svn_version_t v1_4_0 = {1, 4, 0, ""};
+  int repos_format;
+  
+  opts2 = *opts;
+
+  opts2.server_minor_version = 3;
+  SVN_ERR(svn_test__create_repos(&repos, "test-repo-info-3",
+                                 &opts2, pool));
+  SVN_ERR(svn_repos_capabilities(&capabilities, repos, pool, pool));
+  SVN_TEST_ASSERT(apr_hash_count(capabilities) == 0);
+  SVN_ERR(svn_repos_info_format(&repos_format, &supports_version, repos,
+                                pool, pool));
+  SVN_TEST_ASSERT(repos_format == 3);
+  SVN_TEST_ASSERT(svn_ver_equal(supports_version, &v1_0_0));
+
+  opts2.server_minor_version = 8;
+  SVN_ERR(svn_test__create_repos(&repos, "test-repo-info-8",
+                                 &opts2, pool));
+  SVN_ERR(svn_repos_capabilities(&capabilities, repos, pool, pool));
+  SVN_TEST_ASSERT(apr_hash_count(capabilities) == 1);
+  SVN_TEST_ASSERT(svn_hash_gets(capabilities, SVN_REPOS_CAPABILITY_MERGEINFO));
+  SVN_ERR(svn_repos_info_format(&repos_format, &supports_version, repos,
+                                pool, pool));
+  SVN_TEST_ASSERT(repos_format == 5);
+  SVN_TEST_ASSERT(svn_ver_equal(supports_version, &v1_4_0));
+
+  return SVN_NO_ERROR;
+}
+
 
 /* The test table.  */
 
@@ -3300,5 +3341,7 @@ struct svn_test_descriptor_t test_funcs[
                        "test svn_repos_delete"),
     SVN_TEST_OPTS_PASS(filename_with_control_chars,
                        "test filenames with control characters"),
+    SVN_TEST_OPTS_PASS(test_repos_info,
+                       "test svn_repos_info_*"),
     SVN_TEST_NULL
   };



Mime
View raw message