subversion-commits mailing list archives

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

URL: http://svn.apache.org/viewvc?rev=1717491&view=rev
Log:
On the git-ra branch: Implement created rev lookup. This fixes the
last-changed-* properties for all paths within branches.

* subversion/libsvn_fs_git/fsgit-queries.sql
  (STMT_SELECT_HEADREV): Add column.

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

* subversion/libsvn_fs_git/git-revroot.c
  (cleanup_git_commit): New function.
  (find_commit): New function.
  (fs_git_node_created_rev): Implement function for the normal case.

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

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-revroot.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=1717491&r1=1717490&r2=1717491&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 18:25:41 2015
@@ -108,6 +108,15 @@ svn_fs_git__db_fetch_oid(svn_boolean_t *
                          apr_pool_t *scratch_pool);
 
 svn_error_t *
+svn_fs_git__db_fetch_rev(svn_revnum_t *revnum,
+                         const char **path,
+                         svn_fs_t *fs,
+                         const git_oid *oid,
+                         apr_pool_t *result_pool,
+                         apr_pool_t *scratch_pool);
+
+
+svn_error_t *
 svn_fs_git__db_fetch_checksum(svn_checksum_t **checksum,
                               svn_fs_t *fs,
                               const git_oid *oid,

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=1717491&r1=1717490&r2=1717491&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 18:25:41
2015
@@ -39,7 +39,7 @@ SELECT MAX(
    IFNULL((SELECT MAX(from_rev) FROM BRANCHMAP), 0))
 
 -- STMT_SELECT_REV_BY_COMMITID
-SELECT revnum FROM REVMAP WHERE commit_id = ?1
+SELECT revnum, relpath FROM REVMAP WHERE commit_id = ?1
 
 -- STMT_SELECT_COMMIT_BY_REV
 SELECT commit_id, relpath, revnum

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=1717491&r1=1717490&r2=1717491&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 18:25:41
2015
@@ -77,6 +77,13 @@ cleanup_git_object(void *baton)
   return APR_SUCCESS;
 }
 
+static apr_status_t
+cleanup_git_commit(void *baton)
+{
+  git_commit_free(baton);
+  return APR_SUCCESS;
+}
+
 /* Gets the raw git object behind an entry. Takes care of the 'will free'
    promise via the pool */
 static svn_error_t *
@@ -214,6 +221,22 @@ find_branch(const git_commit **commit, c
 }
 
 static svn_error_t *
+find_commit(git_commit **commit, svn_fs_root_t *root,
+            const git_oid *oid, apr_pool_t *result_pool)
+{
+  svn_fs_git_fs_t *fgf = root->fs->fsap_data;
+
+  GIT2_ERR(git_commit_lookup(commit, fgf->repos, oid));
+
+  if (commit)
+    {
+      apr_pool_cleanup_register(result_pool, *commit, cleanup_git_commit,
+                                apr_pool_cleanup_null);
+    }
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
 find_tree_entry(const git_tree_entry **entry, git_tree *tree,
                 const char *relpath,
                 apr_pool_t *result_pool, apr_pool_t *scratch_pool)
@@ -458,14 +481,85 @@ fs_git_node_created_rev(svn_revnum_t *re
                         svn_fs_root_t *root, const char *path,
                         apr_pool_t *pool)
 {
-  /*svn_fs_git_root_t *fgr = root->fsap_data;*/
-  if (*path == '/' && path[1] == '\0')
+  svn_fs_git_root_t *fgr = root->fsap_data;
+  const git_commit *rev_commit;
+  const char *relpath;
+  git_tree *rev_tree;
+  git_tree_entry *rev_entry;
+  apr_pool_t *iterpool;
+  git_oid oid, last_oid;
+  const git_oid *oid_p;
+
+  if (*path == '/')
+    path++;
+
+  if (*path == '\0')
+    {
+      *revision = root->rev;
+      return SVN_NO_ERROR;
+    }
+
+  SVN_ERR(find_branch(&rev_commit, &relpath, root, path, pool));
+  if (!rev_commit)
     {
+      /* Handle 'branches' and 'tags' dirs */
       *revision = root->rev;
       return SVN_NO_ERROR;
     }
+  else if (!*relpath && fgr->rev_path && !strcmp(fgr->rev_path, path))
+    {
+      /* The root of what has committed, changed... */
+      *revision = root->rev;
+      return SVN_NO_ERROR;
+    }
+  iterpool = svn_pool_create(pool);
+
+  GIT2_ERR(git_commit_tree(&rev_tree, rev_commit));
+  SVN_ERR(find_tree_entry(&rev_entry, rev_tree, relpath, pool, iterpool));
+
+  last_oid = *git_commit_id(rev_commit);
+  oid_p = git_commit_parent_id(rev_commit, 0);
+
+
+  while (oid_p)
+    {
+      git_commit *cmt;
+      git_tree *cmt_tree;
+      git_tree_entry *cmt_entry;
+
+      svn_pool_clear(iterpool);
+
+      SVN_ERR(find_commit(&cmt, root, oid_p, iterpool));
+
+      GIT2_ERR(git_commit_tree(&cmt_tree, cmt));
+
+      SVN_ERR(find_tree_entry(&cmt_entry, cmt_tree, relpath,
+                              iterpool, iterpool));
+
+      if (!cmt_entry || git_oid_cmp(git_tree_entry_id(rev_entry),
+                                    git_tree_entry_id(cmt_entry)))
+        {
+          break;
+        }
+
+      git_commit_message(cmt);
+
+      last_oid = *git_commit_id(cmt);
+
+      oid_p = git_commit_parent_id(cmt, 0);
+      if (!oid_p)
+        break;
+
+      /* And prepare for pool cleanup */
+      oid = *oid_p;
+      oid_p = &oid;
+    }
+
+  SVN_ERR(svn_fs_git__db_fetch_rev(revision, NULL,
+                                   root->fs, &last_oid,
+                                   pool, iterpool));
 
-  *revision = root->rev; /* ### Needs path walk */
+  svn_pool_destroy(iterpool);
 
   return SVN_NO_ERROR;
 }

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=1717491&r1=1717490&r2=1717491&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 18:25:41 2015
@@ -139,6 +139,43 @@ svn_fs_git__db_fetch_oid(svn_boolean_t *
 }
 
 
+svn_error_t *
+svn_fs_git__db_fetch_rev(svn_revnum_t *revnum,
+                         const char **path,
+                         svn_fs_t *fs,
+                         const git_oid *oid,
+                         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_ERR(svn_sqlite__get_statement(&stmt, fgf->sdb,
+                                    STMT_SELECT_REV_BY_COMMITID));
+  SVN_ERR(svn_sqlite__bind_blob(stmt, 1, oid, sizeof(*oid)));
+  SVN_ERR(svn_sqlite__step(&got_row, stmt));
+
+  if (got_row)
+    {
+      if (revnum)
+        *revnum = svn_sqlite__column_revnum(stmt, 0);
+      if (path)
+        *path = svn_sqlite__column_text(stmt, 1, result_pool);
+    }
+  else
+    {
+      if (revnum)
+        *revnum = SVN_INVALID_REVNUM;
+      if (path)
+        *path = NULL;
+    }
+  SVN_ERR(svn_sqlite__reset(stmt));
+  return SVN_NO_ERROR;
+}
+
+
+
 static svn_error_t *
 db_fetch_checksum(svn_checksum_t **checksum,
                   svn_fs_t *fs,



Mime
View raw message