subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhuij...@apache.org
Subject svn commit: r1717378 - in /subversion/branches/ra-git/subversion/libsvn_fs_git: fs_git.h fsgit-queries.sql git-fs.c git-revroot.c gitdb.c revmap.c
Date Tue, 01 Dec 2015 05:34:07 GMT
Author: rhuijben
Date: Tue Dec  1 05:34:07 2015
New Revision: 1717378

URL: http://svn.apache.org/viewvc?rev=1717378&view=rev
Log:
On the git-ra branch: Start mapping the revisions to several operations.

* subversion/libsvn_fs_git/fsgit-queries.sql
  (STMT_SELECT_COMMIT_BY_REV): New statement.

* subversion/libsvn_fs_git/fs_git.h
  (svn_fs_git__db_fetch_oid): New function.

* subversion/libsvn_fs_git/git-fs.c
  (includes): Add svn_hash.h, svn_time.h.
  (fs_git_revision_proplist): Implement function.
  (fs_git_get_lock,
   fs_git_get_locks): Return no locks instead of an error.

* subversion/libsvn_fs_git/git-revroot.c
  (includes): Add svn_hash.h.
  (svn_fs_git_root_t): New struct.
  (git_root_cleanup,
   make_id): New function.
  (fs_git_check_path): Handle '/'.
  (fs_git_node_created_rev): Handle '/'. Fake others.
  (fs_git_node_has_props): No props yet.
  (fs_git_dir_entries): Fake '/'.
  (svn_fs_git__revision_root): Fetch the commit describing the
    revision.

* subversion/libsvn_fs_git/gitdb.c
  (svn_fs_git__db_fetch_oid): New function.

* subversion/libsvn_fs_git/revmap.c
  (revmap_update_branch): Add cancel support.
  (revmap_update): Use r1 for setting up layout.

Modified:
    subversion/branches/ra-git/subversion/libsvn_fs_git/fs_git.h
    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/git-revroot.c
    subversion/branches/ra-git/subversion/libsvn_fs_git/gitdb.c
    subversion/branches/ra-git/subversion/libsvn_fs_git/revmap.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=1717378&r1=1717377&r2=1717378&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 Tue Dec  1 05:34:07 2015
@@ -89,6 +89,15 @@ svn_fs_git__db_ensure_commit(svn_fs_t *f
                              svn_revnum_t *latest_rev,
                              git_reference *ref);
 
+svn_error_t *
+svn_fs_git__db_fetch_oid(svn_boolean_t *found,
+                         git_oid **oid,
+                         const char **path,
+                         svn_fs_t *fs,
+                         svn_revnum_t revnum,
+                         apr_pool_t *result_pool,
+                         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-queries.sql
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_fs_git/fsgit-queries.sql?rev=1717378&r1=1717377&r2=1717378&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 Tue Dec  1 05:34:07
2015
@@ -41,6 +41,13 @@ SELECT MAX(
 -- STMT_SELECT_REV_BY_COMMITID
 SELECT revnum FROM REVMAP WHERE commit_id = ?1
 
+-- STMT_SELECT_COMMIT_BY_REV
+SELECT commit_id, relpath, revnum
+FROM REVMAP
+WHERE revnum <= ?1
+ORDER BY revnum DESC
+LIMIT 1
+
 -- STMT_INSERT_COMMIT
 INSERT INTO REVMAP (revnum, commit_id, relpath) VALUES (?1, ?2, ?3)
 

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=1717378&r1=1717377&r2=1717378&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 Tue Dec  1 05:34:07 2015
@@ -30,6 +30,8 @@
 #include "svn_fs.h"
 #include "svn_version.h"
 #include "svn_pools.h"
+#include "svn_hash.h"
+#include "svn_time.h"
 
 #include "svn_private_config.h"
 
@@ -62,7 +64,43 @@ fs_git_revision_prop(svn_string_t **valu
 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)
 {
+  svn_fs_git_fs_t *fgf = fs->fsap_data;
+  svn_boolean_t found;
+  git_oid *oid;
   *table_p = apr_hash_make(result_pool);
+
+  SVN_ERR(svn_fs_git__db_fetch_oid(&found, &oid, NULL, fs, rev,
+                                   scratch_pool, scratch_pool));
+
+  if (found)
+    {
+      git_commit *commit;
+      const git_signature *author;
+      git_time_t c_time;
+      const char *msg;
+      GIT2_ERR(git_commit_lookup(&commit, fgf->repos, oid));
+
+      c_time = git_commit_time(commit);
+      author = git_commit_author(commit);
+      msg = git_commit_message(commit);
+
+      if (ctime)
+        svn_hash_sets(*table_p, SVN_PROP_REVISION_DATE,
+                      svn_string_create(
+                        svn_time_to_cstring(
+                          apr_time_from_sec(git_commit_time(commit)),
+                          scratch_pool),
+                        result_pool));
+      if (author)
+        svn_hash_sets(*table_p, SVN_PROP_REVISION_AUTHOR,
+                      svn_string_create(author->email, result_pool));
+      if (msg)
+        svn_hash_sets(*table_p, SVN_PROP_REVISION_LOG,
+                      svn_string_create(msg, result_pool));
+
+      git_commit_free(commit);
+    }
+
   return SVN_NO_ERROR;
 }
 
@@ -128,13 +166,14 @@ fs_git_unlock(svn_fs_t *fs, apr_hash_t *
 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);
+  *lock = NULL;
+  return SVN_NO_ERROR;
 }
 
 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);
