You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by rh...@apache.org on 2015/11/30 15:02:26 UTC

svn commit: r1717253 - in /subversion/branches/ra-git: ./ build/generator/ subversion/include/ subversion/libsvn_fs/ subversion/libsvn_fs_git/

Author: rhuijben
Date: Mon Nov 30 14:02:26 2015
New Revision: 1717253

URL: http://svn.apache.org/viewvc?rev=1717253&view=rev
Log:
On the ra-git branch: To avoid having to reimplement quite a bit of the repos
layer code to support a git backend (as the branch currently does), start
moving a bit of git code to the fs layer so the existing repos layer code
can be used to access git state.

For this experiment I try to build a readonly git filesystem to just support
libsvn_ra_git's access to read the repository.

As a side effect this filesystem may support other code like 'svnadmin dump',
to work on this level as this happens to have the same requirements. It might
also make it easy to publish git repositories on a Subversion compatible url.

The backend for this filesystem will be a git repository
(accessed by libgit2) and an sqlite database containing some mapping
information.

The short term goal is to support svn:externals pointing to a git repository,
like the current branch does.

* build.conf
  (libsvn_fs_git): New filesystem.
  (libsvn_ra_git,
   fs-libs): Declare usage of libsvn_fs_git.

* build/generator/gen_win_dependencies.py
  (_find_libgit2): Use revision instead of PATCH. Define
    SVN_LIBSVN_FS_LINKS_FS_GIT.

* subversion/include/svn_fs.h
  (SVN_FS_TYPE_GIT): Define.

* subversion/libsvn_fs/fs-loader.c
  (git_defn): New definition.
  (base_defn): Hook definition.
  (synchronized_initialize): Reset the new last filesystem.

* subversion/libsvn_fs/fs-loader.h
  (fs includes): Add ../libsvn_fs_git/fs_init.h.

* subversion/libsvn_fs_git
  New directory.

* subversion/libsvn_fs_git/fs.c
  New file.
* subversion/libsvn_fs_git/fs_git.h
  New file.
* subversion/libsvn_fs_git/fs_init.h
  New file.

Added:
    subversion/branches/ra-git/subversion/libsvn_fs_git/
    subversion/branches/ra-git/subversion/libsvn_fs_git/fs.c   (with props)
    subversion/branches/ra-git/subversion/libsvn_fs_git/fs_git.h   (with props)
    subversion/branches/ra-git/subversion/libsvn_fs_git/fs_init.h   (with props)
Modified:
    subversion/branches/ra-git/build.conf
    subversion/branches/ra-git/build/generator/gen_win_dependencies.py
    subversion/branches/ra-git/subversion/include/svn_fs.h
    subversion/branches/ra-git/subversion/libsvn_fs/fs-loader.c
    subversion/branches/ra-git/subversion/libsvn_fs/fs-loader.h

Modified: subversion/branches/ra-git/build.conf
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/build.conf?rev=1717253&r1=1717252&r2=1717253&view=diff
==============================================================================
--- subversion/branches/ra-git/build.conf (original)
+++ subversion/branches/ra-git/build.conf Mon Nov 30 14:02:26 2015
@@ -305,6 +305,15 @@ libs = libsvn_delta libsvn_subr aprutil
 msvc-export = ../libsvn_fs_x/fs_init.h
 msvc-delayload = yes
 
+[libsvn_fs_git]
+description = Readonly Subversion Filesystem representation of a git repository
+type = fs-module
+path = subversion/libsvn_fs_git
+install = fsmod-lib
+libs = libsvn_delta libsvn_subr aprutil apriconv apr libgit2 libsvn_fs_util
+msvc-export = ../libsvn_fs_git/fs_init.h
+msvc-delayload = yes
+
 # Low-level grab bag of utilities
 [libsvn_fs_util]
 description = Subversion Filesystem Utility Library
@@ -361,7 +370,7 @@ description = Subversion Git Repository
 type = ra-module
 path = subversion/libsvn_ra_git
 install = ramod-lib
-libs = libsvn_delta libsvn_subr apriconv apr libgit2
+libs = libsvn_delta libsvn_subr apriconv apr libsvn_fs_git libgit2
 msvc-static = yes
 
 # Routines built on top of libsvn_fs
