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/12/02 09:40:23 UTC

svn commit: r1717585 - in /subversion/branches/ra-git/subversion/libsvn_fs_git: fs_git.h fsgit-metadata.sql fsgit-queries.sql git-fs.c gitdb.c

Author: rhuijben
Date: Wed Dec  2 08:40:23 2015
New Revision: 1717585

URL: http://svn.apache.org/viewvc?rev=1717585&view=rev
Log:
On the ra-git branch: Allow changing the uuid to an explicit value in the git
filesystem and improve some error reporting.

* subversion/libsvn_fs_git/fsgit-metadata.sql
  (REPOSITORY): Make sure there is just 1 record.

* subversion/libsvn_fs_git/fsgit-queries.sql
  (STMT_INSERT_UUID): Allow overwriting.

* subversion/libsvn_fs_git/fs_git.h
  (svn_fs_git__read_only_error): New macro.
  (svn_fs_git__db_set_uuid): New function.

* subversion/libsvn_fs_git/git-fs.c
  (fs_git_youngest_rev,
   fs_git_refresh_revprops): Verify argument.
  (fs_git_revision_prop): Implement via fs_git_revision_proplist.
  (fs_git_change_rev_prop): Return new error.
  (fs_git_set_uuid): Implement.
  (fs_git_begin_txn,
   fs_git_open_txn,
   fs_git_purge_txn): Return less generic error.
  (fs_git_deltify): Implement as no-op.
  (fs_git_lock): Return less generic error.
  (fs_git_generate_lock_token): Return static token.
  (fs_git_unlock): Return less generic error.
  (fs_git_info_format): Verify fs pointer.
  (fs_git_verify_root): Return success.
  (fs_git_freeze): Return error.
  (fs_vtable): Mark const.


* subversion/libsvn_fs_git/gitdb.c

Modified:
    subversion/branches/ra-git/subversion/libsvn_fs_git/fs_git.h
    subversion/branches/ra-git/subversion/libsvn_fs_git/fsgit-metadata.sql
    subversion/branches/ra-git/subversion/libsvn_fs_git/fsgit-queries.sql
    subversion/branches/ra-git/subversion/libsvn_fs_git/git-fs.c
    subversion/branches/ra-git/subversion/libsvn_fs_git/gitdb.c

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=1717585&r1=1717584&r2=1717585&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 Wed Dec  2 08:40:23 2015
@@ -32,6 +32,11 @@ svn_fs_git__wrap_git_error(void);
 #define svn_fs_git__wrap_git_error() \
           svn_error_trace(svn_fs_git__wrap_git_error())
 
+#define svn_fs_git__read_only_error()                                         \
+          svn_error_create(SVN_ERR_FS_REP_NOT_MUTABLE, NULL,                  \
+                           _("The Subversion git filesystem doesn't support " \
+                             "write operations"))
+
 #define GIT2_ERR(expr)                        \
   do {                                        \
     int svn_err__git_temp = (expr);           \
@@ -124,6 +129,11 @@ svn_fs_git__db_fetch_checksum(svn_checks
                               apr_pool_t *result_pool,
                               apr_pool_t *scratch_pool);
 
+svn_error_t *
+svn_fs_git__db_set_uuid(svn_fs_t *fs,
+                        const char *uuid,
+                        apr_pool_t *scratch_pool);
+
 /* */
 svn_error_t *
 svn_fs_git__revision_root(svn_fs_root_t **root_p,

Modified: subversion/branches/ra-git/subversion/libsvn_fs_git/fsgit-metadata.sql
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_fs_git/fsgit-metadata.sql?rev=1717585&r1=1717584&r2=1717585&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_fs_git/fsgit-metadata.sql (original)
+++ subversion/branches/ra-git/subversion/libsvn_fs_git/fsgit-metadata.sql Wed Dec  2 08:40:23 2015
@@ -25,7 +25,7 @@
 -- STMT_CREATE_SCHEMA
 
 CREATE TABLE REPOSITORY (
-  id INTEGER PRIMARY KEY AUTOINCREMENT,
+  id INTEGER PRIMARY KEY AUTOINCREMENT CHECK(id=1),
 
   /* the UUID of the repository */
   uuid  TEXT NOT NULL

Modified: subversion/branches/ra-git/subversion/libsvn_fs_git/fsgit-queries.sql
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_fs_git/fsgit-queries.sql?rev=1717585&r1=1717584&r2=1717585&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_fs_git/fsgit-queries.sql (original)
+++ subversion/branches/ra-git/subversion/libsvn_fs_git/fsgit-queries.sql Wed Dec  2 08:40:23 2015
@@ -29,8 +29,9 @@
 -- STMT_SELECT_UUID
 SELECT uuid from REPOSITORY
 
+/* Use fixed id, to support overwriting */
 -- STMT_INSERT_UUID
-INSERT INTO REPOSITORY(uuid) VALUES (?1)
+INSERT OR REPLACE INTO REPOSITORY(id, uuid) VALUES (1, ?1)
 
 -- STMT_SELECT_HEADREV
 SELECT MAX(

Modified: 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=1717585&r1=1717584&r2=1717585&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_fs_git/git-fs.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_fs_git/git-fs.c Wed Dec  2 08:40:23 2015
@@ -44,6 +44,8 @@
 static svn_error_t *
 fs_git_youngest_rev(svn_revnum_t *youngest_p, svn_fs_t *fs, apr_pool_t *pool)
 {
+  SVN_ERR(svn_fs__check_fs(fs, TRUE));
+
   SVN_ERR(svn_fs_git__db_youngest_rev(youngest_p, fs, pool));
 
   return SVN_NO_ERROR;
@@ -52,13 +54,9 @@ fs_git_youngest_rev(svn_revnum_t *younge
 static svn_error_t *
 fs_git_refresh_revprops(svn_fs_t *fs, apr_pool_t *scratch_pool)
 {
-  return SVN_NO_ERROR;
-}
+  SVN_ERR(svn_fs__check_fs(fs, TRUE));
 
-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);
+  return SVN_NO_ERROR;
 }
 
 static svn_error_t *
@@ -104,63 +102,89 @@ fs_git_revision_proplist(apr_hash_t **ta
   return SVN_NO_ERROR;
 }
 
+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)
+{
+  apr_hash_t *props;
+  svn_string_t *value;
+  SVN_ERR(svn_fs__check_fs(fs, TRUE));
+
+  SVN_ERR(fs_git_revision_proplist(&props, fs, rev, refresh, scratch_pool, scratch_pool));
+
+  value = svn_hash_gets(props, propname);
+  if (value)
+    *value_p = svn_string_dup(value, result_pool);
+  else
+    *value_p = NULL;
+
+  return SVN_NO_ERROR;
+}
+
+
 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);
+  return svn_fs_git__read_only_error();
 }
 
 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);
