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/01 11:40:26 UTC
svn commit: r1706209 - in /subversion/branches/move-tracking-2/subversion:
include/private/svn_branch.h libsvn_delta/branch.c libsvn_delta/compat3e.c
libsvn_delta/editor3e.c svnmover/svnmover.c
Author: julianfoad
Date: Thu Oct 1 09:40:26 2015
New Revision: 1706209
URL: http://svn.apache.org/viewvc?rev=1706209&view=rev
Log:
On the 'move-tracking-2' branch: Some tidying up.
* subversion/include/private/svn_branch.h,
subversion/libsvn_delta/branch.c
(svn_branch_id_nest): New.
(svn_branch_id_unnest): Rename from 'svn_branch_id_split'. Move the doc
string to the declaration.
(svn_branch_branch_subtree): Delete.
(svn_branch_rev_bid_eid_dup): Allow a null input.
(svn_branch_instantiate_subtree): Avoid using svn_branch_branch_subtree().
(svn_branch_state_parse): Track the rename.
* subversion/libsvn_delta/compat3e.c
(editor3_open_branch): Use svn_branch_id_nest().
* subversion/libsvn_delta/editor3e.c
(svn_editor3_open_branch,
svn_editor3_branch): Allow the output pointer to be null.
* subversion/svnmover/svnmover.c
(subtree_subbranch_str): Use svn_branch_id_nest().
(merge_subbranch): Avoid using svn_branch_branch_subtree().
(branch_merge_subtree_r): Add comments.
(subtree_diff_r): Use svn_branch_id_nest().
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/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_branch.h
URL: http://svn.apache.org/viewvc/subversion/branches/move-tracking-2/subversion/include/private/svn_branch.h?rev=1706209&r1=1706208&r2=1706209&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 Thu Oct 1 09:40:26 2015
@@ -285,13 +285,35 @@ const char *
svn_branch_get_id(svn_branch_state_t *branch,
apr_pool_t *result_pool);
-/*
+/* Return the id of the branch nested in OUTER_BID at element OUTER_EID.
+ *
+ * For a top-level branch, OUTER_BID is null and OUTER_EID is the
+ * top-level branch number.
+ *
+ * (Such branches need not exist. This works purely with ids, making use
+ * of the fact that nested branch ids are predictable based on the nesting
+ * element id.)
+ */
+const char *
+svn_branch_id_nest(const char *outer_bid,
+ int outer_eid,
+ apr_pool_t *result_pool);
+
+/* Given a nested branch id BID, set *OUTER_BID to the outer branch's id
+ * and *OUTER_EID to the nesting element in the outer branch.
+ *
+ * For a top-level branch, set *OUTER_BID to NULL and *OUTER_EID to the
+ * top-level branch number.
+ *
+ * (Such branches need not exist. This works purely with ids, making use
+ * of the fact that nested branch ids are predictable based on the nesting
+ * element id.)
*/
void
-svn_branch_id_split(const char **outer_bid,
- int *outer_eid,
- const char *bid,
- apr_pool_t *result_pool);
+svn_branch_id_unnest(const char **outer_bid,
+ int *outer_eid,
+ const char *bid,
+ apr_pool_t *result_pool);
/* Create a new branch at OUTER_BRANCH:OUTER_EID, with no elements
* (not even a root element).
@@ -576,28 +598,6 @@ svn_branch_instantiate_subtree(svn_branc
svn_branch_subtree_t from_subtree,
apr_pool_t *scratch_pool);
-/* Create a new branch of a given subtree.
- *
- * Create a new branch object. Register its existence in REV_ROOT.
- * Instantiate the subtree FROM_SUBTREE in this new branch. In the new
- * branch, create new subbranches corresponding to any subbranches
- * specified in FROM_SUBTREE, recursively.
- *
- * If TO_OUTER_BRANCH is NULL, create a top-level branch with a new top-level
- * branch number, ignoring TO_OUTER_EID. Otherwise, create a branch that claims
- * to be nested under TO_OUTER_BRANCH:TO_OUTER_EID, but do not require that
- * a subbranch root element exists there, nor create one.
- *
- * Set *NEW_BRANCH_P to the new branch (the one at TO_OUTER_BRANCH:TO_OUTER_EID).
- */
-svn_error_t *
-svn_branch_branch_subtree(svn_branch_state_t **new_branch_p,
- svn_branch_subtree_t from_subtree,
- svn_branch_revision_root_t *rev_root,
- svn_branch_state_t *to_outer_branch,
- svn_branch_eid_t to_outer_eid,
- apr_pool_t *scratch_pool);
-
/* Create a copy of NEW_SUBTREE in TO_BRANCH.
*
* For each non-root element in NEW_SUBTREE, create a new element with
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=1706209&r1=1706208&r2=1706209&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/libsvn_delta/branch.c (original)
+++ subversion/branches/move-tracking-2/subversion/libsvn_delta/branch.c Thu Oct 1 09:40:26 2015
@@ -267,8 +267,12 @@ svn_branch_rev_bid_eid_t *
svn_branch_rev_bid_eid_dup(const svn_branch_rev_bid_eid_t *old_id,
apr_pool_t *result_pool)
{
- svn_branch_rev_bid_eid_t *id = apr_pmemdup(result_pool, old_id, sizeof(*id));
+ svn_branch_rev_bid_eid_t *id;
+ if (! old_id)
+ return NULL;
+
+ id = apr_pmemdup(result_pool, old_id, sizeof(*id));
id->bid = apr_pstrdup(result_pool, old_id->bid);
return id;
}
@@ -848,44 +852,22 @@ svn_branch_instantiate_subtree(svn_branc
{
int this_outer_eid = svn_int_hash_this_key(bi->apr_hi);
svn_branch_subtree_t *this_subtree = bi->val;
+ svn_branch_state_t *new_branch;
/* branch this subbranch into NEW_BRANCH (recursing) */
- SVN_ERR(svn_branch_branch_subtree(NULL,
- *this_subtree,
- to_branch->rev_root,
- to_branch, this_outer_eid,
- bi->iterpool));
+ new_branch = svn_branch_add_new_branch(to_branch->rev_root,
+ to_branch, this_outer_eid,
+ this_subtree->root_eid,
+ bi->iterpool);
+
+ SVN_ERR(svn_branch_instantiate_subtree(new_branch, -1, "", *this_subtree,
+ bi->iterpool));
}
}
return SVN_NO_ERROR;
}
-svn_error_t *
-svn_branch_branch_subtree(svn_branch_state_t **new_branch_p,
- svn_branch_subtree_t from_subtree,
- svn_branch_revision_root_t *rev_root,
- svn_branch_state_t *to_outer_branch,
- svn_branch_eid_t to_outer_eid,
- apr_pool_t *scratch_pool)
-{
- svn_branch_state_t *new_branch;
-
- /* create new branch */
- new_branch = svn_branch_add_new_branch(rev_root,
- to_outer_branch, to_outer_eid,
- from_subtree.root_eid,
- scratch_pool);
-
- /* Populate the new branch mapping */
- SVN_ERR(svn_branch_instantiate_subtree(new_branch, -1, "", from_subtree,
- scratch_pool));
-
- if (new_branch_p)
- *new_branch_p = new_branch;
- return SVN_NO_ERROR;
-}
-
apr_array_header_t *
svn_branch_get_immediate_subbranches(const svn_branch_state_t *branch,
apr_pool_t *result_pool,
@@ -1080,17 +1062,22 @@ parse_element_line(int *eid_p,
return SVN_NO_ERROR;
}
-/* Set *OUTER_BID to the outer branch's id and *OUTER_EID to this branch's
- * outer EID.
- *
- * For a top-level branch, set *OUTER_BID to NULL and *OUTER_EID to the
- * top-level branch number.
- */
+const char *
+svn_branch_id_nest(const char *outer_bid,
+ int outer_eid,
+ apr_pool_t *result_pool)
+{
+ if (!outer_bid)
+ return apr_psprintf(result_pool, "B%d", outer_eid);
+
+ return apr_psprintf(result_pool, "%s.%d", outer_bid, outer_eid);
+}
+
void
-svn_branch_id_split(const char **outer_bid,
- int *outer_eid,
- const char *bid,
- apr_pool_t *result_pool)
+svn_branch_id_unnest(const char **outer_bid,
+ int *outer_eid,
+ const char *bid,
+ apr_pool_t *result_pool)
{
char *last_dot = strrchr(bid, '.');
@@ -1130,7 +1117,7 @@ svn_branch_state_parse(svn_branch_state_
{
const char *outer_bid;
- svn_branch_id_split(&outer_bid, &outer_eid, bid, scratch_pool);
+ svn_branch_id_unnest(&outer_bid, &outer_eid, bid, scratch_pool);
if (outer_bid)
{
outer_branch
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=1706209&r1=1706208&r2=1706209&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/libsvn_delta/compat3e.c (original)
+++ subversion/branches/move-tracking-2/subversion/libsvn_delta/compat3e.c Thu Oct 1 09:40:26 2015
@@ -1190,7 +1190,7 @@ editor3_open_branch(void *baton,
/* if the subbranch already exists, just return its bid */
*new_branch_id_p
- = apr_psprintf(result_pool, "%s.%d", outer_branch_id, outer_eid);
+ = svn_branch_id_nest(outer_branch_id, outer_eid, result_pool);
new_branch
= svn_branch_revision_root_get_branch_by_id(eb->edited_rev_root,
*new_branch_id_p,
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=1706209&r1=1706208&r2=1706209&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/libsvn_delta/editor3e.c (original)
+++ subversion/branches/move-tracking-2/subversion/libsvn_delta/editor3e.c Thu Oct 1 09:40:26 2015
@@ -211,13 +211,20 @@ svn_editor3_open_branch(svn_editor3_t *e
int root_eid,
apr_pool_t *result_pool)
{
+ const char *new_branch_id;
+
SVN_ERR_ASSERT(VALID_EID(outer_eid));
SVN_ERR_ASSERT(VALID_EID(root_eid));
DO_CALLBACK(editor, cb_open_branch,
- 5(new_branch_id_p, outer_branch_id, outer_eid, root_eid,
+ 5(&new_branch_id, outer_branch_id, outer_eid, root_eid,
result_pool));
+ /* We allow the output pointer to be null, here, so that implementations
+ may assume their output pointer is non-null. */
+ if (new_branch_id_p)
+ *new_branch_id_p = new_branch_id;
+
return SVN_NO_ERROR;
}
@@ -229,12 +236,19 @@ svn_editor3_branch(svn_editor3_t *editor
int outer_eid,
apr_pool_t *result_pool)
{
+ const char *new_branch_id;
+
SVN_ERR_ASSERT(VALID_EID(outer_eid));
DO_CALLBACK(editor, cb_branch,
- 5(new_branch_id_p, from, outer_branch_id, outer_eid,
+ 5(&new_branch_id, from, outer_branch_id, outer_eid,
result_pool));
+ /* We allow the output pointer to be null, here, so that implementations
+ may assume their output pointer is non-null. */
+ if (new_branch_id_p)
+ *new_branch_id_p = new_branch_id;
+
return SVN_NO_ERROR;
}
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=1706209&r1=1706208&r2=1706209&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c (original)
+++ subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c Thu Oct 1 09:40:26 2015
@@ -792,7 +792,8 @@ subtree_subbranch_str(svn_branch_subtree
if (subbranch)
return apr_psprintf(result_pool,
- " (branch %s.%d)", bid, eid);
+ " (branch %s)",
+ svn_branch_id_nest(bid, eid, result_pool));
return "";
}
@@ -1358,16 +1359,16 @@ merge_subbranch(svn_editor3_t *editor,
}
else if (subbr_src) /* added on source branch */
{
- svn_branch_subtree_t *from_subtree
- = svn_branch_get_subtree(src_subbranch,
- src_subbranch->root_eid,
- scratch_pool);
-
- SVN_ERR(svn_branch_branch_subtree(NULL,
- *from_subtree,
- tgt->branch->rev_root,
- tgt->branch, eid,
- scratch_pool));
+ svn_branch_rev_bid_eid_t *from
+ = svn_branch_rev_bid_eid_create(src_subbranch->rev_root->rev,
+ svn_branch_get_id(src_subbranch,
+ scratch_pool),
+ src_subbranch->root_eid,
+ scratch_pool);
+
+ SVN_ERR(svn_editor3_branch(editor, NULL /*new_branch_id_p*/, from,
+ svn_branch_get_id(tgt->branch, scratch_pool),
+ eid, scratch_pool));
}
else if (subbr_tgt) /* added on target branch */
{
@@ -1515,7 +1516,9 @@ branch_merge_subtree_r(svn_editor3_t *ed
TGT, YCA) exists, but we choose to skip it when SRC == YCA. */
if (! e_yca_src)
{
- /* Still need to merge subbranch */
+ /* Still need to merge any subbranch linked to this element.
+ There were no changes to the link element but that doesn't
+ mean there were no changes to the linked branch. */
SVN_ERR(merge_subbranch(editor, src, tgt, yca, eid, iterpool));
continue;
@@ -1553,6 +1556,10 @@ branch_merge_subtree_r(svn_editor3_t *ed
eid, e_yca->name,
subbranch_str(yca->branch, eid, iterpool));
SVN_ERR(svn_editor3_delete(editor, tgt_branch_id, eid));
+
+ /* ### If this is a subbranch-root element being deleted, shouldn't
+ we see if there were any changes to be merged in the subbranch,
+ and raise a delete-vs-edit conflict if so? */
}
else if (result)
{
@@ -1990,7 +1997,7 @@ subtree_diff_r(svn_editor3_t *editor,
const char *relpath
= svn_branch_subtree_get_path_by_eid(left, e, scratch_pool);
- sub_left_bid = apr_psprintf(scratch_pool, "%s.%d", left_bid, e);
+ sub_left_bid = svn_branch_id_nest(left_bid, e, scratch_pool);
sub_left_rrpath = svn_relpath_join(left_rrpath, relpath,
scratch_pool);
}
@@ -2004,7 +2011,7 @@ subtree_diff_r(svn_editor3_t *editor,
const char *relpath
= svn_branch_subtree_get_path_by_eid(right, e, scratch_pool);
- sub_right_bid = apr_psprintf(scratch_pool, "%s.%d", right_bid, e);
+ sub_right_bid = svn_branch_id_nest(right_bid, e, scratch_pool);
sub_right_rrpath = svn_relpath_join(right_rrpath, relpath,
scratch_pool);
}