@@ -1512,7 +1521,7 @@ libs = libsvn_ra_serf libsvn_ra_local li
 [fs-libs]
 type = lib
 external-lib = $(SVN_FS_LIB_LINK)
-libs = libsvn_fs_base libsvn_fs_fs libsvn_fs_x
+libs = libsvn_fs_base libsvn_fs_fs libsvn_fs_x libsvn_fs_git
 
 [__ALL__]
 type = project

Modified: subversion/branches/ra-git/build/generator/gen_win_dependencies.py
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/build/generator/gen_win_dependencies.py?rev=1717253&r1=1717252&r2=1717253&view=diff
==============================================================================
--- subversion/branches/ra-git/build/generator/gen_win_dependencies.py (original)
+++ subversion/branches/ra-git/build/generator/gen_win_dependencies.py Mon Nov 30 14:02:26 2015
@@ -1392,10 +1392,13 @@ class GenDependenciesBase(gen_base.Gener
     vermatch = re.search(r'^\s*#define\s+LIBGIT2_VER_MINOR\s+(\d+)', txt, re.M)
     minor = int(vermatch.group(1))
 
-    vermatch = re.search(r'^\s*#define\s+LIBGIT2_VER_PATCH\s+(\d+)', txt, re.M)
-    patch = int(vermatch.group(1))
+    vermatch = re.search(r'^\s*#define\s+LIBGIT2_VER_REVISION\s+(\d+)', txt, re.M)
+    revision = int(vermatch.group(1))
 
-    version = (major, minor, patch)
+    #vermatch = re.search(r'^\s*#define\s+LIBGIT2_VER_PATCH\s+(\d+)', txt, re.M)
+    #patch = int(vermatch.group(1))
+
+    version = (major, minor, revision)
 
     libgit2_version = '.'.join(str(v) for v in version)
 
@@ -1406,8 +1409,11 @@ class GenDependenciesBase(gen_base.Gener
                '.'.join(str(v) for v in minimal_libgit2_version)))
       return
 
+    defines = ['SVN_LIBSVN_FS_LINKS_FS_GIT']
+
     self._libraries['libgit2'] = SVNCommonLibrary('libgit2', inc_dir, lib_dir,
-                                                   lib_name, libgit2_version)
+                                                   lib_name, libgit2_version,
+                                                   defines=defines)
 
   def _find_sqlite(self, show_warnings):
     "Find the Sqlite library and version"

Modified: subversion/branches/ra-git/subversion/include/svn_fs.h
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/include/svn_fs.h?rev=1717253&r1=1717252&r2=1717253&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/include/svn_fs.h (original)
+++ subversion/branches/ra-git/subversion/include/svn_fs.h Mon Nov 30 14:02:26 2015
@@ -87,6 +87,18 @@ typedef struct svn_fs_t svn_fs_t;
  */
 #define SVN_FS_TYPE_FSX                         "fsx"
 
+
+/**
+ * EXPERIMENTAL read-only filesystem backend.
+ *
+ * It is not ready for general production use.  Please consult the
+ * respective release notes on suggested usage scenarios.
+ *
+ * @since New in 1.10.
+ */
+#define SVN_FS_TYPE_GIT                         "git"
+
+
 /** @} */
 
 

Modified: subversion/branches/ra-git/subversion/libsvn_fs/fs-loader.c
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_fs/fs-loader.c?rev=1717253&r1=1717252&r2=1717253&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_fs/fs-loader.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_fs/fs-loader.c Mon Nov 30 14:02:26 2015
@@ -77,6 +77,19 @@ struct fs_type_defn {
   struct fs_type_defn *next;
 };
 
+static struct fs_type_defn git_defn =
+{
+  SVN_FS_TYPE_GIT, "git",
+#ifdef SVN_LIBSVN_FS_LINKS_FS_GIT
+  svn_fs_git__init,
+#else
+  NULL,
+#endif
+  NULL,
+  NULL /* End of static list: this needs to be reset to NULL if the
+          common_pool used when setting it has been cleared. */
+};
+
 static struct fs_type_defn base_defn =
   {
     SVN_FS_TYPE_BDB, "base",
@@ -86,8 +99,7 @@ static struct fs_type_defn base_defn =
     NULL,
 #endif
     NULL,
-    NULL /* End of static list: this needs to be reset to NULL if the
-            common_pool used when setting it has been cleared. */
+    &git_defn
   };
 
 static struct fs_type_defn fsx_defn =
