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 620028F37 for ; Tue, 13 Sep 2011 02:40:16 +0000 (UTC) Received: (qmail 42735 invoked by uid 500); 13 Sep 2011 02:40:16 -0000 Delivered-To: apmail-subversion-commits-archive@subversion.apache.org Received: (qmail 42626 invoked by uid 500); 13 Sep 2011 02:40:15 -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 42619 invoked by uid 99); 13 Sep 2011 02:40:13 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Sep 2011 02:40:13 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Sep 2011 02:40:11 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 06E1A2388A02 for ; Tue, 13 Sep 2011 02:39:50 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1170014 - /subversion/branches/fs-successor-ids/subversion/libsvn_fs_fs/tree.c Date: Tue, 13 Sep 2011 02:39:49 -0000 To: commits@subversion.apache.org From: danielsh@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110913023950.06E1A2388A02@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: danielsh Date: Tue Sep 13 02:39:49 2011 New Revision: 1170014 URL: http://svn.apache.org/viewvc?rev=1170014&view=rev Log: On the fs-successor-ids branch, implement svn_fs_history_next() for FSFS. This is largely a machine translation of the BDB implementation :-(. * subversion/libsvn_fs_fs/tree.c (struct history_next_args, report_successor, txn_body_history_next): New, based on their analogues in libsvn_fs_base. (fs_history_next): Implement, mirroring base_history_next(). Modified: subversion/branches/fs-successor-ids/subversion/libsvn_fs_fs/tree.c Modified: subversion/branches/fs-successor-ids/subversion/libsvn_fs_fs/tree.c URL: http://svn.apache.org/viewvc/subversion/branches/fs-successor-ids/subversion/libsvn_fs_fs/tree.c?rev=1170014&r1=1170013&r2=1170014&view=diff ============================================================================== --- subversion/branches/fs-successor-ids/subversion/libsvn_fs_fs/tree.c (original) +++ subversion/branches/fs-successor-ids/subversion/libsvn_fs_fs/tree.c Tue Sep 13 02:39:49 2011 @@ -3330,6 +3330,104 @@ fs_history_prev(svn_fs_history_t **prev_ } +struct history_next_args +{ + svn_fs_history_next_receiver_t receiver; + void *receiver_baton; + svn_fs_history_t *history; + apr_pool_t *pool; +}; + +/* Call ARGS->RECEIVER with a history object corresponding to either + ID or NODE in ARGS's FS. Exactly one of NODE and ID must be provided. + Use SCRATCH_POOL for allocations. + */ +static svn_error_t * +report_successor(struct history_next_args *args, + svn_fs_id_t *id, + dag_node_t *node, + apr_pool_t *scratch_pool) +{ + fs_history_data_t *fhd = args->history->fsap_data; + svn_fs_history_t *next; + const char *path; + svn_revnum_t revision; + + SVN_ERR_ASSERT((id != NULL) != (node != NULL)); + + if (id) + SVN_ERR(svn_fs_fs__dag_get_node(&node, fhd->fs, id, scratch_pool)); + + path = svn_fs_fs__dag_get_created_path(node); + SVN_ERR(svn_fs_fs__dag_get_revision(&revision, node, + scratch_pool)); + /* ### TODO(sid): NEXT should be allocated in SCRATCH_POOL, but there is no + svn_fs_history_dup() function for callers that want to hang on to it. + */ + next = assemble_history(fhd->fs, + path, revision, + TRUE /* is_interesting */, + NULL, SVN_INVALID_REVNUM /* path_hint, rev_hint */, + args->pool); + SVN_ERR(args->receiver(next, args->receiver_baton, args->history, + scratch_pool)); + + return SVN_NO_ERROR; +} + +/* Corresponds to the same function in libsvn_fs_base, except that here it + doesn't need to take any lock or txn as it doesn't write anything. */ +static svn_error_t * +txn_body_history_next(struct history_next_args *args, + apr_pool_t *scratch_pool) +{ + fs_history_data_t *fhd = args->history->fsap_data; + const svn_fs_id_t *node_id; + dag_node_t *node; + + /* Compute NODE and NODE_ID from fhd->PATH and fhd->REVISION. */ + { + svn_fs_root_t *root; + svn_fs_t *fs = fhd->fs; + + SVN_ERR(svn_fs_fs__revision_root(&root, fs, fhd->revision, scratch_pool)); + SVN_ERR(get_dag(&node, root, fhd->path, scratch_pool)); + node_id = svn_fs_fs__dag_get_id(node); + } + + /* Check whether NODE_ID itself is an interesting history location. */ + { + svn_revnum_t commit_rev; + + SVN_ERR(svn_fs_fs__dag_get_revision(&commit_rev, node, + scratch_pool)); + + if (commit_rev == fhd->revision) + SVN_ERR(report_successor(args, NULL, node, scratch_pool)); + } + + /* Let the fs_fs.h API do the legwork, ... */ + { + apr_array_header_t *successors; + int i; + + /* ### TODO(sid): switch to callback */ + SVN_ERR(svn_fs_fs__get_node_successors(&successors, + fhd->fs, node_id, + TRUE /* committed_only */, + scratch_pool, scratch_pool)); + for (i = 0; i < successors->nelts; i++) + { + /* ... then massage its results into something understandable by + our caller, and pass them along. */ + svn_fs_id_t *successor_id = APR_ARRAY_IDX(successors, i, svn_fs_id_t *); + SVN_ERR(report_successor(args, successor_id, NULL, scratch_pool)); + } + } + + return SVN_NO_ERROR; +} + /* Implement svn_fs_history_next(). */ static svn_error_t * fs_history_next(svn_fs_history_next_receiver_t receiver, @@ -3337,8 +3435,13 @@ fs_history_next(svn_fs_history_next_rece svn_fs_history_t *history, apr_pool_t *pool) { - /* ### "Not implemented" */ - return svn_error_create(SVN_ERR_UNSUPPORTED_FEATURE, NULL, NULL); + struct history_next_args args = { + receiver, receiver_baton, history, pool + }; + + SVN_ERR(txn_body_history_next(&args, pool)); + + return SVN_NO_ERROR; }