subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhuij...@apache.org
Subject svn commit: r1717645 - in /subversion/branches/ra-git/subversion/libsvn_fs_git: fs_git.h fsgit-queries.sql git-revroot.c gitdb.c
Date Wed, 02 Dec 2015 14:50:11 GMT
Author: rhuijben
Date: Wed Dec  2 14:50:11 2015
New Revision: 1717645

URL: http://svn.apache.org/viewvc?rev=1717645&view=rev
Log:
On the ra-git branch: Implement fetching of the /tags/ directory.
(And provide some plumbing for /branches/)

* subversion/libsvn_fs_git/fsgit-queries.sql
  (STMT_SELECT_BRANCH): Fix checksum for the right revision.

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

* subversion/libsvn_fs_git/git-revroot.c
  (find_branch): Improve check to avoid segfault in strange case
    that should never happen.
  (fs_git_dir_entries): Resolve TODO.

* subversion/libsvn_fs_git/gitdb.c
  (includes): Add svn_hash.h.
  (db_get_tags_branches,
   svn_fs_git__db_get_tags_branches): 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=1717645&r1=1717644&r2=1717645&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 14:50:11 2015
@@ -151,6 +151,15 @@ svn_fs_git__db_tag_create(svn_revnum_t *
                           apr_pool_t *scratch_pool);
 
 svn_error_t *
+svn_fs_git__db_get_tags_branches(apr_hash_t **tags,
+                                 apr_hash_t **branches,
+                                 svn_fs_t *fs,
+                                 const char *relpath,
+                                 svn_revnum_t rev,
+                                 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);

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=1717645&r1=1717644&r2=1717645&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 14:50:11
2015
@@ -73,7 +73,7 @@ WHERE (relpath <= ?1 AND relpath || '0'
 LIMIT 1
 
 -- STMT_SELECT_BRANCH
-SELECT relpath, (SELECT commit_id FROM revmap r WHERE r.revnum=t.revnum),
+SELECT relpath, (SELECT commit_id FROM revmap r WHERE r.revnum=t.from_rev),
        from_rev
 FROM TAGMAP t WHERE relpath = ?1 AND revnum <= ?2
 UNION ALL
@@ -89,6 +89,16 @@ SELECT revnum, from_rev, relpath FROM TA
 -- STMT_INSERT_TAG
 INSERT INTO TAGMAP (revnum, from_rev, relpath) VALUES (?1, ?2, ?3)
 
+-- STMT_SELECT_BRANCHES
+SELECT DISTINCT relpath FROM BRANCHMAP
+WHERE relpath > ?1 || '/' AND relpath < ?1 || '0'
+AND from_rev <= ?2 AND (to_rev > ?2 OR to_rev IS NULL)
+
+-- STMT_SELECT_TAGS
+SELECT DISTINCT relpath FROM TAGMAP
+WHERE relpath > ?1 || '/' AND relpath < ?1 || '0'
+AND revnum <= ?2
+
 /* Grab all the statements related to the schema.  */
 
 -- include: fsgit-metadata

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=1717645&r1=1717644&r2=1717645&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 Wed Dec  2 14:50:11
2015
@@ -317,7 +317,7 @@ find_branch(const git_commit **commit, c
                                      root->fs, path, root->rev,
                                      pool, pool));
 
