You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ju...@apache.org on 2015/10/20 12:54:14 UTC
svn commit: r1709565 - in /subversion/branches/move-tracking-2/subversion:
include/private/svn_branch.h libsvn_delta/branch.c
libsvn_delta/branch_private.h
Author: julianfoad
Date: Tue Oct 20 10:54:14 2015
New Revision: 1709565
URL: http://svn.apache.org/viewvc?rev=1709565&view=rev
Log:
On the 'move-tracking-2' branch: Refactoring of branch state and branch
transaction objects to allow implementing different subclasses with
different private data.
This separates the private data from the (conceptually public) vtable.
* subversion/include/private/svn_branch.h
(svn_branch_txn_vtable_t,
svn_branch_state_vtable_t): New.
(svn_branch_txn_t,
svn_branch_state_t): Add a vtable.
* subversion/libsvn_delta/branch_private.h
(svn_branch_txn_vtable_t,
svn_branch_state_vtable_t): Rename from '*_priv_t' and remove the private
data.
* subversion/libsvn_delta/branch.c
(svn_branch_txn_priv_t,
svn_branch_state_priv_t): Define here, containing just the private data.
(svn_branch_txn_new_eid,
svn_branch_txn_open_branch,
svn_branch_txn_branch,
svn_branch_txn_sequence_point,
branch_txn_create): Track the rename of 'priv' to 'vtable'.
(svn_branch_txn_create): Initialize the new 'priv' member.
(svn_branch_state_alter_one,
svn_branch_state_copy_tree,
svn_branch_state_delete_one,
svn_branch_state_purge,
branch_state_create): Track the rename of 'priv' to 'vtable'.
(svn_branch_state_create): Initialize the new 'priv' member.
Modified:
subversion/branches/move-tracking-2/subversion/include/private/svn_branch.h
subversion/branches/move-tracking-2/subversion/libsvn_delta/branch.c
subversion/branches/move-tracking-2/subversion/libsvn_delta/branch_private.h
Modified: subversion/branches/move-tracking-2/subversion/include/private/svn_branch.h
URL: http://svn.apache.org/viewvc/subversion/branches/move-tracking-2/subversion/include/private/svn_branch.h?rev=1709565&r1=1709564&r2=1709565&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/include/private/svn_branch.h (original)
+++ subversion/branches/move-tracking-2/subversion/include/private/svn_branch.h Tue Oct 20 10:54:14 2015
@@ -123,7 +123,11 @@ typedef struct svn_branch_state_t svn_br
*/
typedef struct svn_branch_repos_t svn_branch_repos_t;
-/* Private methods and data for a transaction.
+/* Methods (conceptually public, but called indirectly) for a transaction.
+ */
+typedef struct svn_branch_txn_vtable_t svn_branch_txn_vtable_t;
+
+/* Private data for a transaction.
*/
typedef struct svn_branch_txn_priv_t svn_branch_txn_priv_t;
@@ -132,9 +136,14 @@ typedef struct svn_branch_txn_priv_t svn
*/
typedef struct svn_branch_txn_t
{
- /* Private methods and data. */
+ /* Methods (conceptually public, but called indirectly). */
+ svn_branch_txn_vtable_t *vtable;
+
+ /* Private data. */
svn_branch_txn_priv_t *priv;
+ /* Public data. */
+
/* The repository in which this revision exists. */
svn_branch_repos_t *repos;
@@ -247,7 +256,11 @@ svn_branch_txn_finalize_eids(svn_branch_
* ...
*/
-/* Private methods and data for a branch state.
+/* Methods (conceptually public, but called indirectly) for a branch state.
+ */
+typedef struct svn_branch_state_vtable_t svn_branch_state_vtable_t;
+
+/* Private data for a branch state.
*/
typedef struct svn_branch_state_priv_t svn_branch_state_priv_t;
@@ -257,9 +270,14 @@ typedef struct svn_branch_state_priv_t s
*/
struct svn_branch_state_t
{
- /* Private methods and data. */
+ /* Methods (conceptually public, but called indirectly). */
+ svn_branch_state_vtable_t *vtable;
+
+ /* Private data. */
svn_branch_state_priv_t *priv;
+ /* Public data. */
+
/* The branch identifier (starting with 'B') */
const char *bid;
Modified: subversion/branches/move-tracking-2/subversion/libsvn_delta/branch.c
URL: http://svn.apache.org/viewvc/subversion/branches/move-tracking-2/subversion/libsvn_delta/branch.c?rev=1709565&r1=1709564&r2=1709565&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/libsvn_delta/branch.c (original)
+++ subversion/branches/move-tracking-2/subversion/libsvn_delta/branch.c Tue Oct 20 10:54:14 2015
@@ -52,6 +52,20 @@
(strcmp(svn_branch_get_id(branch1, scratch_pool), \
svn_branch_get_id(branch2, scratch_pool)) == 0)
+struct svn_branch_txn_priv_t
+{
+ /* All branches. */
+ apr_array_header_t *branches;
+
+};
+
+struct svn_branch_state_priv_t
+{
+ /* EID -> svn_branch_el_rev_content_t mapping. */
+ svn_element_tree_t *element_tree;
+
+};
+
/* */
static apr_pool_t *
branch_state_pool_get(svn_branch_state_t *branch)
@@ -211,8 +225,10 @@ svn_branch_txn_new_eid(svn_branch_txn_t
int *new_eid_p,
apr_pool_t *scratch_pool)
{
- SVN_ERR(txn->priv->new_eid(txn, new_eid_p, txn->priv->vpriv.scratch_pool));
- svn_pool_clear(txn->priv->vpriv.scratch_pool); /* ### assumes no recursion */
+ SVN_ERR(txn->vtable->new_eid(txn,
+ new_eid_p,
+ txn->vtable->vpriv.scratch_pool));
+ svn_pool_clear(txn->vtable->vpriv.scratch_pool); /* ### assumes no recursion */
return SVN_NO_ERROR;
}
@@ -226,10 +242,12 @@ svn_branch_txn_open_branch(svn_branch_tx
apr_pool_t *result_pool,
apr_pool_t *scratch_pool)
{
- SVN_ERR(txn->priv->open_branch(txn, new_branch_id_p,
- predecessor, outer_branch_id, outer_eid, root_eid,
- result_pool, txn->priv->vpriv.scratch_pool));
- svn_pool_clear(txn->priv->vpriv.scratch_pool); /* ### assumes no recursion */
+ SVN_ERR(txn->vtable->open_branch(txn,
+ new_branch_id_p,
+ predecessor, outer_branch_id, outer_eid,
+ root_eid, result_pool,
+ txn->vtable->vpriv.scratch_pool));
+ svn_pool_clear(txn->vtable->vpriv.scratch_pool); /* ### assumes no recursion */
return SVN_NO_ERROR;
}
@@ -242,10 +260,11 @@ svn_branch_txn_branch(svn_branch_txn_t *
apr_pool_t *result_pool,
apr_pool_t *scratch_pool)
{
- SVN_ERR(txn->priv->branch(txn, new_branch_id_p,
- from, outer_branch_id, outer_eid,
- result_pool, txn->priv->vpriv.scratch_pool));
- svn_pool_clear(txn->priv->vpriv.scratch_pool); /* ### assumes no recursion */
+ SVN_ERR(txn->vtable->branch(txn,
+ new_branch_id_p,
+ from, outer_branch_id, outer_eid, result_pool,
+ txn->vtable->vpriv.scratch_pool));
+ svn_pool_clear(txn->vtable->vpriv.scratch_pool); /* ### assumes no recursion */
return SVN_NO_ERROR;
}
@@ -253,15 +272,16 @@ svn_error_t *
svn_branch_txn_sequence_point(svn_branch_txn_t *txn,
apr_pool_t *scratch_pool)
{
- SVN_ERR(txn->priv->sequence_point(txn, txn->priv->vpriv.scratch_pool));
- svn_pool_clear(txn->priv->vpriv.scratch_pool); /* ### assumes no recursion */
+ SVN_ERR(txn->vtable->sequence_point(txn,
+ txn->vtable->vpriv.scratch_pool));
+ svn_pool_clear(txn->vtable->vpriv.scratch_pool); /* ### assumes no recursion */
return SVN_NO_ERROR;
}
static svn_branch_txn_t *
branch_txn_create(apr_pool_t *result_pool)
{
- static const svn_branch_txn_priv_t vtable = {
+ static const svn_branch_txn_vtable_t vtable = {
{0},
branch_txn_new_eid,
branch_txn_open_branch,
@@ -270,16 +290,16 @@ branch_txn_create(apr_pool_t *result_poo
};
svn_branch_txn_t *txn = apr_pcalloc(result_pool, sizeof(*txn));
- txn->priv = apr_pmemdup(result_pool, &vtable, sizeof(vtable));
+ txn->vtable = apr_pmemdup(result_pool, &vtable, sizeof(vtable));
- txn->priv->vpriv.cancel_func = NULL;
- txn->priv->vpriv.cancel_baton = NULL;
- txn->priv->vpriv.scratch_pool = svn_pool_create(result_pool);
+ txn->vtable->vpriv.cancel_func = NULL;
+ txn->vtable->vpriv.cancel_baton = NULL;
+ txn->vtable->vpriv.scratch_pool = svn_pool_create(result_pool);
#ifdef ENABLE_ORDERING_CHECK
- txn->priv->vpriv.within_callback = FALSE;
- txn->priv->vpriv.finished = FALSE;
- txn->priv->vpriv.state_pool = result_pool;
+ txn->vtable->vpriv.within_callback = FALSE;
+ txn->vtable->vpriv.finished = FALSE;
+ txn->vtable->vpriv.state_pool = result_pool;
#endif
return txn;
@@ -293,6 +313,7 @@ svn_branch_txn_create(svn_branch_repos_t
{
svn_branch_txn_t *txn = branch_txn_create(result_pool);
+ txn->priv = apr_pcalloc(result_pool, sizeof(*txn->priv));
txn->repos = repos;
txn->rev = rev;
txn->base_rev = base_rev;
@@ -974,10 +995,10 @@ svn_branch_state_alter_one(svn_branch_st
const svn_element_payload_t *new_payload,
apr_pool_t *scratch_pool)
{
- SVN_ERR(branch->priv->alter_one(branch,
- eid, new_parent_eid, new_name, new_payload,
- branch->priv->vpriv.scratch_pool));
- svn_pool_clear(branch->priv->vpriv.scratch_pool); /* ### assumes no recursion */
+ SVN_ERR(branch->vtable->alter_one(branch,
+ eid, new_parent_eid, new_name, new_payload,
+ branch->vtable->vpriv.scratch_pool));
+ svn_pool_clear(branch->vtable->vpriv.scratch_pool); /* ### assumes no recursion */
return SVN_NO_ERROR;
}
@@ -988,10 +1009,10 @@ svn_branch_state_copy_tree(svn_branch_st
const char *new_name,
apr_pool_t *scratch_pool)
{
- SVN_ERR(branch->priv->copy_tree(branch,
- src_el_rev, new_parent_eid, new_name,
- branch->priv->vpriv.scratch_pool));
- svn_pool_clear(branch->priv->vpriv.scratch_pool); /* ### assumes no recursion */
+ SVN_ERR(branch->vtable->copy_tree(branch,
+ src_el_rev, new_parent_eid, new_name,
+ branch->vtable->vpriv.scratch_pool));
+ svn_pool_clear(branch->vtable->vpriv.scratch_pool); /* ### assumes no recursion */
return SVN_NO_ERROR;
}
@@ -1000,10 +1021,10 @@ svn_branch_state_delete_one(svn_branch_s
svn_branch_eid_t eid,
apr_pool_t *scratch_pool)
{
- SVN_ERR(branch->priv->delete_one(branch,
- eid,
- branch->priv->vpriv.scratch_pool));
- svn_pool_clear(branch->priv->vpriv.scratch_pool); /* ### assumes no recursion */
+ SVN_ERR(branch->vtable->delete_one(branch,
+ eid,
+ branch->vtable->vpriv.scratch_pool));
+ svn_pool_clear(branch->vtable->vpriv.scratch_pool); /* ### assumes no recursion */
return SVN_NO_ERROR;
}
@@ -1011,16 +1032,16 @@ svn_error_t *
svn_branch_state_purge(svn_branch_state_t *branch,
apr_pool_t *scratch_pool)
{
- SVN_ERR(branch->priv->purge(branch,
- branch->priv->vpriv.scratch_pool));
- svn_pool_clear(branch->priv->vpriv.scratch_pool); /* ### assumes no recursion */
+ SVN_ERR(branch->vtable->purge(branch,
+ branch->vtable->vpriv.scratch_pool));
+ svn_pool_clear(branch->vtable->vpriv.scratch_pool); /* ### assumes no recursion */
return SVN_NO_ERROR;
}
static svn_branch_state_t *
branch_state_create(apr_pool_t *result_pool)
{
- static const svn_branch_state_priv_t vtable = {
+ static const svn_branch_state_vtable_t vtable = {
{0},
branch_state_alter,
branch_state_copy_one,
@@ -1031,16 +1052,16 @@ branch_state_create(apr_pool_t *result_p
};
svn_branch_state_t *b = apr_pcalloc(result_pool, sizeof(*b));
- b->priv = apr_pmemdup(result_pool, &vtable, sizeof(vtable));
+ b->vtable = apr_pmemdup(result_pool, &vtable, sizeof(vtable));
- b->priv->vpriv.cancel_func = NULL;
- b->priv->vpriv.cancel_baton = NULL;
- b->priv->vpriv.scratch_pool = svn_pool_create(result_pool);
+ b->vtable->vpriv.cancel_func = NULL;
+ b->vtable->vpriv.cancel_baton = NULL;
+ b->vtable->vpriv.scratch_pool = svn_pool_create(result_pool);
#ifdef ENABLE_ORDERING_CHECK
- b->priv->vpriv.within_callback = FALSE;
- b->priv->vpriv.finished = FALSE;
- b->priv->vpriv.state_pool = result_pool;
+ b->vtable->vpriv.within_callback = FALSE;
+ b->vtable->vpriv.finished = FALSE;
+ b->vtable->vpriv.state_pool = result_pool;
#endif
return b;
@@ -1055,6 +1076,7 @@ svn_branch_state_create(const char *bid,
{
svn_branch_state_t *b = branch_state_create(result_pool);
+ b->priv = apr_pcalloc(result_pool, sizeof(*b->priv));
b->bid = apr_pstrdup(result_pool, bid);
b->predecessor = svn_branch_rev_bid_dup(predecessor, result_pool);
b->txn = txn;
Modified: subversion/branches/move-tracking-2/subversion/libsvn_delta/branch_private.h
URL: http://svn.apache.org/viewvc/subversion/branches/move-tracking-2/subversion/libsvn_delta/branch_private.h?rev=1709565&r1=1709564&r2=1709565&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/libsvn_delta/branch_private.h (original)
+++ subversion/branches/move-tracking-2/subversion/libsvn_delta/branch_private.h Tue Oct 20 10:54:14 2015
@@ -84,7 +84,7 @@ typedef svn_error_t *(*branch_txn_v_sequ
svn_branch_txn_t *txn,
apr_pool_t *scratch_pool);
-struct svn_branch_txn_priv_t
+struct svn_branch_txn_vtable_t
{
svn_vtable_priv_t vpriv;
@@ -94,9 +94,6 @@ struct svn_branch_txn_priv_t
branch_txn_v_branch_t branch;
branch_txn_v_sequence_point_t sequence_point;
- /* All branches. */
- apr_array_header_t *branches;
-
};
/* The methods of svn_branch_state_t.
@@ -141,7 +138,7 @@ typedef svn_error_t *(*branch_state_v_pu
svn_branch_state_t *branch,
apr_pool_t *scratch_pool);
-struct svn_branch_state_priv_t
+struct svn_branch_state_vtable_t
{
svn_vtable_priv_t vpriv;
@@ -152,9 +149,6 @@ struct svn_branch_state_priv_t
branch_state_v_payload_resolve_t payload_resolve;
branch_state_v_purge_t purge;
- /* EID -> svn_branch_el_rev_content_t mapping. */
- svn_element_tree_t *element_tree;
-
};