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/09/30 13:24:05 UTC
svn commit: r1706000 - in /subversion/branches/move-tracking-2/subversion:
include/private/svn_editor3e.h libsvn_delta/compat3e.c
libsvn_delta/editor3e.c svnmover/svnmover.c
Author: julianfoad
Date: Wed Sep 30 11:24:04 2015
New Revision: 1706000
URL: http://svn.apache.org/viewvc?rev=1706000&view=rev
Log:
On the 'move-tracking-2' branch: Add a 'branch' method to the editor and use
it instead of direct access to the branch API.
* subversion/include/private/svn_editor3e.h
(svn_editor3_branch,
svn_editor3_cb_branch_t): New.
(svn_editor3_cb_funcs_t): Add the method to the vtable.
* subversion/libsvn_delta/editor3e.c
(svn_editor3_branch,
wrap_branch,
change_detection_branch): New.
(svn_editor3__get_debug_editor,
svn_editor3__change_detection_editor): Add the method to the vtable.
* subversion/libsvn_delta/compat3e.c
(branch_in_rev_or_txn): New, factored out...
(editor3_copy_tree): ... from here.
(editor3_branch): New.
(svn_editor3_in_memory,
svn_editor3__ev3_from_delta_for_commit): Add the method to the vtable.
* subversion/svnmover/svnmover.c
(do_branch,
do_topbranch): Use the method.
(do_branch_and_delete,
execute): Track the changes to do_branch() and do_topbranch().
Modified:
subversion/branches/move-tracking-2/subversion/include/private/svn_editor3e.h
subversion/branches/move-tracking-2/subversion/libsvn_delta/compat3e.c
subversion/branches/move-tracking-2/subversion/libsvn_delta/editor3e.c
subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c
Modified: subversion/branches/move-tracking-2/subversion/include/private/svn_editor3e.h
URL: http://svn.apache.org/viewvc/subversion/branches/move-tracking-2/subversion/include/private/svn_editor3e.h?rev=1706000&r1=1705999&r2=1706000&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/include/private/svn_editor3e.h (original)
+++ subversion/branches/move-tracking-2/subversion/include/private/svn_editor3e.h Wed Sep 30 11:24:04 2015
@@ -617,6 +617,13 @@ svn_editor3_open_branch(svn_editor3_t *e
int outer_eid,
int root_eid,
apr_pool_t *result_pool);
+svn_error_t *
+svn_editor3_branch(svn_editor3_t *editor,
+ const char **new_branch_id_p,
+ svn_branch_rev_bid_eid_t *from,
+ const char *outer_branch_id,
+ int outer_eid,
+ apr_pool_t *result_pool);
/** Specify the tree position and payload of the element of @a branch_id
* identified by @a eid.
@@ -864,6 +871,17 @@ typedef svn_error_t *(*svn_editor3_cb_op
apr_pool_t *result_pool,
apr_pool_t *scratch_pool);
+/** @see svn_editor3_branch(), #svn_editor3_t
+ */
+typedef svn_error_t *(*svn_editor3_cb_branch_t)(
+ void *baton,
+ const char **new_branch_id_p,
+ svn_branch_rev_bid_eid_t *from,
+ const char *outer_branch_id,
+ int outer_eid,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool);
+
/** @see svn_editor3_alter(), #svn_editor3_t
*/
typedef svn_error_t *(*svn_editor3_cb_alter_t)(
@@ -949,6 +967,7 @@ typedef struct svn_editor3_cb_funcs_t
{
svn_editor3_cb_new_eid_t cb_new_eid;
svn_editor3_cb_open_branch_t cb_open_branch;
+ svn_editor3_cb_branch_t cb_branch;
svn_editor3_cb_alter_t cb_alter;
svn_editor3_cb_copy_one_t cb_copy_one;
svn_editor3_cb_copy_tree_t cb_copy_tree;
Modified: subversion/branches/move-tracking-2/subversion/libsvn_delta/compat3e.c
URL: http://svn.apache.org/viewvc/subversion/branches/move-tracking-2/subversion/libsvn_delta/compat3e.c?rev=1706000&r1=1705999&r2=1706000&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/libsvn_delta/compat3e.c (original)
+++ subversion/branches/move-tracking-2/subversion/libsvn_delta/compat3e.c Wed Sep 30 11:24:04 2015
@@ -1034,6 +1034,31 @@ storage_pathrev_from_branch_ref(svn_path
*/
/* */
+static svn_error_t *
+branch_in_rev_or_txn(svn_branch_state_t **src_branch,
+ const svn_branch_rev_bid_eid_t *src_el_rev,
+ ev3_from_delta_baton_t *eb,
+ apr_pool_t *result_pool)
+{
+ if (SVN_IS_VALID_REVNUM(src_el_rev->rev))
+ {
+ SVN_ERR(svn_branch_repos_get_branch_by_id(src_branch,
+ eb->edited_rev_root->repos,
+ src_el_rev->rev,
+ src_el_rev->bid,
+ result_pool));
+ }
+ else
+ {
+ *src_branch
+ = svn_branch_revision_root_get_branch_by_id(
+ eb->edited_rev_root, src_el_rev->bid, result_pool);
+ }
+
+ return SVN_NO_ERROR;
+}
+
+/* */
#define PAYLOAD_IS_ONLY_BY_REFERENCE(payload) \
((payload)->kind == svn_node_unknown)
@@ -1185,6 +1210,49 @@ editor3_open_branch(void *baton,
/* An #svn_editor3_t method. */
static svn_error_t *
+editor3_branch(void *baton,
+ const char **new_branch_id_p,
+ svn_branch_rev_bid_eid_t *from,
+ const char *outer_branch_id,
+ int outer_eid,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool)
+{
+ ev3_from_delta_baton_t *eb = baton;
+ svn_branch_state_t *new_branch;
+ svn_branch_state_t *outer_branch = NULL;
+ svn_branch_state_t *from_branch;
+ svn_branch_subtree_t *from_subtree;
+
+ SVN_ERR(branch_in_rev_or_txn(&from_branch, from, eb, scratch_pool));
+ from_subtree = svn_branch_get_subtree(from_branch, from->eid, scratch_pool);
+
+ /* Source element must exist */
+ if (! from_subtree)
+ {
+ return svn_error_createf(SVN_ERR_BRANCHING, NULL,
+ _("Cannot branch from r%ld %s e%d: "
+ "does not exist"),
+ from->rev, from->bid, from->eid);
+ }
+
+ if (outer_branch_id)
+ outer_branch = svn_branch_revision_root_get_branch_by_id(
+ eb->edited_rev_root, outer_branch_id, scratch_pool);
+ new_branch = svn_branch_add_new_branch(eb->edited_rev_root,
+ outer_branch, outer_eid,
+ from->eid, scratch_pool);
+
+ /* Populate the mapping from the 'from' source */
+ SVN_ERR(svn_branch_instantiate_subtree(new_branch, -1, "", *from_subtree,
+ scratch_pool));
+
+ *new_branch_id_p = svn_branch_get_id(new_branch, result_pool);
+ return SVN_NO_ERROR;
+}
+
+/* An #svn_editor3_t method. */
+static svn_error_t *
editor3_alter(void *baton,
const char *branch_id,
svn_branch_eid_t eid,
@@ -1306,20 +1374,7 @@ editor3_copy_tree(void *baton,
SVN_DBG(("copy_tree(e%d -> e%d/%s)",
src_el_rev->eid, new_parent_eid, new_name));
- if (SVN_IS_VALID_REVNUM(src_el_rev->rev))
- {
- SVN_ERR(svn_branch_repos_get_branch_by_id(&src_branch,
- eb->edited_rev_root->repos,
- src_el_rev->rev,
- src_el_rev->bid,
- scratch_pool));
- }
- else
- {
- src_branch
- = svn_branch_revision_root_get_branch_by_id(
- eb->edited_rev_root, src_el_rev->bid, scratch_pool);
- }
+ SVN_ERR(branch_in_rev_or_txn(&src_branch, src_el_rev, eb, scratch_pool));
from_el_rev = svn_branch_el_rev_id_create(src_branch, src_el_rev->eid,
src_el_rev->rev, scratch_pool);
SVN_ERR(copy_subtree(from_el_rev,
@@ -1974,6 +2029,7 @@ svn_editor3_in_memory(svn_editor3_t **ed
static const svn_editor3_cb_funcs_t editor_funcs = {
editor3_new_eid,
editor3_open_branch,
+ editor3_branch,
editor3_alter,
editor3_copy_one,
editor3_copy_tree,
@@ -2017,6 +2073,7 @@ svn_editor3__ev3_from_delta_for_commit(
static const svn_editor3_cb_funcs_t editor_funcs = {
editor3_new_eid,
editor3_open_branch,
+ editor3_branch,
editor3_alter,
editor3_copy_one,
editor3_copy_tree,
Modified: subversion/branches/move-tracking-2/subversion/libsvn_delta/editor3e.c
URL: http://svn.apache.org/viewvc/subversion/branches/move-tracking-2/subversion/libsvn_delta/editor3e.c?rev=1706000&r1=1705999&r2=1706000&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/libsvn_delta/editor3e.c (original)
+++ subversion/branches/move-tracking-2/subversion/libsvn_delta/editor3e.c Wed Sep 30 11:24:04 2015
@@ -222,6 +222,23 @@ svn_editor3_open_branch(svn_editor3_t *e
}
svn_error_t *
+svn_editor3_branch(svn_editor3_t *editor,
+ const char **new_branch_id_p,
+ svn_branch_rev_bid_eid_t *from,
+ const char *outer_branch_id,
+ int outer_eid,
+ apr_pool_t *result_pool)
+{
+ SVN_ERR_ASSERT(VALID_EID(outer_eid));
+
+ DO_CALLBACK(editor, cb_branch,
+ 5(new_branch_id_p, from, outer_branch_id, outer_eid,
+ result_pool));
+
+ return SVN_NO_ERROR;
+}
+
+svn_error_t *
svn_editor3_alter(svn_editor3_t *editor,
const char *branch_id,
svn_branch_eid_t eid,
@@ -448,6 +465,26 @@ wrap_open_branch(void *baton,
}
static svn_error_t *
+wrap_branch(void *baton,
+ const char **new_branch_id_p,
+ svn_branch_rev_bid_eid_t *from,
+ const char *outer_branch_id,
+ int outer_eid,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool)
+{
+ wrapper_baton_t *eb = baton;
+
+ /*dbg(eb, scratch_pool, "%s : open_branch(...)",
+ eid_str(eid, scratch_pool), ...);*/
+ SVN_ERR(svn_editor3_branch(eb->wrapped_editor,
+ new_branch_id_p,
+ from, outer_branch_id, outer_eid,
+ result_pool));
+ return SVN_NO_ERROR;
+}
+
+static svn_error_t *
wrap_alter(void *baton,
const char *branch_id,
svn_branch_eid_t eid,
@@ -578,6 +615,7 @@ svn_editor3__get_debug_editor(svn_editor
static const svn_editor3_cb_funcs_t wrapper_funcs = {
wrap_new_eid,
wrap_open_branch,
+ wrap_branch,
wrap_alter,
wrap_copy_one,
wrap_copy_tree,
@@ -655,6 +693,24 @@ change_detection_open_branch(void *baton
}
static svn_error_t *
+change_detection_branch(void *baton,
+ const char **new_branch_id_p,
+ svn_branch_rev_bid_eid_t *from,
+ const char *outer_branch_id,
+ int outer_eid,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool)
+{
+ change_detection_baton_t *eb = baton;
+
+ SVN_ERR(svn_editor3_branch(eb->wrapped_editor,
+ new_branch_id_p,
+ from, outer_branch_id, outer_eid,
+ result_pool));
+ return SVN_NO_ERROR;
+}
+
+static svn_error_t *
change_detection_alter(void *baton,
const char *branch_id,
svn_branch_eid_t eid,
@@ -774,6 +830,7 @@ svn_editor3__change_detection_editor(svn
static const svn_editor3_cb_funcs_t wrapper_funcs = {
change_detection_new_eid,
change_detection_open_branch,
+ change_detection_branch,
change_detection_alter,
change_detection_copy_one,
change_detection_copy_tree,
Modified: subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c
URL: http://svn.apache.org/viewvc/subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c?rev=1706000&r1=1705999&r2=1706000&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c (original)
+++ subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c Wed Sep 30 11:24:04 2015
@@ -2326,82 +2326,52 @@ mk_branch(const char **new_branch_id_p,
* and NEW_NAME must be nonexistent in that directory.
*/
static svn_error_t *
-do_branch(svn_branch_state_t **new_branch_p,
+do_branch(const char **new_branch_id_p,
svn_editor3_t *editor,
- svn_branch_state_t *from_branch,
- int from_eid,
+ svn_branch_rev_bid_eid_t *from,
svn_branch_state_t *to_outer_branch,
svn_branch_eid_t to_outer_parent_eid,
const char *new_name,
+ apr_pool_t *result_pool,
apr_pool_t *scratch_pool)
{
const char *to_outer_branch_id
= to_outer_branch ? svn_branch_get_id(to_outer_branch, scratch_pool) : NULL;
- svn_branch_subtree_t *from_subtree;
int to_outer_eid;
- /* Source element must exist */
- if (! svn_branch_get_path_by_eid(from_branch, from_eid, scratch_pool))
- {
- return svn_error_createf(SVN_ERR_BRANCHING, NULL,
- _("Cannot branch from %s e%d: "
- "does not exist"),
- svn_branch_get_id(
- from_branch, scratch_pool), from_eid);
- }
-
- /* Fetch the subtree to be branched before creating the new subbranch root
- element, as we don't want to recurse (endlessly) into that in the case
- where it is an immediate subbranch of FROM_BRANCH. */
- from_subtree = svn_branch_get_subtree(from_branch, from_eid, scratch_pool);
-
/* assign new eid to root element (outer branch) */
SVN_ERR(svn_editor3_new_eid(editor, &to_outer_eid));
+
+ SVN_ERR(svn_editor3_branch(editor, new_branch_id_p,
+ from, to_outer_branch_id, to_outer_eid,
+ result_pool));
+
SVN_ERR(svn_editor3_alter(editor,
to_outer_branch_id, to_outer_eid,
to_outer_parent_eid, new_name, NULL));
- SVN_ERR(svn_branch_branch_subtree(new_branch_p,
- *from_subtree,
- to_outer_branch->rev_root,
- to_outer_branch, to_outer_eid,
- scratch_pool));
- notify_v("A+ %s%s",
+ notify_v("A+ %s (branch %s)",
svn_branch_get_path_by_eid(to_outer_branch, to_outer_eid,
scratch_pool),
- branch_str(*new_branch_p, scratch_pool));
+ *new_branch_id_p);
return SVN_NO_ERROR;
}
static svn_error_t *
-do_topbranch(svn_branch_state_t **new_branch_p,
- svn_branch_revision_root_t *rev_root,
- svn_branch_state_t *from_branch,
- int from_eid,
+do_topbranch(const char **new_branch_id_p,
+ svn_editor3_t *editor,
+ svn_branch_rev_bid_eid_t *from,
+ apr_pool_t *result_pool,
apr_pool_t *scratch_pool)
{
- svn_branch_subtree_t *from_subtree;
-
- /* Source element must exist */
- if (! svn_branch_get_path_by_eid(from_branch, from_eid, scratch_pool))
- {
- return svn_error_createf(SVN_ERR_BRANCHING, NULL,
- _("Cannot branch from %s e%d: "
- "does not exist"),
- svn_branch_get_id(
- from_branch, scratch_pool), from_eid);
- }
+ SVN_ERR(svn_editor3_branch(editor, new_branch_id_p,
+ from,
+ NULL, 0, /*outer_branch,outer_eid*/
+ result_pool));
- from_subtree = svn_branch_get_subtree(from_branch, from_eid, scratch_pool);
-
- SVN_ERR(svn_branch_branch_subtree(new_branch_p,
- *from_subtree,
- rev_root,
- NULL, 0, /*outer_branch,outer_eid*/
- scratch_pool));
- notify_v("A+ %s",
- branch_str(*new_branch_p, scratch_pool));
+ notify_v("A+ (branch %s)",
+ *new_branch_id_p);
return SVN_NO_ERROR;
}
@@ -2484,13 +2454,18 @@ do_branch_and_delete(svn_editor3_t *edit
const char *to_name,
apr_pool_t *scratch_pool)
{
- svn_branch_state_t *new_branch;
+ const char *from_branch_id = svn_branch_get_id(el_rev->branch,
+ scratch_pool);
+ svn_branch_rev_bid_eid_t *from
+ = svn_branch_rev_bid_eid_create(el_rev->rev, from_branch_id,
+ el_rev->eid, scratch_pool);
+ const char *new_branch_id;
SVN_ERR_ASSERT(! is_branch_root_element(el_rev->branch, el_rev->eid));
- SVN_ERR(do_branch(&new_branch, editor, el_rev->branch, el_rev->eid,
+ SVN_ERR(do_branch(&new_branch_id, editor, from,
to_outer_branch, to_outer_parent_eid, to_name,
- scratch_pool));
+ scratch_pool, scratch_pool));
SVN_ERR(do_delete(editor, el_rev->branch, el_rev->eid, scratch_pool));
@@ -3128,15 +3103,21 @@ execute(svnmover_wc_t *wc,
case ACTION_TBRANCH:
VERIFY_EID_EXISTS("tbranch", 0);
{
- svn_branch_state_t *new_branch;
-
- SVN_ERR(do_topbranch(&new_branch,
- wc->working->branch->rev_root,
- arg[0]->el_rev->branch, arg[0]->el_rev->eid,
- iterpool));
+ const char *from_branch_id = svn_branch_get_id(arg[0]->el_rev->branch,
+ iterpool);
+ svn_branch_rev_bid_eid_t *from
+ = svn_branch_rev_bid_eid_create(arg[0]->el_rev->rev, from_branch_id,
+ arg[0]->el_rev->eid, iterpool);
+ const char *new_branch_id;
+
+ SVN_ERR(do_topbranch(&new_branch_id, editor,
+ from,
+ iterpool, iterpool));
/* Switch the WC working state to this new branch */
- wc->working->branch_id = svn_branch_get_id(new_branch, wc->pool);
- wc->working->branch = new_branch;
+ wc->working->branch_id = new_branch_id;
+ wc->working->branch
+ = svn_branch_revision_root_get_branch_by_id(
+ wc->working->branch->rev_root, new_branch_id, iterpool);
}
break;
@@ -3146,13 +3127,18 @@ execute(svnmover_wc_t *wc,
VERIFY_EID_NONEXISTENT("branch", 1);
VERIFY_PARENT_EID_EXISTS("branch", 1);
{
- svn_branch_state_t *new_branch;
+ const char *from_branch_id = svn_branch_get_id(arg[0]->el_rev->branch,
+ iterpool);
+ svn_branch_rev_bid_eid_t *from
+ = svn_branch_rev_bid_eid_create(arg[0]->el_rev->rev, from_branch_id,
+ arg[0]->el_rev->eid, iterpool);
+ const char *new_branch_id;
- SVN_ERR(do_branch(&new_branch, editor,
- arg[0]->el_rev->branch, arg[0]->el_rev->eid,
+ SVN_ERR(do_branch(&new_branch_id, editor,
+ from,
arg[1]->el_rev->branch, arg[1]->parent_el_rev->eid,
arg[1]->path_name,
- iterpool));
+ iterpool, iterpool));
}
break;