subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhuij...@apache.org
Subject svn commit: r1717773 - in /subversion/branches/ra-git/subversion/libsvn_fs_git: fs_git.h git-history.c git-revroot.c
Date Thu, 03 Dec 2015 14:30:33 GMT
Author: rhuijben
Date: Thu Dec  3 14:30:32 2015
New Revision: 1717773

URL: http://svn.apache.org/viewvc?rev=1717773&view=rev
Log:
On the ra-git branch: Add the initial plumbing for supporting history walking.

This fixes 'svn log' on the repository root.

* subversion/libsvn_fs_git/fs_git.h
  (git2.h): Add similar define as in ra_git.
  (svn_fs_git__make_history_simple,
   svn_fs_git__make_history_commit,
   svn_fs_git__make_history_node): New function.

* subversion/libsvn_fs_git/git-history.c
  New file.

* subversion/libsvn_fs_git/git-revroot.c
  (fs_git_node_history): Detect the kind of history walk we need and delegate
    to a few new helper functions.

Added:
    subversion/branches/ra-git/subversion/libsvn_fs_git/git-history.c   (with props)
Modified:
    subversion/branches/ra-git/subversion/libsvn_fs_git/fs_git.h
    subversion/branches/ra-git/subversion/libsvn_fs_git/git-revroot.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=1717773&r1=1717772&r2=1717773&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 Thu Dec  3 14:30:32 2015
@@ -20,7 +20,12 @@
 * ====================================================================
 */
 
+/* We compile in C89 mode, so the 'inline' keyword used by libgit2 isn't supported. */
+#define inline APR_INLINE
 #include <git2.h>
+#undef inline
+
+#include "svn_fs.h"
 #include "private/svn_sqlite.h"
 
 #ifndef SVN_LIBSVN_FS__FS_GIT_H
@@ -171,6 +176,31 @@ svn_fs_git__revision_root(svn_fs_root_t
                           svn_revnum_t rev,
                           apr_pool_t *pool);
 
+/* From git-history.c */
+svn_error_t *
+svn_fs_git__make_history_simple(svn_fs_history_t **history_p,
+                                svn_fs_root_t *root,
+                                svn_revnum_t rev_start,
+                                svn_revnum_t rev_end,
+                                const char *path,
+                                apr_pool_t *result_pool,
+                                apr_pool_t *scratch_pool);
+
+svn_error_t *
+svn_fs_git__make_history_commit(svn_fs_history_t **history_p,
+                                svn_fs_root_t *root,
+                                const git_commit *commit,
+                                apr_pool_t *result_pool,
+                                apr_pool_t *scratch_pool);
+
+svn_error_t *
+svn_fs_git__make_history_node(svn_fs_history_t **history_p,
+                              svn_fs_root_t *root,
+                              const git_commit *commit,
+                              const char *relpath,
+                              apr_pool_t *result_pool,
+                              apr_pool_t *scratch_pool);
+
 
 /* From revmap.c */
 /* Until there is a formal api, this will synchronize the revisions */

