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:54:22 UTC
svn commit: r1717266 - in /subversion/branches/ra-git: build.conf
subversion/libsvn_fs_git/fs.c subversion/libsvn_fs_git/fs_git.h
subversion/libsvn_fs_git/git-fs.c subversion/libsvn_fs_git/git-lib.c
Author: rhuijben
Date: Mon Nov 30 14:54:22 2015
New Revision: 1717266
URL: http://svn.apache.org/viewvc?rev=1717266&view=rev
Log:
On the ra-git branch: Following up on r1717253, start moving some more
plumbing into place to use libgit2 from libsvn_fs_git.
* build.conf
(libgit2): Use winhttp.lib dependency as that is required by newer libgit2
versions on Windows.
* subversion/libsvn_fs_git/fs.c
Rename file to git-lib.c
* subversion/libsvn_fs_git/fs_git.h
(svn_fs_git_fs_t): New struct.
* subversion/libsvn_fs_git/git-fs.c
New file.
* subversion/libsvn_fs_git/git-lib.c
Renamed from fs.c.
(includes): Add git2.h and private/svn_atomic.h.
(fs_git_create,
fs_git_open_fs,
fs_git_open_fs_for_recovery): Add basic implementation by forwarding to
new methods.
(fs_git_upgrade_fs,
fs_git_verify_fs,
fs_git_hotcopy,
fs_git_recover,
fs_git_pack_fs): Add some basic argument validation.
(fs_git_set_svn_fs_open): Store pointer.
(initialize_libgit2): New function.
(svn_fs_git__init): Call initialize_libgit2.
Added:
subversion/branches/ra-git/subversion/libsvn_fs_git/git-fs.c (with props)
subversion/branches/ra-git/subversion/libsvn_fs_git/git-lib.c
- copied, changed from r1717265, subversion/branches/ra-git/subversion/libsvn_fs_git/fs.c
Removed:
subversion/branches/ra-git/subversion/libsvn_fs_git/fs.c
Modified:
subversion/branches/ra-git/build.conf
subversion/branches/ra-git/subversion/libsvn_fs_git/fs_git.h
Modified: subversion/branches/ra-git/build.conf
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/build.conf?rev=1717266&r1=1717265&r2=1717266&view=diff
==============================================================================
--- subversion/branches/ra-git/build.conf (original)
+++ subversion/branches/ra-git/build.conf Mon Nov 30 14:54:22 2015
@@ -1488,6 +1488,7 @@ pkg-config-private = yes
[libgit2]
type = lib
external-lib = $(SVN_LIBGIT2_LIBS)
+msvc-libs = winhttp.lib
[xml]
type = lib
Modified: 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=1717266&r1=1717265&r2=1717266&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_fs_git/fs_git.h (original)
+++ subversion/branches/ra-git/subversion/libsvn_fs_git/fs_git.h Mon Nov 30 14:54:22 2015
@@ -23,6 +23,30 @@
#ifndef SVN_LIBSVN_FS__FS_GIT_H
#define SVN_LIBSVN_FS__FS_GIT_H
+typedef struct svn_fs_git_fs_t
+{
+
+ svn_error_t *(*svn_fs_open)(svn_fs_t **,
+ const char *,
+ apr_hash_t *,
+ apr_pool_t *,
+ apr_pool_t *);
+
+} svn_fs_git_fs_t;
+
+svn_error_t *
+svn_fs_git__initialize_fs_struct(svn_fs_t *fs,
+ apr_pool_t *scratch_pool);
+
+svn_error_t *
+svn_fs_git__create(svn_fs_t *fs,
+ const char *path,
+ apr_pool_t *scratch_pool);
+
+svn_error_t *
+svn_fs_git__open(svn_fs_t *fs,
+ const char *path,
+ apr_pool_t *scratch_pool);
#endif
Added: subversion/branches/ra-git/subversion/libsvn_fs_git/git-fs.c
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_fs_git/git-fs.c?rev=1717266&view=auto
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_fs_git/git-fs.c (added)
+++ subversion/branches/ra-git/subversion/libsvn_fs_git/git-fs.c Mon Nov 30 14:54:22 2015
@@ -0,0 +1,233 @@
+/* git-fs.c --- the git filesystem
+ *
+ * ====================================================================
+ * 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 svn_error_t *
+fs_git_youngest_rev(svn_revnum_t *youngest_p, svn_fs_t *fs, apr_pool_t *pool)
+{
+ return svn_error_create(APR_ENOTIMPL, NULL, NULL);
+}
+
+static svn_error_t *
+fs_git_refresh_revprops(svn_fs_t *fs, apr_pool_t *scratch_pool)
+{
+ return svn_error_create(APR_ENOTIMPL, NULL, NULL);
+}
+
+static svn_error_t *
+fs_git_revision_prop(svn_string_t **value_p, svn_fs_t *fs, svn_revnum_t rev, const char *propname, svn_boolean_t refresh, apr_pool_t *result_pool, apr_pool_t *scratch_pool)
+{
+ return svn_error_create(APR_ENOTIMPL, NULL, NULL);
+}
+
+static svn_error_t *
+fs_git_revision_proplist(apr_hash_t **table_p, svn_fs_t *fs, svn_revnum_t rev, svn_boolean_t refresh, apr_pool_t *result_pool, apr_pool_t *scratch_pool)
+{
+ return svn_error_create(APR_ENOTIMPL, NULL, NULL);
+}
+
+static svn_error_t *fs_git_change_rev_prop(svn_fs_t *fs, svn_revnum_t rev, const char *name, const svn_string_t *const *old_value_p, const svn_string_t *value, apr_pool_t *pool)
+{
+ return svn_error_create(APR_ENOTIMPL, NULL, NULL);
+}
+
+static svn_error_t *
+fs_git_set_uuid(svn_fs_t *fs, const char *uuid, apr_pool_t *pool)
+{
+ return svn_error_create(APR_ENOTIMPL, NULL, NULL);
+}
+
+static svn_error_t *
+fs_git_revision_root(svn_fs_root_t **root_p, svn_fs_t *fs, svn_revnum_t rev, apr_pool_t *pool)
+{
+ return svn_error_create(APR_ENOTIMPL, NULL, NULL);
+}
+
+static svn_error_t *
+fs_git_begin_txn(svn_fs_txn_t **txn_p, svn_fs_t *fs, svn_revnum_t rev, apr_uint32_t flags, apr_pool_t *pool)
+{
+ return svn_error_create(APR_ENOTIMPL, NULL, NULL);
+}
+
+static svn_error_t *
+fs_git_open_txn(svn_fs_txn_t **txn, svn_fs_t *fs, const char *name, apr_pool_t *pool)
+{
+ return svn_error_create(APR_ENOTIMPL, NULL, NULL);
+}
+
+static svn_error_t *
+fs_git_purge_txn(svn_fs_t *fs, const char *txn_id, apr_pool_t *pool)
+{
+ return svn_error_create(APR_ENOTIMPL, NULL, NULL);
+}
+
+static svn_error_t *
+fs_git_list_transactions(apr_array_header_t **names_p, svn_fs_t *fs, apr_pool_t *pool)
+{
+ return svn_error_create(APR_ENOTIMPL, NULL, NULL);
+}
+
+static svn_error_t *
+fs_git_deltify(svn_fs_t *fs, svn_revnum_t rev, apr_pool_t *pool)
+{
+ return svn_error_create(APR_ENOTIMPL, NULL, NULL);
+}
+
+static svn_error_t *
+fs_git_lock(svn_fs_t *fs, apr_hash_t *targets, const char *comment, svn_boolean_t is_dav_comment, apr_time_t expiration_date, svn_boolean_t steal_lock, svn_fs_lock_callback_t lock_callback, void *lock_baton, apr_pool_t *result_pool, apr_pool_t *scratch_pool)
+{
+ return svn_error_create(APR_ENOTIMPL, NULL, NULL);
+}
+
+static svn_error_t *
+fs_git_generate_lock_token(const char **token, svn_fs_t *fs, apr_pool_t *pool)
+{
+ return svn_error_create(APR_ENOTIMPL, NULL, NULL);
+}
+
+static svn_error_t *
+fs_git_unlock(svn_fs_t *fs, apr_hash_t *targets, svn_boolean_t break_lock, svn_fs_lock_callback_t lock_callback, void *lock_baton, apr_pool_t *result_pool, apr_pool_t *scratch_pool)
+{
+ return svn_error_create(APR_ENOTIMPL, NULL, NULL);
+}
+
+static svn_error_t *
+fs_git_get_lock(svn_lock_t **lock, svn_fs_t *fs, const char *path, apr_pool_t *pool)
+{
+ return svn_error_create(APR_ENOTIMPL, NULL, NULL);
+}
+
+static svn_error_t *
+fs_git_get_locks(svn_fs_t *fs, const char *path, svn_depth_t depth, svn_fs_get_locks_callback_t get_locks_func, void *get_locks_baton, apr_pool_t *pool)
+{
+ return svn_error_create(APR_ENOTIMPL, NULL, NULL);
+}
+
+static svn_error_t *
+fs_git_info_format(int *fs_format, svn_version_t **supports_version, svn_fs_t *fs, apr_pool_t *result_pool, apr_pool_t *scratch_pool)
+{
+ return svn_error_create(APR_ENOTIMPL, NULL, NULL);
+}
+
+static svn_error_t *
+fs_git_info_config_files(apr_array_header_t **files, svn_fs_t *fs, apr_pool_t *result_pool, apr_pool_t *scratch_pool)
+{
+ return svn_error_create(APR_ENOTIMPL, NULL, NULL);
+}
+
+static svn_error_t *
+fs_git_info_fsap(const void **fsap_info, svn_fs_t *fs, apr_pool_t *result_pool, apr_pool_t *scratch_pool)
+{
+ return svn_error_create(APR_ENOTIMPL, NULL, NULL);
+}
+
+static svn_error_t *
+fs_git_verify_root(svn_fs_root_t *root, apr_pool_t *pool)
+{
+ return svn_error_create(APR_ENOTIMPL, NULL, NULL);
+}
+
+static svn_error_t *
+fs_git_freeze(svn_fs_t *fs, svn_fs_freeze_func_t freeze_func, void *freeze_baton, apr_pool_t *pool)
+{
+ return svn_error_create(APR_ENOTIMPL, NULL, NULL);
+}
+
+static svn_error_t *
+fs_git_bdb_set_errcall(svn_fs_t *fs, void(*handler)(const char *errpfx, char *msg))
+{
+ return SVN_NO_ERROR;
+}
+
+static fs_vtable_t fs_vtable =
+{
+ fs_git_youngest_rev,
+ fs_git_refresh_revprops,
+ fs_git_revision_prop,
+ fs_git_revision_proplist,
+ fs_git_change_rev_prop,
+ fs_git_set_uuid,
+ fs_git_revision_root,
+ fs_git_begin_txn,
+ fs_git_open_txn,
+ fs_git_purge_txn,
+ fs_git_list_transactions,
+ fs_git_deltify,
+ fs_git_lock,
+ fs_git_generate_lock_token,
+ fs_git_unlock,
+ fs_git_get_lock,
+ fs_git_get_locks,
+ fs_git_info_format,
+ fs_git_info_config_files,
+ fs_git_info_fsap,
+ fs_git_verify_root,
+ fs_git_freeze,
+ fs_git_bdb_set_errcall
+};
+
+svn_error_t *
+svn_fs_git__initialize_fs_struct(svn_fs_t *fs,
+ apr_pool_t *scratch_pool)
+{
+ svn_fs_git_fs_t *fgf = apr_pcalloc(fs->pool, sizeof(*fgf));
+
+ fs->vtable = &fs_vtable;
+ fs->fsap_data = fgf;
+ return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_fs_git__create(svn_fs_t *fs,
+ const char *path,
+ apr_pool_t *scratch_pool)
+{
+ return svn_error_create(APR_ENOTIMPL, NULL, NULL);
+}
+
+svn_error_t *
+svn_fs_git__open(svn_fs_t *fs,
+ const char *path,
+ apr_pool_t *scratch_pool)
+{
+ return svn_error_create(APR_ENOTIMPL, NULL, NULL);
+}
Propchange: subversion/branches/ra-git/subversion/libsvn_fs_git/git-fs.c
------------------------------------------------------------------------------
svn:eol-style = native
Copied: subversion/branches/ra-git/subversion/libsvn_fs_git/git-lib.c (from r1717265, subversion/branches/ra-git/subversion/libsvn_fs_git/fs.c)
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_fs_git/git-lib.c?p2=subversion/branches/ra-git/subversion/libsvn_fs_git/git-lib.c&p1=subversion/branches/ra-git/subversion/libsvn_fs_git/fs.c&r1=1717265&r2=1717266&rev=1717266&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_fs_git/fs.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_fs_git/git-lib.c Mon Nov 30 14:54:22 2015
@@ -1,4 +1,4 @@
-/* fs.c --- creating, opening and closing filesystems
+/* git-lib.c --- fs library level operations
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
@@ -28,6 +28,8 @@
#include <apr_pools.h>
#include <apr_file_io.h>
+#include <git2.h>
+
#include "svn_fs.h"
#include "svn_delta.h"
#include "svn_version.h"
@@ -35,6 +37,7 @@
#include "svn_private_config.h"
+#include "private/svn_atomic.h"
#include "private/svn_fs_util.h"
#include "../libsvn_fs/fs-loader.h"
@@ -53,15 +56,28 @@ fs_git_create(svn_fs_t *fs,
apr_pool_t *scratch_pool,
apr_pool_t *common_pool)
{
- return svn_error_create(APR_ENOTIMPL, NULL, NULL);
+ SVN_ERR(svn_fs__check_fs(fs, FALSE));
+
+ SVN_ERR(svn_fs_git__initialize_fs_struct(fs, scratch_pool));
+
+ SVN_ERR(svn_fs_git__create(fs, path, scratch_pool));
+
+ return SVN_NO_ERROR;
}
static svn_error_t *
-fs_git_open_fs(svn_fs_t *fs, const char *path,
+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)
{
+ SVN_ERR(svn_fs__check_fs(fs, FALSE));
+
+ SVN_ERR(svn_fs_git__initialize_fs_struct(fs, scratch_pool));
+
+ SVN_ERR(svn_fs_git__open(fs, path, scratch_pool));
+
return SVN_NO_ERROR;
}
@@ -72,6 +88,16 @@ fs_git_open_fs_for_recovery(svn_fs_t *fs
apr_pool_t *pool,
apr_pool_t *common_pool)
{
+ apr_pool_t * subpool = svn_pool_create(pool);
+
+ SVN_ERR(svn_fs__check_fs(fs, FALSE));
+
+ SVN_ERR(svn_fs_git__initialize_fs_struct(fs, subpool));
+
+ SVN_ERR(svn_fs_git__open(fs, path, subpool));
+
+ svn_pool_destroy(subpool);
+
return SVN_NO_ERROR;
}
@@ -86,6 +112,8 @@ fs_git_upgrade_fs(svn_fs_t *fs,
apr_pool_t *scratch_pool,
apr_pool_t *common_pool)
{
+ SVN_ERR(svn_fs__check_fs(fs, TRUE));
+
return SVN_NO_ERROR;
}
@@ -102,6 +130,8 @@ fs_git_verify_fs(svn_fs_t *fs,
apr_pool_t *pool,
apr_pool_t *common_pool)
{
+ SVN_ERR(svn_fs__check_fs(fs, TRUE));
+
return SVN_NO_ERROR;
}
@@ -127,6 +157,9 @@ fs_git_hotcopy(svn_fs_t *src_fs,
apr_pool_t *pool,
apr_pool_t *common_pool)
{
+ SVN_ERR(svn_fs__check_fs(src_fs, TRUE));
+ SVN_ERR(svn_fs__check_fs(dst_fs, TRUE));
+
return svn_error_create(APR_ENOTIMPL, NULL, NULL);
}
@@ -141,6 +174,8 @@ fs_git_recover(svn_fs_t *fs,
svn_cancel_func_t cancel_func, void *cancel_baton,
apr_pool_t *pool)
{
+ SVN_ERR(svn_fs__check_fs(fs, TRUE));
+
return SVN_NO_ERROR;
}
@@ -155,6 +190,8 @@ fs_git_pack_fs(svn_fs_t *fs,
apr_pool_t *pool,
apr_pool_t *common_pool)
{
+ SVN_ERR(svn_fs__check_fs(fs, TRUE));
+
return SVN_NO_ERROR;
}
@@ -178,6 +215,11 @@ fs_git_set_svn_fs_open(svn_fs_t *fs,
apr_pool_t *,
apr_pool_t *))
{
+ svn_fs_git_fs_t *fgf = fs->fsap_data;
+ SVN_ERR(svn_fs__check_fs(fs, TRUE));
+
+ fgf->svn_fs_open = svn_fs_open_;
+
return SVN_NO_ERROR;
}
@@ -200,6 +242,17 @@ static fs_library_vtable_t library_vtabl
NULL /* info_fsap_dup */
};
+static volatile svn_atomic_t libgit2_init_state = 0;
+
+static svn_error_t *
+initialize_libgit2(void *baton,
+ apr_pool_t *pool)
+{
+ git_libgit2_init();
+
+ return SVN_NO_ERROR;
+}
+
svn_error_t *
svn_fs_git__init(const svn_version_t *loader_version,
fs_library_vtable_t **vtable,
@@ -221,6 +274,9 @@ svn_fs_git__init(const svn_version_t *lo
loader_version->major);
SVN_ERR(svn_ver_check_list2(fs_git_get_version(), checklist, svn_ver_equal));
+ SVN_ERR(svn_atomic__init_once(&libgit2_init_state, initialize_libgit2, NULL,
+ common_pool));
+
*vtable = &library_vtable;
return SVN_NO_ERROR;
}