-  if (branch_path)
+  if (branch_path && oid)
     {
       apr_pool_t *result_pool = apr_hash_pool_get(fgr->branch_map);
 
@@ -964,7 +964,26 @@ fs_git_dir_entries(apr_hash_t **entries_
   SVN_ERR(find_branch(&commit, &relpath, root, path, pool));
   if (!commit)
     {
-      /* TODO: List 'tags' and 'branches' */
+      apr_hash_t *tags, *branches;
+      apr_hash_index_t *hi;
+
+      SVN_ERR(svn_fs_git__db_get_tags_branches(&tags, &branches,
+                                               root->fs, path, root->rev,
+                                               pool, pool));
+
+      branches = apr_hash_overlay(pool, branches, tags);
+      for (hi = apr_hash_first(pool, branches); hi; hi = apr_hash_next(hi))
+        {
+          const char *name = apr_hash_this_key(hi);
+          const char *relpath = apr_hash_this_val(hi);
+
+          de = apr_pcalloc(pool, sizeof(*de));
+          de->kind = svn_node_dir;
+          de->id = make_id(root, relpath, pool);
+          de->name = name;
+          svn_hash_sets(*entries_p, name, de);
+        }
+
       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=1717645&r1=1717644&r2=1717645&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 14:50:11 2015
@@ -30,6 +30,7 @@
 #include "svn_fs.h"
 #include "svn_version.h"
 #include "svn_pools.h"
+#include "svn_hash.h"
 #include "svn_dirent_uri.h"
 
 #include "svn_private_config.h"
@@ -395,6 +396,88 @@ svn_fs_git__db_tag_create(svn_revnum_t *
   return SVN_NO_ERROR;
 }
 
+static svn_error_t *
+db_get_tags_branches(apr_hash_t **tags,
+                     apr_hash_t **branches,
+                     svn_fs_t *fs,
+                     const char *relpath,
+                     svn_revnum_t rev,
+                     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;
+
+  if (branches)
+    {
+      *branches = apr_hash_make(result_pool);
+      SVN_ERR(svn_sqlite__get_statement(&stmt, fgf->sdb,
+                                        STMT_SELECT_BRANCHES));
+      SVN_ERR(svn_sqlite__bind_text(stmt, 1, relpath));
+      SVN_ERR(svn_sqlite__bind_revnum(stmt, 2, rev));
+      SVN_ERR(svn_sqlite__step(&got_row, stmt));
+      while (got_row)
+        {
+          const char *name;
+          const char *path;
+
+          path = svn_sqlite__column_text(stmt, 0, result_pool);
+          name = svn_relpath_skip_ancestor(relpath, path);
+
+          if (!strchr(name, '/'))
+            svn_hash_sets(*tags, name, path);
+
+          SVN_ERR(svn_sqlite__step(&got_row, stmt));
+        }
+      SVN_ERR(svn_sqlite__reset(stmt));
+    }
+  if (tags)
+    {
+      *tags = apr_hash_make(result_pool);
+      SVN_ERR(svn_sqlite__get_statement(&stmt, fgf->sdb,
+                                        STMT_SELECT_TAGS));
+      SVN_ERR(svn_sqlite__bind_text(stmt, 1, relpath));
+      SVN_ERR(svn_sqlite__bind_revnum(stmt, 2, rev));
+      SVN_ERR(svn_sqlite__step(&got_row, stmt));
+      while (got_row)
+        {
+          const char *name;
+          const char *path;
+
+          path = svn_sqlite__column_text(stmt, 0, result_pool);
+          name = svn_relpath_skip_ancestor(relpath, path);
+
+          if (!strchr(name, '/'))
+            svn_hash_sets(*tags, name, path);
+
+          SVN_ERR(svn_sqlite__step(&got_row, stmt));
+        }
+      SVN_ERR(svn_sqlite__reset(stmt));
+    }
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_fs_git__db_get_tags_branches(apr_hash_t **tags,
+                                 apr_hash_t **branches,
+                                 svn_fs_t *fs,
+                                 const char *relpath,
+                                 svn_revnum_t rev,
+                                 apr_pool_t *result_pool,
+                                 apr_pool_t *scratch_pool)
+{
+  svn_fs_git_fs_t *fgf = fs->fsap_data;
+
+  SVN_SQLITE__WITH_LOCK(db_get_tags_branches(tags, branches,
+                                             fs, relpath, rev,
+                                             result_pool, scratch_pool),
+                        fgf->sdb);
+
+  return SVN_NO_ERROR;
+}
+
+
 svn_error_t *
 svn_fs_git__db_open(svn_fs_t *fs,
                     apr_pool_t *scratch_pool)



Mime
View raw message