[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn commit: r37733 - in trunk/subversion: include libsvn_wc

From: Greg Stein <gstein_at_gmail.com>
Date: Fri, 15 May 2009 13:20:15 -0700

Rockin'!

On May 14, 2009, at 22:19, "Hyrum K. Wright" <hyrum_at_hyrumwright.org>
wrote:

> Author: hwright
> Date: Thu May 14 22:19:14 2009
> New Revision: 37733
>
> Log:
> Create a new public data structure for interacting with wc-ng. The
> working copy context will take the place of the adm_access baton in
> our
> APIs, while being much cleaner to use.
>
> Right now, this is essentially just an opaque way of letting the
> client pass
> around svn_wc__db_t handles.
>
> * subversion/include/svn_wc.h
> (svn_wc_context_t, svn_wc_context_create, svn_wc_context_destroy):
> New.
>
> * subversion/libsvn_wc/context.c
> (svn_wc_context_t, svn_wc_context_create, svn_wc_context_destroy):
> New.
>
> Added:
> trunk/subversion/libsvn_wc/context.c (contents, props changed)
> Modified:
> trunk/subversion/include/svn_wc.h
>
> Modified: trunk/subversion/include/svn_wc.h
> URL: http://svn.collab.net/viewvc/svn/trunk/subversion/include/svn_wc.h?pathrev=37733&r1=37732&r2=37733
> ===
> ===
> ===
> =====================================================================
> --- trunk/subversion/include/svn_wc.h Thu May 14 21:42:49 2009
> (r37732)
> +++ trunk/subversion/include/svn_wc.h Thu May 14 22:19:14 2009
> (r37733)
> @@ -127,6 +127,58 @@ svn_wc_version(void);
>
> /** @} */
>
> +/**
> + * @defgroup svn_wc_context Working copy context
> + * @{
> + */
> +
> +/** The context for all working copy interactions.
> + *
> + * This is the client-facing datastructure API consumers are required
> + * to create and use when interacting with a working copy. Multiple
> + * contexts can be created for the same working copy
> simultaneously, within
> + * the same process or different processes. Context mutexing will
> be handled
> + * internally by the working copy library.
> + */
> +typedef struct svn_wc_context_t svn_wc_context_t;
> +
> +/** Create a context for the working copy, and return it in @a
> *wc_ctx. This
> + * context is not associated with a particular working copy, but as
> operations
> + * are performed, will load the appropriate working copy information.
> + *
> + * @a config should hold the various configuration options that may
> apply to
> + * this context. It should live at least as long as @a
> result_pool. It may
> + * be @c NULL.
> + *
> + * The context will be allocated in @a result_pool, and will use @a
> + * result_pool for any internal allocations requiring the same
> longevity as
> + * the context. The context will be automatically destroyed, and its
> + * resources released, when @a result_pool is cleared, or it may be
> manually
> + * destroyed by invoking svn_wc_context_destroy().
> + *
> + * Use @a scratch_pool for temporary allocations. It may be cleared
> + * immediately upon returning from this function.
> + *
> + * @since New in 1.7.
> + */
> +svn_error_t *
> +svn_wc_context_create(svn_wc_context_t **wc_ctx,
> + svn_config_t *config,
> + apr_pool_t *result_pool,
> + apr_pool_t *scratch_pool);
> +
> +
> +/** Destroy the working copy context described by @a wc_ctx,
> releasing any
> + * acquired resources.
> + *
> + * @since New in 1.7.
> + */
> +svn_error_t *
> +svn_wc_context_destroy(svn_wc_context_t *wc_ctx);
> +
> +
> +/** @} */
> +
>
> /* Locking/Opening/Closing */
>
>
> Added: trunk/subversion/libsvn_wc/context.c
> URL: http://svn.collab.net/viewvc/svn/trunk/subversion/libsvn_wc/context.c?pathrev=37733
> ===
> ===
> ===
> =====================================================================
> --- /dev/null 00:00:00 1970 (empty, because file is newly added)
> +++ trunk/subversion/libsvn_wc/context.c Thu May 14 22:19:14
> 2009 (r37733)
> @@ -0,0 +1,96 @@
> +/*
> + * context.c: routines for managing a working copy context
> + *
> + *
> ====================================================================
> + * Copyright (c) 2009 CollabNet. All rights reserved.
> + *
> + * This software is licensed as described in the file COPYING, which
> + * you should have received as part of this distribution. The terms
> + * are also available at http://subversion.tigris.org/license-1.html.
> + * If newer versions of this license are posted there, you may use a
> + * newer version instead, at your option.
> + *
> + * This software consists of voluntary contributions made by many
> + * individuals. For exact contribution history, see the revision
> + * history and logs, available at http://subversion.tigris.org/.
> + *
> ====================================================================
> + */
> +
> +#include <apr_pools.h>
> +
> +#include "svn_types.h"
> +#include "svn_pools.h"
> +#include "svn_dirent_uri.h"
> +#include "svn_path.h"
> +
> +#include "wc.h"
> +#include "wc_db.h"
> +
> +#include "svn_private_config.h"
> +
> +
> +
> +struct svn_wc_context_t
> +{
> + /* The wc_db handle for this working copy. */
> + svn_wc__db_t *db;
> +
> + /* The state pool for this context. */
> + apr_pool_t *state_pool;
> +};
> +
> +
> +/* APR cleanup function used to explicitly close any of our dependent
> + data structures before we disappear ourselves. */
> +static apr_status_t
> +close_ctx_apr(void *data)
> +{
> + svn_wc_context_t *ctx = data;
> + svn_error_t *err;
> +
> + /* We can use the state pool here, because this handler will only
> get
> + run if the state pool is being cleaned up posthaste. */
> + err = svn_wc__db_close(ctx->db, ctx->state_pool);
> + if (err)
> + {
> + int result = err->apr_err;
> + svn_error_clear(err);
> + return result;
> + }
> +
> + return APR_SUCCESS;
> +}
> +
> +
> +svn_error_t *
> +svn_wc_context_create(svn_wc_context_t **wc_ctx,
> + svn_config_t *config,
> + apr_pool_t *result_pool,
> + apr_pool_t *scratch_pool)
> +{
> + svn_wc_context_t *ctx = apr_pcalloc(result_pool, sizeof(*ctx));
> +
> + /* Create the state_pool, and open up a wc_db in it. */
> + ctx->state_pool = svn_pool_create(result_pool);
> + SVN_ERR(svn_wc__db_open(&ctx->db, svn_wc__db_openmode_readwrite,
> config,
> + ctx->state_pool, scratch_pool));
> +
> + apr_pool_cleanup_register(ctx->state_pool, ctx, close_ctx_apr,
> + apr_pool_cleanup_null);
> +
> + *wc_ctx = ctx;
> +
> + return SVN_NO_ERROR;
> +}
> +
> +
> +svn_error_t *
> +svn_wc_context_destroy(svn_wc_context_t *wc_ctx)
> +{
> + /* Because we added the cleanup handler in
> svn_wc_context_create(), we
> + can just destory the state pool. VoilĂ ! Everything is closed
> and
> + freed. */
> + svn_pool_destroy(wc_ctx->state_pool);
> +
> + return SVN_NO_ERROR;
> +}
>
> ------------------------------------------------------
> http://subversion.tigris.org/ds/viewMessage.do?dsForumId=495&dsMessageId=2266564

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2274298
Received on 2009-05-15 22:20:51 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.