Added: subversion/branches/ra-git/subversion/libsvn_fs_git/git-history.c
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_fs_git/git-history.c?rev=1717773&view=auto
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_fs_git/git-history.c (added)
+++ subversion/branches/ra-git/subversion/libsvn_fs_git/git-history.c Thu Dec  3 14:30:32
2015
@@ -0,0 +1,141 @@
+/* git-history.c --- svn history, delivered from 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.
+ * ====================================================================
+ */
+
+#include "svn_types.h"
+#include "svn_fs.h"
+
+#include "fs_git.h"
+#include "../libsvn_fs/fs-loader.h"
+
+static svn_fs_history_t *
+history_make(const history_vtable_t *vtable,
+             void *fsap_data,
+             apr_pool_t *result_pool)
+{
+  svn_fs_history_t *h = apr_palloc(result_pool, sizeof(*h));
+  h->vtable = vtable;
+  h->fsap_data = fsap_data;
+
+  return h;
+}
+
+/* ------------------------------------------------------- */
+typedef struct fs_git_simple_history_t
+{
+  const char *next_path;
+  svn_revnum_t rev;
+  svn_revnum_t last_rev;
+  svn_boolean_t initial_item;
+} fs_git_simple_history_t;
+
+static svn_error_t *
+fs_git_simple_history_prev(svn_fs_history_t **prev_history_p,
+                           svn_fs_history_t *history,
+                           svn_boolean_t cross_copies,
+                           apr_pool_t *result_pool,
+                           apr_pool_t *scratch_pool)
+{
+  fs_git_simple_history_t *sht = history->fsap_data;
+
+  if (!sht->initial_item
+      && sht->rev == sht->last_rev)
+    {
+      *prev_history_p = NULL;
+      return SVN_NO_ERROR;
+    }
+
+  sht = apr_pmemdup(result_pool, sht, sizeof(*sht));
+  sht->next_path = apr_pstrdup(result_pool, sht->next_path);
+
+  if (sht->initial_item)
+    sht->initial_item = FALSE;
+  else
+    {
+      sht->rev--;
+    }
+
+  *prev_history_p = history_make(history->vtable,
+                                 sht, result_pool);
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+fs_git_simple_history_location(const char **path,
+                               svn_revnum_t *revision,
+                               svn_fs_history_t *history,
+                               apr_pool_t *pool)
+{
+  fs_git_simple_history_t *sht = history->fsap_data;
+
+  *path = apr_pstrdup(pool, sht->next_path);
+  *revision = sht->rev;
+  return SVN_NO_ERROR;
+}
+
+static const history_vtable_t fs_git_simple_history_vtable =
+{
+  fs_git_simple_history_prev,
+  fs_git_simple_history_location
+};
+
+svn_error_t *
+svn_fs_git__make_history_simple(svn_fs_history_t **history_p,
+                                svn_fs_root_t *root,
+                                svn_revnum_t rev_start,
+                                svn_revnum_t rev_end,
+                                const char *path,
+                                apr_pool_t *result_pool,
+                                apr_pool_t *scratch_pool)
+{
+  fs_git_simple_history_t *sht = apr_palloc(result_pool, sizeof(*sht));
+  sht->next_path = apr_pstrdup(result_pool, path ? path : "/"); 
+  sht->rev = rev_start;
+  sht->last_rev = rev_end;
+  sht->initial_item = TRUE;
+
+  *history_p = history_make(&fs_git_simple_history_vtable,
+                              sht, result_pool);
+  return SVN_NO_ERROR;
+}
+
+/* ------------------------------------------------------- */
+svn_error_t *
+svn_fs_git__make_history_commit(svn_fs_history_t **history_p,
+                                svn_fs_root_t *root,
+                                const git_commit *commit,
+                                apr_pool_t *result_pool,
+                                apr_pool_t *scratch_pool)
+{
+  return svn_error_create(APR_ENOTIMPL, NULL, NULL);
+}
+
+/* ------------------------------------------------------- */
+svn_error_t *
+svn_fs_git__make_history_node(svn_fs_history_t **history_p,
+                              svn_fs_root_t *root,
+                              const git_commit *commit,
+                              const char *relpath,
+                              apr_pool_t *result_pool,
+                              apr_pool_t *scratch_pool)
+{
+  return svn_error_create(APR_ENOTIMPL, NULL, NULL);
+}

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

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=1717773&r1=1717772&r2=1717773&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 Thu Dec  3 14:30:32
2015
@@ -611,7 +611,55 @@ fs_git_node_history(svn_fs_history_t **h
                     apr_pool_t *result_pool,
                     apr_pool_t *scratch_pool)
 {
-  return svn_error_create(APR_ENOTIMPL, NULL, NULL);
+  const git_commit *commit;
+  const char *relpath;
+  git_tree *tree;
+  git_tree_entry *entry;
+
+  if (*path == '/')
+    path++;
+  if (!*path)
+    {
+      SVN_ERR(svn_fs_git__make_history_simple(history_p,
+                                              root, root->rev, 0, NULL,
+                                              result_pool, scratch_pool));
+      return SVN_NO_ERROR;
+    }
+
+  SVN_ERR(find_branch(&commit, &relpath, root, path, result_pool));
+  if (!commit)
+    {
+      if (root->rev > 0
+          && !strcmp(path, "branches") || !strcmp(path, "tags"))
+        {
+          /* Branches and tags subdirs were created in r1 */
+          SVN_ERR(svn_fs_git__make_history_simple(history_p,
+                                                  root, root->rev, 1, path,
+                                                  result_pool, scratch_pool));
+          return SVN_NO_ERROR;
+        }
+
+      return SVN_FS__NOT_FOUND(root, path);
+    }
+
+  if (!relpath[0])
+    {
+      SVN_ERR(svn_fs_git__make_history_commit(history_p,
+                                              root, commit,
+                                              result_pool, scratch_pool));
+      return SVN_NO_ERROR;
+    }
+
+  SVN_ERR(get_commit_tree(&tree, commit, scratch_pool));
+  SVN_ERR(find_tree_entry(&entry, tree, relpath, scratch_pool, scratch_pool));
+
+  if (!entry)
+    return SVN_FS__NOT_FOUND(root, path);
+
+  SVN_ERR(svn_fs_git__make_history_node(history_p,
+                                        root, commit, relpath,
+                                        result_pool, scratch_pool));
+  return SVN_NO_ERROR;
 }
 
 static svn_error_t *



Mime
View raw message