subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhuij...@apache.org
Subject svn commit: r1717860 - in /subversion/branches/ra-git/subversion/libsvn_fs_git: fs_git.h fsgit-metadata.sql fsgit-queries.sql gitdb.c revmap.c
Date Thu, 03 Dec 2015 22:47:30 GMT
Author: rhuijben
Date: Thu Dec  3 22:47:30 2015
New Revision: 1717860

URL: http://svn.apache.org/viewvc?rev=1717860&view=rev
Log:
On the ra-git branch: Start filling the branchmap table in the sqlite database
to fix svn ls ^/branches and to prepare hiding and re-adding branches pointing
to existing revisions during repository syncs.

* subversion/libsvn_fs_git/fsgit-metadata.sql
  (BRANCHMAP): Rename and add column.

* subversion/libsvn_fs_git/fsgit-queries.sql
  (STMT_SELECT_HEADREV): Tweak query.
  (STMT_SELECT_BRANCH_EXACT,
   STMT_INSERT_BRANCH): New query.
  (STMT_SELECT_BRANCHES): Tweak query.

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

* subversion/libsvn_fs_git/gitdb.c
  (db_branch_ensure,
   svn_fs_git__db_branch_ensure): New function.

* subversion/libsvn_fs_git/revmap.c
  (revmap_update_branch): Ensure branch if necessary.

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/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=1717860&r1=1717859&r2=1717860&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 22:47:30 2015
@@ -144,6 +144,13 @@ svn_fs_git__db_get_tags_branches(apr_has
                                  apr_pool_t *scratch_pool);
 
 svn_error_t *