+  SVN_ERR(svn_fs__check_fs(fs, TRUE));
+
+  SVN_ERR(svn_fs_git_db_set_uuid(fs, uuid, pool));
+
+  return SVN_NO_ERROR;
 }
 
 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);
+  return svn_fs_git__read_only_error();
 }
 
 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);
+  return svn_fs_git__read_only_error();
 }
 
 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);
+  return svn_fs_git__read_only_error();
 }
 
 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);
+  *names_p = apr_array_make(pool, 0, sizeof(void*));
+
+  return SVN_NO_ERROR;
 }
 
 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);
+  return SVN_NO_ERROR;
 }
 
 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);
+  return svn_fs_git__read_only_error();
 }
 
 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);
+  *token = "static-token";
+  return SVN_NO_ERROR;
 }
 
 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);
+  return svn_fs_git__read_only_error();
 }
 
 static svn_error_t *
@@ -180,6 +204,9 @@ 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)
 {
   svn_fs_git_fs_t *fgf = fs->fsap_data;
+
+  SVN_ERR(svn_fs__check_fs(fs, TRUE));
+
   *fs_format = 0;
 
   SVN_ERR(svn_sqlite__read_schema_version(fs_format, fgf->sdb, scratch_pool));
@@ -215,13 +242,13 @@ fs_git_info_fsap(const void **fsap_info,
 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);
+  return SVN_NO_ERROR;
 }
 
 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);
+  return svn_fs_git__read_only_error();
 }
 
 static svn_error_t *
@@ -230,7 +257,7 @@ fs_git_bdb_set_errcall(svn_fs_t *fs, voi
   return SVN_NO_ERROR;
 }
 
-static fs_vtable_t fs_vtable =
+static const fs_vtable_t fs_vtable =
 {
   fs_git_youngest_rev,
   fs_git_refresh_revprops,

Modified: subversion/branches/ra-git/subversion/libsvn_fs_git/gitdb.c
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_fs_git/gitdb.c?rev=1717585&r1=1717584&r2=1717585&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_fs_git/gitdb.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_fs_git/gitdb.c Wed Dec  2 08:40:23 2015
@@ -258,7 +258,6 @@ svn_fs_git__db_fetch_checksum(svn_checks
   return SVN_NO_ERROR;
 }
 
-
 svn_error_t *
 svn_fs_git__db_open(svn_fs_t *fs,
                     apr_pool_t *scratch_pool)
@@ -281,24 +280,34 @@ svn_fs_git__db_open(svn_fs_t *fs,
   return SVN_NO_ERROR;
 }
 
+svn_error_t *
+svn_fs_git__db_set_uuid(svn_fs_t *fs,
+                        const char *uuid,
+                        apr_pool_t *scratch_pool)
+{
+  svn_fs_git_fs_t *fgf = fs->fsap_data;
+  svn_sqlite__stmt_t *stmt;
+
+  SVN_ERR(svn_sqlite__get_statement(&stmt, fgf->sdb, STMT_INSERT_UUID));
+  SVN_ERR(svn_sqlite__bind_text(stmt, 1, uuid));
+  SVN_ERR(svn_sqlite__update(NULL, stmt));
+
+  fs->uuid = apr_pstrdup(fs->pool, uuid);
+  return SVN_NO_ERROR;
+}
+
+
 static svn_error_t *
 create_schema(svn_fs_t *fs,
               apr_pool_t *scratch_pool)
 {
   svn_fs_git_fs_t *fgf = fs->fsap_data;
-  svn_sqlite__stmt_t *stmt;
-  const char *uuid;
 
   SVN_ERR(svn_sqlite__exec_statements(fgf->sdb,
                                       STMT_CREATE_SCHEMA));
 
-  uuid = svn_uuid_generate(fs->pool);
-
-  SVN_ERR(svn_sqlite__get_statement(&stmt, fgf->sdb, STMT_INSERT_UUID));
-  SVN_ERR(svn_sqlite__bind_text(stmt, 1, uuid));
-  SVN_ERR(svn_sqlite__update(NULL, stmt));
-
-  fs->uuid = uuid;
+  SVN_ERR(svn_fs_git__db_set_uuid(fs, svn_uuid_generate(scratch_pool),
+                                  scratch_pool));
 
   return SVN_NO_ERROR;
 }