@@ -391,7 +403,7 @@ static svn_error_t *
 synchronized_initialize(void *baton, apr_pool_t *pool)
 {
   common_pool = svn_pool_create(pool);
-  base_defn.next = NULL;
+  git_defn.next = NULL;
   SVN_ERR(svn_mutex__init(&common_pool_lock, TRUE, common_pool));
 
   /* ### This won't work if POOL is NULL and libsvn_fs is loaded as a DSO

Modified: subversion/branches/ra-git/subversion/libsvn_fs/fs-loader.h
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_fs/fs-loader.h?rev=1717253&r1=1717252&r2=1717253&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_fs/fs-loader.h (original)
+++ subversion/branches/ra-git/subversion/libsvn_fs/fs-loader.h Mon Nov 30 14:02:26 2015
@@ -187,6 +187,7 @@ typedef svn_error_t *(*fs_init_func_t)(c
 #include "../libsvn_fs_base/fs_init.h"
 #include "../libsvn_fs_fs/fs_init.h"
 #include "../libsvn_fs_x/fs_init.h"
+#include "../libsvn_fs_git/fs_init.h"
 
 
 

Added: subversion/branches/ra-git/subversion/libsvn_fs_git/fs.c
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_fs_git/fs.c?rev=1717253&view=auto
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_fs_git/fs.c (added)
+++ subversion/branches/ra-git/subversion/libsvn_fs_git/fs.c Mon Nov 30 14:02:26 2015
@@ -0,0 +1,226 @@
+/* fs.c --- creating, opening and closing filesystems
+ *
+ * ====================================================================
+ *    Licensed to the Apache Software Foundation (ASF) under one
+ *    or more contributor license agreements.  See the NOTICE file
+ *    distributed with this work for additional information
+ *    regarding copyright ownership.  The ASF licenses this file
+ *    to you under the Apache License, Version 2.0 (the
+ *    "License"); you may not use this file except in compliance
+ *    with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing,
+ *    software distributed under the License is distributed on an
+ *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *    KIND, either express or implied.  See the License for the
+ *    specific language governing permissions and limitations
+ *    under the License.
+ * ====================================================================
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <apr_general.h>
+#include <apr_pools.h>
+#include <apr_file_io.h>
+
+#include "svn_fs.h"
+#include "svn_delta.h"
+#include "svn_version.h"
+#include "svn_pools.h"
+
+#include "svn_private_config.h"
+
+#include "private/svn_fs_util.h"
+
+#include "../libsvn_fs/fs-loader.h"
+#include "fs_git.h"
+
+static const svn_version_t *
+fs_git_get_version(void)
+{
+  SVN_VERSION_BODY;
+}
+
+static svn_error_t *
+fs_git_create(svn_fs_t *fs,
+              const char *path,
+              svn_mutex__t *common_pool_lock,
+              apr_pool_t *scratch_pool,
+              apr_pool_t *common_pool)
+{
+  return svn_error_create(APR_ENOTIMPL, NULL, NULL);
+}
+
+static svn_error_t *
+fs_git_open_fs(svn_fs_t *fs, const char *path,
+               svn_mutex__t *common_pool_lock,
+               apr_pool_t *scratch_pool,
+               apr_pool_t *common_pool)
+{
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+fs_git_open_fs_for_recovery(svn_fs_t *fs,
+                            const char *path,
+                            svn_mutex__t *common_pool_lock,
+                            apr_pool_t *pool,
+                            apr_pool_t *common_pool)
+{
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+fs_git_upgrade_fs(svn_fs_t *fs,
+                  const char *path,
+                  svn_fs_upgrade_notify_t notify_func,
+                  void *notify_baton,
+                  svn_cancel_func_t cancel_func,
+                  void *cancel_baton,
+                  svn_mutex__t *common_pool_lock,
+                  apr_pool_t *scratch_pool,
+                  apr_pool_t *common_pool)
+{
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+fs_git_verify_fs(svn_fs_t *fs,
+                 const char *path,
+                 svn_revnum_t start,
+                 svn_revnum_t end,
+                 svn_fs_progress_notify_func_t notify_func,
+                 void *notify_baton,
+                 svn_cancel_func_t cancel_func,
+                 void *cancel_baton,
+                 svn_mutex__t *common_pool_lock,
+                 apr_pool_t *pool,
+                 apr_pool_t *common_pool)
+{
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+fs_git_delete_fs(const char *path,
+                 apr_pool_t *pool)
+{
+  return svn_error_create(APR_ENOTIMPL, NULL, NULL);
+}
+
+static svn_error_t *
+fs_git_hotcopy(svn_fs_t *src_fs,
+               svn_fs_t *dst_fs,
+               const char *src_path,
+               const char *dst_path,
+               svn_boolean_t clean,
+               svn_boolean_t incremental,
+               svn_fs_hotcopy_notify_t notify_func,
+               void *notify_baton,
+               svn_cancel_func_t cancel_func,
+               void *cancel_baton,
+               svn_mutex__t *common_pool_lock,
+               apr_pool_t *pool,
+               apr_pool_t *common_pool)
+{
+  return svn_error_create(APR_ENOTIMPL, NULL, NULL);
+}
+
+static const char *
+fs_git_get_description(void)
+{
+  return _("Experimental module for reading a GIT repository.");
+}
+
+static svn_error_t *
+fs_git_recover(svn_fs_t *fs,
+               svn_cancel_func_t cancel_func, void *cancel_baton,
+               apr_pool_t *pool)
+{
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+fs_git_pack_fs(svn_fs_t *fs,
+               const char *path,
+               svn_fs_pack_notify_t notify_func,
+               void *notify_baton,
+               svn_cancel_func_t cancel_func,
+               void *cancel_baton,
+               svn_mutex__t *common_pool_lock,
+               apr_pool_t *pool,
+               apr_pool_t *common_pool)
+{
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+fs_git_logfiles(apr_array_header_t **logfiles,
+                const char *path,
+                svn_boolean_t only_unused,
+                apr_pool_t *pool)
+{
+  /* A no-op for GIT. */
+  *logfiles = apr_array_make(pool, 0, sizeof(const char *));
+
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+fs_git_set_svn_fs_open(svn_fs_t *fs,
+                       svn_error_t *(*svn_fs_open_)(svn_fs_t **,
+                                                    const char *,
+                                                    apr_hash_t *,
+                                                    apr_pool_t *,
+                                                    apr_pool_t *))
+{
+  return SVN_NO_ERROR;
+}
+
+static fs_library_vtable_t library_vtable =
+{
+  fs_git_get_version,
+  fs_git_create,
+  fs_git_open_fs,
+  fs_git_open_fs_for_recovery,
+  fs_git_upgrade_fs,
+  fs_git_verify_fs,
+  fs_git_delete_fs,
+  fs_git_hotcopy,
+  fs_git_get_description,
+  fs_git_recover,
+  fs_git_pack_fs,
+  fs_git_logfiles,
+  NULL /* parse_id */,
+  fs_git_set_svn_fs_open,
+  NULL /* info_fsap_dup */
+};
+
+svn_error_t *
+svn_fs_git__init(const svn_version_t *loader_version,
+                 fs_library_vtable_t **vtable,
+                 apr_pool_t* common_pool)
+{
+  static const svn_version_checklist_t checklist[] =
+  {
+    { "svn_subr",  svn_subr_version },
+    { "svn_delta", svn_delta_version },
+    { "svn_fs_util", svn_fs_util__version },
+    { NULL, NULL }
+  };
+
+  /* Simplified version check to make sure we can safely use the
+  VTABLE parameter. The FS loader does a more exhaustive check. */
+  if (loader_version->major != SVN_VER_MAJOR)
+    return svn_error_createf(SVN_ERR_VERSION_MISMATCH, NULL,
+                             _("Unsupported FS loader version (%d) for fsx"),
+                             loader_version->major);
+  SVN_ERR(svn_ver_check_list2(fs_git_get_version(), checklist, svn_ver_equal));
+
+  *vtable = &library_vtable;
+  return SVN_NO_ERROR;
+}

Propchange: subversion/branches/ra-git/subversion/libsvn_fs_git/fs.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: subversion/branches/ra-git/subversion/libsvn_fs_git/fs_git.h
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_fs_git/fs_git.h?rev=1717253&view=auto
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_fs_git/fs_git.h (added)
+++ subversion/branches/ra-git/subversion/libsvn_fs_git/fs_git.h Mon Nov 30 14:02:26 2015
@@ -0,0 +1,28 @@
+/* fs_git.h : interface to Subversion filesystem, private to libsvn_fs_git
+*
+* ====================================================================
+*    Licensed to the Apache Software Foundation (ASF) under one
+*    or more contributor license agreements.  See the NOTICE file
+*    distributed with this work for additional information
+*    regarding copyright ownership.  The ASF licenses this file
+*    to you under the Apache License, Version 2.0 (the
+*    "License"); you may not use this file except in compliance
+*    with the License.  You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+*    Unless required by applicable law or agreed to in writing,
+*    software distributed under the License is distributed on an
+*    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+*    KIND, either express or implied.  See the License for the
+*    specific language governing permissions and limitations
+*    under the License.
+* ====================================================================
+*/
+
+#ifndef SVN_LIBSVN_FS__FS_GIT_H
+#define SVN_LIBSVN_FS__FS_GIT_H
+
+
+
+#endif

Propchange: subversion/branches/ra-git/subversion/libsvn_fs_git/fs_git.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: subversion/branches/ra-git/subversion/libsvn_fs_git/fs_init.h
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_fs_git/fs_init.h?rev=1717253&view=auto
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_fs_git/fs_init.h (added)
+++ subversion/branches/ra-git/subversion/libsvn_fs_git/fs_init.h Mon Nov 30 14:02:26 2015
@@ -0,0 +1,33 @@
+/*
+* libsvn_fs_fs/fs_init.h:  Exported function of libsvn_fs_fs
+*
+* ====================================================================
+*    Licensed to the Apache Software Foundation (ASF) under one
+*    or more contributor license agreements.  See the NOTICE file
+*    distributed with this work for additional information
+*    regarding copyright ownership.  The ASF licenses this file
+*    to you under the Apache License, Version 2.0 (the
+*    "License"); you may not use this file except in compliance
+*    with the License.  You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+*    Unless required by applicable law or agreed to in writing,
+*    software distributed under the License is distributed on an
+*    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+*    KIND, either express or implied.  See the License for the
+*    specific language governing permissions and limitations
+*    under the License.
+* ====================================================================
+*/
+
+#ifndef LIBSVN_FS_LOADER_H
+#error Please include libsvn_fs/fs_loader.h instead of this file
+#else
+
+svn_error_t *
+svn_fs_git__init(const svn_version_t *loader_version,
+                 fs_library_vtable_t **vtable,
+                 apr_pool_t* common_pool);
+
+#endif

Propchange: subversion/branches/ra-git/subversion/libsvn_fs_git/fs_init.h
------------------------------------------------------------------------------
    svn:eol-style = native



Re: svn commit: r1717253 - in /subversion/branches/ra-git: ./ build/generator/ subversion/include/ subversion/libsvn_fs/ subversion/libsvn_fs_git/

Posted by Stefan Sperling <st...@elego.de>.
On Mon, Nov 30, 2015 at 02:02:26PM -0000, rhuijben@apache.org wrote:
> Author: rhuijben
> Date: Mon Nov 30 14:02:26 2015
> New Revision: 1717253
> 
> URL: http://svn.apache.org/viewvc?rev=1717253&view=rev
> Log:
> On the ra-git branch: To avoid having to reimplement quite a bit of the repos
> layer code to support a git backend (as the branch currently does), start
> moving a bit of git code to the fs layer so the existing repos layer code
> can be used to access git state.
> 
> For this experiment I try to build a readonly git filesystem to just support
> libsvn_ra_git's access to read the repository.
> 
> As a side effect this filesystem may support other code like 'svnadmin dump',
> to work on this level as this happens to have the same requirements. It might
> also make it easy to publish git repositories on a Subversion compatible url.
> 
> The backend for this filesystem will be a git repository
> (accessed by libgit2) and an sqlite database containing some mapping
> information.
> 
> The short term goal is to support svn:externals pointing to a git repository,
> like the current branch does.

Awesome :-)