+  return SVN_NO_ERROR;
 }
 
 static svn_error_t *

Modified: subversion/branches/ra-git/subversion/libsvn_fs_git/git-revroot.c
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_fs_git/git-revroot.c?rev=1717378&r1=1717377&r2=1717378&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_fs_git/git-revroot.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_fs_git/git-revroot.c Tue Dec  1 05:34:07
2015
@@ -27,6 +27,7 @@
 #include <apr_pools.h>
 
 #include "svn_fs.h"
+#include "svn_hash.h"
 #include "svn_version.h"
 #include "svn_pools.h"
 
@@ -37,6 +38,35 @@
 #include "../libsvn_fs/fs-loader.h"
 #include "fs_git.h"
 
+typedef struct svn_fs_git_root_t
+{
+  git_commit *commit;
+  const char *rev_path;
+  svn_boolean_t exact;
+} svn_fs_git_root_t;
+
+static apr_status_t
+git_root_cleanup(void *baton)
+{
+  svn_fs_git_root_t *fgr = baton;
+
+  if (fgr->commit)
+    {
+      git_commit_free(fgr->commit);
+      fgr->commit = NULL;
+    }
+
+  return APR_SUCCESS;
+}
+
+static svn_fs_id_t *
+make_id(svn_fs_root_t *root,
+        const char *path,
+        apr_pool_t *result_pool)
+{
+  return NULL;
+}
+
  /* Determining what has changed in a root */
 static svn_error_t *
 fs_git_paths_changed(apr_hash_t **changed_paths_p,
@@ -51,6 +81,14 @@ static svn_error_t *
 fs_git_check_path(svn_node_kind_t *kind_p, svn_fs_root_t *root,
                   const char *path, apr_pool_t *pool)
 {
+  if (*path == '/')
+    path++;
+  if (!*path)
+    {
+      *kind_p = svn_node_dir;
+      return SVN_NO_ERROR;
+    }
+
   return svn_error_create(APR_ENOTIMPL, NULL, NULL);
 }
 
@@ -84,7 +122,16 @@ fs_git_node_created_rev(svn_revnum_t *re
                         svn_fs_root_t *root, const char *path,
                         apr_pool_t *pool)
 {
-  return svn_error_create(APR_ENOTIMPL, NULL, NULL);
+  /*svn_fs_git_root_t *fgr = root->fsap_data;*/
+  if (*path == '/' && path[1] == '\0')
+    {
+      *revision = root->rev;
+      return SVN_NO_ERROR;
+    }
+
+  *revision = root->rev; /* ### Needs path walk */
+
+  return SVN_NO_ERROR;
 }
 
 static svn_error_t *
@@ -157,11 +204,13 @@ fs_git_node_proplist(apr_hash_t **table_
 {
   return svn_error_create(APR_ENOTIMPL, NULL, NULL);
 }
+
 static svn_error_t *
 fs_git_node_has_props(svn_boolean_t *has_props, svn_fs_root_t *root,
                       const char *path, apr_pool_t *scratch_pool)
 {
-  return svn_error_create(APR_ENOTIMPL, NULL, NULL);
+  *has_props = FALSE;
+  return SVN_NO_ERROR;
 }
 
 static svn_error_t *
@@ -187,6 +236,33 @@ static svn_error_t *
 fs_git_dir_entries(apr_hash_t **entries_p, svn_fs_root_t *root,
                    const char *path, apr_pool_t *pool)
 {
+  svn_fs_dirent_t *de;
+
+  *entries_p = apr_hash_make(pool);
+  if (!root->rev)
+    return SVN_NO_ERROR;
+  else if (*path == '/' && path[1] == '\0')
+    {
+      de = apr_pcalloc(pool, sizeof(*de));
+      de->kind = svn_node_dir;
+      de->id = make_id(root, path, pool);
+      de->name = "trunk";
+      svn_hash_sets(*entries_p, "trunk", de);
+
+      de = apr_pcalloc(pool, sizeof(*de));
+      de->kind = svn_node_dir;
+      de->id = make_id(root, path, pool);
+      de->name = "branches";
+      svn_hash_sets(*entries_p, "branches", de);
+
+      de = apr_pcalloc(pool, sizeof(*de));
+      de->kind = svn_node_dir;
+      de->id = make_id(root, path, pool);
+      de->name = "tags";
+      svn_hash_sets(*entries_p, "tags", de);
+
+      return SVN_NO_ERROR;
+    }
   return svn_error_create(APR_ENOTIMPL, NULL, NULL);
 }
 
@@ -354,10 +430,14 @@ static root_vtable_t root_vtable =
 svn_error_t *
 svn_fs_git__revision_root(svn_fs_root_t **root_p, svn_fs_t *fs, svn_revnum_t rev, apr_pool_t
*pool)
 {
+  svn_fs_git_fs_t *fgf = fs->fsap_data;
   svn_fs_root_t *root;
+  svn_fs_git_root_t *fgr;
 
   SVN_ERR(svn_fs__check_fs(fs, TRUE));
 
+
+  fgr = apr_pcalloc(pool, sizeof(*fgr));
   root = apr_pcalloc(pool, sizeof(*root));
 
   root->pool = pool;
@@ -365,10 +445,23 @@ svn_fs_git__revision_root(svn_fs_root_t
   root->is_txn_root = FALSE;
   root->txn = NULL;
   root->txn_flags = 0;
-  root->rev = 0;
+  root->rev = rev;
 
   root->vtable = &root_vtable;
-  root->fsap_data = NULL;
+  root->fsap_data = fgr;
+
+  if (rev > 0)
+    {
+      git_oid *oid;
+      SVN_ERR(svn_fs_git__db_fetch_oid(&fgr->exact, &oid, &fgr->rev_path,
+                                       fs, rev, pool, pool));
+
+      if (oid)
+        GIT2_ERR(git_commit_lookup(&fgr->commit, fgf->repos, oid));
+
+      apr_pool_cleanup_register(pool, fgr, git_root_cleanup,
+                                apr_pool_cleanup_null);
+    }
 
   *root_p = root;
 

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=1717378&r1=1717377&r2=1717378&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_fs_git/gitdb.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_fs_git/gitdb.c Tue Dec  1 05:34:07 2015
@@ -94,6 +94,53 @@ svn_fs_git__db_ensure_commit(svn_fs_t *f
 }
 
 svn_error_t *
+svn_fs_git__db_fetch_oid(svn_boolean_t *found,
+                         git_oid **oid,
+                         const char **path,
+                         svn_fs_t *fs,
+                         svn_revnum_t revnum,
+                         apr_pool_t *result_pool,
+                         apr_pool_t *scratch_pool)
+{
+  svn_fs_git_fs_t *fgf = fs->fsap_data;
+  svn_sqlite__stmt_t *stmt;
+  svn_boolean_t got_row;
+  svn_revnum_t new_rev;
+
+  SVN_ERR(svn_sqlite__get_statement(&stmt, fgf->sdb,
+                                    STMT_SELECT_COMMIT_BY_REV));
+  SVN_ERR(svn_sqlite__bind_revnum(stmt, 1, revnum));
+  SVN_ERR(svn_sqlite__step(&got_row, stmt));
+
+  if (got_row)
+    {
+      if (found)
+        *found = (revnum == svn_sqlite__column_revnum(stmt, 2));
+      if (oid)
+        {
+          apr_size_t len;
+          *oid = svn_sqlite__column_blob(stmt, 0, &len, result_pool);
+          if (len != sizeof(**oid))
+            *oid = NULL;
+        }
+      if (path)
+        *path = svn_sqlite__column_text(stmt, 1, result_pool);
+    }
+  else
+    {
+      if (found)
+        *found = FALSE;
+      if (oid)
+        *oid = NULL;
+      if (path)
+        *path = NULL;
+    }
+  SVN_ERR(svn_sqlite__reset(stmt));
+  return SVN_NO_ERROR;
+}
+
+
+svn_error_t *
 svn_fs_git__db_open(svn_fs_t *fs,
                     apr_pool_t *scratch_pool)
 {

Modified: subversion/branches/ra-git/subversion/libsvn_fs_git/revmap.c
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_fs_git/revmap.c?rev=1717378&r1=1717377&r2=1717378&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_fs_git/revmap.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_fs_git/revmap.c Tue Dec  1 05:34:07 2015
@@ -53,6 +53,9 @@ revmap_update_branch(svn_fs_t *fs,
 
   while (!(git_err = git_revwalk_next(&oid, revwalk)))
     {
+      if (cancel_func)
+        SVN_ERR(cancel_func(cancel_baton));
+
       SVN_ERR(svn_fs_git__db_ensure_commit(fs, &oid, latest_rev, ref));
     }
 
@@ -77,6 +80,11 @@ revmap_update(svn_fs_t *fs,
   svn_revnum_t latest_rev, youngest;
 
   SVN_ERR(svn_fs_git__db_youngest_rev(&youngest, fs, scratch_pool));
+
+  if (youngest == 0)
+    youngest = 1; /* We use r1 to create /trunk, /branches and /tags.
+                     Let's not add other changes in the same rev */
+
   latest_rev = youngest;
 
   GIT2_ERR(git_branch_iterator_new(&iter, fgf->repos, GIT_BRANCH_ALL));



Mime
View raw message