Return-Path: X-Original-To: apmail-subversion-commits-archive@minotaur.apache.org Delivered-To: apmail-subversion-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8D94318E8B for ; Tue, 1 Dec 2015 18:25:44 +0000 (UTC) Received: (qmail 1700 invoked by uid 500); 1 Dec 2015 18:25:44 -0000 Delivered-To: apmail-subversion-commits-archive@subversion.apache.org Received: (qmail 1664 invoked by uid 500); 1 Dec 2015 18:25:44 -0000 Mailing-List: contact commits-help@subversion.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@subversion.apache.org Delivered-To: mailing list commits@subversion.apache.org Received: (qmail 1654 invoked by uid 99); 1 Dec 2015 18:25:44 -0000 Received: from Unknown (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Dec 2015 18:25:44 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id DACDEC2ED7 for ; Tue, 1 Dec 2015 18:25:43 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.79 X-Spam-Level: * X-Spam-Status: No, score=1.79 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, T_RP_MATCHES_RCVD=-0.01] autolearn=disabled Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id CqIi0CVa6C02 for ; Tue, 1 Dec 2015 18:25:43 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with ESMTP id B64A7429AA for ; Tue, 1 Dec 2015 18:25:42 +0000 (UTC) Received: from svn01-us-west.apache.org (svn.apache.org [10.41.0.6]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 4E5A5E05E3 for ; Tue, 1 Dec 2015 18:25:42 +0000 (UTC) Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 282A93A0404 for ; Tue, 1 Dec 2015 18:25:42 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@subversion.apache.org From: rhuijben@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20151201182542.282A93A0404@svn01-us-west.apache.org> 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,