+svn_fs_git__db_branch_ensure(svn_fs_t *fs,
+                             const char *relpath,
+                             svn_revnum_t youngest_rev,
+                             svn_revnum_t from_rev,
+                             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-metadata.sql
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_fs_git/fsgit-metadata.sql?rev=1717860&r1=1717859&r2=1717860&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 Thu Dec  3 22:47:30
2015
@@ -61,8 +61,10 @@ CREATE TABLE BRANCHMAP (
 
   relpath TEXT NOT NULL,
 
-  from_rev INTEGER NOT NULL,
-  to_rev INTEGER NULL
+  revnum INTEGER NOT NULL,
+  to_rev INTEGER NULL,
+
+  from_rev INTEGER NULL
 );
 
 CREATE UNIQUE INDEX I_BRANCHMAP_RELPATH ON BRANCHMAP (relpath, from_rev);

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=1717860&r1=1717859&r2=1717860&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 Thu Dec  3 22:47:30
2015
@@ -37,7 +37,7 @@ INSERT OR REPLACE INTO REPOSITORY(id, uu
 SELECT MAX(
    IFNULL((SELECT MAX(revnum) FROM REVMAP), 0),
    IFNULL((SELECT MAX(revnum) FROM TAGMAP), 0),
-   IFNULL((SELECT MAX(from_rev) FROM BRANCHMAP), 0))
+   IFNULL((SELECT MAX(revnum) FROM BRANCHMAP), 0))
 
 -- STMT_SELECT_REV_BY_COMMITID
 SELECT revnum, relpath FROM REVMAP WHERE commit_id = ?1
@@ -83,6 +83,15 @@ WHERE relpath = ?1 AND revnum <= ?2
 ORDER BY relpath DESC, revnum DESC
 LIMIT 1
 
+-- STMT_SELECT_BRANCH_EXACT
+SELECT relpath, revnum, to_rev, from_rev
+FROM BRANCHMAP
+WHERE relpath =?1 AND revnum <= ?2 AND (to_rev > ?2 OR to_rev IS NULL)
+
+-- STMT_INSERT_BRANCH
+INSERT INTO BRANCHMAP (relpath, revnum, to_rev, from_rev)
+VALUES (?1, ?2, ?3, ?4)
+
 -- STMT_SELECT_TAG
 SELECT revnum, from_rev, relpath FROM TAGMAP where relpath = ?1
 
@@ -92,7 +101,7 @@ INSERT INTO TAGMAP (revnum, from_rev, re
 -- 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)
+AND revnum <= ?2 AND (to_rev > ?2 OR to_rev IS NULL)
 
 -- STMT_SELECT_TAGS
 SELECT DISTINCT relpath FROM TAGMAP

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=1717860&r1=1717859&r2=1717860&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_fs_git/gitdb.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_fs_git/gitdb.c Thu Dec  3 22:47:30 2015
@@ -392,6 +392,54 @@ svn_fs_git__db_tag_create(svn_revnum_t *
 }
 
 static svn_error_t *
+db_branch_ensure(svn_fs_t *fs,
+                 const char *relpath,
+                 svn_revnum_t youngest_rev,
+                 svn_revnum_t from_rev,
+                 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_BRANCH_EXACT));
+  SVN_ERR(svn_sqlite__bind_text(stmt, 1, relpath));
+  SVN_ERR(svn_sqlite__bind_revnum(stmt, 2, youngest_rev));
+  SVN_ERR(svn_sqlite__step(&got_row, stmt));
+  SVN_ERR(svn_sqlite__reset(stmt));
+  if (got_row)
+    return SVN_NO_ERROR;
+
+  SVN_ERR(svn_sqlite__get_statement(&stmt, fgf->sdb,
+                                    STMT_INSERT_BRANCH));
+  SVN_ERR(svn_sqlite__bind_text(stmt, 1, relpath));
+  SVN_ERR(svn_sqlite__bind_revnum(stmt, 2, youngest_rev));
+  /* 3: to_rev */
+  SVN_ERR(svn_sqlite__bind_revnum(stmt, 4, from_rev));
+  SVN_ERR(svn_sqlite__update(NULL, stmt));
+
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_fs_git__db_branch_ensure(svn_fs_t *fs,
+                             const char *relpath,
+                             svn_revnum_t youngest_rev,
+                             svn_revnum_t from_rev,
+                             apr_pool_t *scratch_pool)
+{
+  svn_fs_git_fs_t *fgf = fs->fsap_data;
+
+  SVN_SQLITE__WITH_LOCK(db_branch_ensure(fs, relpath,
+                                         youngest_rev, from_rev,
+                                         scratch_pool),
+                        fgf->sdb);
+
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
 db_get_tags_branches(apr_hash_t **tags,
                      apr_hash_t **branches,
                      svn_fs_t *fs,
@@ -421,7 +469,7 @@ db_get_tags_branches(apr_hash_t **tags,
           name = svn_relpath_skip_ancestor(relpath, path);
 
           if (!strchr(name, '/'))
-            svn_hash_sets(*tags, name, path);
+            svn_hash_sets(*branches, name, path);
 
           SVN_ERR(svn_sqlite__step(&got_row, stmt));
         }

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=1717860&r1=1717859&r2=1717860&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_fs_git/revmap.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_fs_git/revmap.c Thu Dec  3 22:47:30 2015
@@ -51,7 +51,7 @@ revmap_update_branch(svn_fs_t *fs,
   int git_err;
   git_oid oid;
   svn_revnum_t last_rev = SVN_INVALID_REVNUM;
-
+  svn_boolean_t ensured_branch = (relpath != NULL);
 
   /* ### TODO: Return if walk_oid is already mapped */
 
@@ -88,6 +88,14 @@ revmap_update_branch(svn_fs_t *fs,
       if (rev > y_rev)
         {
           *latest_rev = rev;
+
+          if (!ensured_branch)
+            {
+              SVN_ERR(svn_fs_git__db_branch_ensure(fs, relpath,
+                                                   rev, rev,
+                                                   scratch_pool));
+              ensured_branch = TRUE;
+            }
         }
 
       last_rev = rev;



Mime
View raw message