Author: julianfoad
Date: Thu Feb 26 09:49:01 2015
New Revision: 1662400
URL: http://svn.apache.org/r1662400
Log:
On the 'move-tracking-2' branch: When a merge adds an element that is a
subbranch root, recursively add the nested branch(es) there.
Still to do: when a merge deletes or merges a subbranch root element, delete
or merge the nested branch(es) there.
* subversion/include/private/svn_editor3.h
(svn_branch_get_subbranch_at_eid,
svn_branch_branch_subtree_r2): New functions.
* subversion/libsvn_delta/branching.c
(svn_branch_get_subbranch_at_eid): Move from svnmover.c. Make public.
(svn_branch_branch_subtree_r2): Loosen the restrictions. Make public.
* subversion/svnmove/svnmover.c
(branch_merge_subtree_r): When adding an element, if it's a subbranch root,
branch the subbranch.
(svn_branch_get_subbranch_at_eid): Move to branching.c.
Modified:
subversion/branches/move-tracking-2/subversion/include/private/svn_editor3.h
subversion/branches/move-tracking-2/subversion/libsvn_delta/branching.c
subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c
Modified:
subversion/branches/move-tracking-2/subversion/include/private/svn_editor3.h
URL:
http://svn.apache.org/viewvc/subversion/branches/move-tracking-2/subversion/include/private/svn_editor3.h?rev=1662400&r1=1662399&r2=1662400&view=diff
==============================================================================
---
subversion/branches/move-tracking-2/subversion/include/private/svn_editor3.h
(original)
+++
subversion/branches/move-tracking-2/subversion/include/private/svn_editor3.h
Thu Feb 26 09:49:01 2015
@@ -1766,6 +1766,14 @@ svn_branch_get_all_sub_branches(const sv
apr_pool_t *result_pool,
apr_pool_t *scratch_pool);
+/* Return the subbranch instance rooted at BRANCH:EID, or NULL if that is
+ * not a subbranch root.
+ */
+svn_branch_instance_t *
+svn_branch_get_subbranch_at_eid(svn_branch_instance_t *branch,
+ int eid,
+ apr_pool_t *scratch_pool);
+
/* element */
/*
typedef struct svn_branch_element_t
@@ -1943,6 +1951,18 @@ svn_branch_branch_subtree_r(svn_branch_i
const char *new_name,
apr_pool_t *scratch_pool);
+/* Instantiate a new branch of FROM_BRANCH, selecting only the subtree at
+ * FROM_EID, at existing branch-root element TO_OUTER_BRANCH:TO_OUTER_EID.
+ */
+svn_error_t *
+svn_branch_branch_subtree_r2(svn_branch_instance_t **new_branch_p,
+ svn_branch_instance_t *from_branch,
+ int from_eid,
+ svn_branch_instance_t *to_outer_branch,
+ svn_editor3_eid_t to_outer_eid,
+ svn_branch_sibling_t *new_branch_def,
+ apr_pool_t *scratch_pool);
+
/* Copy a subtree.
*
* For each element that in FROM_BRANCH is a pathwise descendant of
Modified:
subversion/branches/move-tracking-2/subversion/libsvn_delta/branching.c
URL:
http://svn.apache.org/viewvc/subversion/branches/move-tracking-2/subversion/libsvn_delta/branching.c?rev=1662400&r1=1662399&r2=1662400&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/libsvn_delta/branching.c
(original)
+++ subversion/branches/move-tracking-2/subversion/libsvn_delta/branching.c Thu
Feb 26 09:49:01 2015
@@ -805,6 +805,30 @@ svn_branch_get_all_sub_branches(const sv
}
svn_branch_instance_t *
+svn_branch_get_subbranch_at_eid(svn_branch_instance_t *branch,
+ int eid,
+ apr_pool_t *scratch_pool)
+{
+ apr_array_header_t *subbranches;
+ int i;
+
+ /* TODO: more efficient to search in branch->rev_root->branch_instances */
+ subbranches = svn_branch_get_all_sub_branches(branch,
+ scratch_pool, scratch_pool);
+ for (i = 0; i < subbranches->nelts; i++)
+ {
+ svn_branch_instance_t *subbranch = APR_ARRAY_IDX(subbranches, i, void *);
+
+ if (subbranch->outer_eid == eid)
+ {
+ return subbranch;
+ }
+ }
+
+ return NULL;
+}
+
+svn_branch_instance_t *
svn_branch_add_new_branch_instance(svn_branch_instance_t *outer_branch,
int outer_eid,
svn_branch_sibling_t *branch_sibling,
@@ -1256,15 +1280,6 @@ svn_branch_repos_find_el_rev_by_path_rev
* ========================================================================
*/
-static svn_error_t *
-svn_branch_branch_subtree_r2(svn_branch_instance_t **new_branch_p,
- svn_branch_instance_t *from_branch,
- int from_eid,
- svn_branch_instance_t *to_outer_branch,
- svn_editor3_eid_t to_outer_eid,
- svn_branch_sibling_t *new_branch_def,
- apr_pool_t *scratch_pool);
-
svn_error_t *
svn_branch_branch_subtree_r(svn_branch_instance_t **new_branch_p,
svn_branch_instance_t *from_branch,
@@ -1319,10 +1334,7 @@ svn_branch_branch_subtree_r(svn_branch_i
return SVN_NO_ERROR;
}
-/* Make a new branch of FROM_BRANCH, selecting only the subtree at FROM_EID,
- * at existing branch-root element TO_OUTER_BRANCH:TO_OUTER_EID.
- */
-static svn_error_t *
+svn_error_t *
svn_branch_branch_subtree_r2(svn_branch_instance_t **new_branch_p,
svn_branch_instance_t *from_branch,
int from_eid,
@@ -1335,8 +1347,11 @@ svn_branch_branch_subtree_r2(svn_branch_
/* Source element must exist */
SVN_ERR_ASSERT(svn_branch_get_path_by_eid(from_branch, from_eid,
scratch_pool));
- /* FROM_BRANCH must be an immediate child branch of TO_OUTER_BRANCH. */
- SVN_ERR_ASSERT(SAME_BRANCH(from_branch->outer_branch, to_outer_branch));
+ /* When creating a new branch-sibling in same outer branch, TO_OUTER_BRANCH
+ is the parent of FROM_BRANCH. When instantiating the same branch-sibling
+ into a different outer-branch, TO_OUTER_BRANCH is in the same family as
+ the parent of FROM_BRANCH. We require only the latter. */
+ SVN_ERR_ASSERT(BRANCHES_IN_SAME_FAMILY(from_branch->outer_branch,
to_outer_branch));
/* create new inner branch instance */
new_branch = svn_branch_add_new_branch_instance(to_outer_branch,
to_outer_eid,
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=1662400&r1=1662399&r2=1662400&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c
(original)
+++ subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c Thu Feb
26 09:49:01 2015
@@ -701,7 +701,16 @@ branch_merge_subtree_r(svn_editor3_t *ed
}
else if (result)
{
- notify("A <e%d> %s", eid, result->name);
+ svn_branch_instance_t *subbranch
+ = svn_branch_get_subbranch_at_eid(src->branch, eid, scratch_pool);
+
+ if (subbranch)
+ notify("A <e%d> %s (subbranch b%d e%d)",
+ eid, result->name,
+ subbranch->sibling_defn->bid,
+ subbranch->sibling_defn->root_eid);
+ else
+ notify("A <e%d> %s", eid, result->name);
/* In BRANCH, create an instance of the element EID with new content.
*
@@ -713,6 +722,16 @@ branch_merge_subtree_r(svn_editor3_t *ed
SVN_ERR(svn_editor3_instantiate(editor, tgt->branch, eid,
result->parent_eid, result->name,
result->content));
+
+ if (subbranch)
+ {
+ SVN_ERR(svn_branch_branch_subtree_r2(
+ NULL,
+ subbranch, subbranch->sibling_defn->root_eid,
+ tgt->branch, eid,
+ subbranch->sibling_defn,
+ scratch_pool));
+ }
}
}
@@ -1205,30 +1224,6 @@ do_move(svn_editor3_t *editor,
}
/* */
-static svn_branch_instance_t *
-svn_branch_get_subbranch_at_eid(svn_branch_instance_t *branch,
- int eid,
- apr_pool_t *scratch_pool)
-{
- apr_array_header_t *subbranches;
- int i;
-
- subbranches = svn_branch_get_all_sub_branches(branch,
- scratch_pool, scratch_pool);
- for (i = 0; i < subbranches->nelts; i++)
- {
- svn_branch_instance_t *subbranch = APR_ARRAY_IDX(subbranches, i, void *);
-
- if (subbranch->outer_eid == eid)
- {
- return subbranch;
- }
- }
-
- return NULL;
-}
-
-/* */
static svn_branch_instance_t *
svn_branch_revision_root_find_branch_by_id(const svn_branch_revision_root_t
*rev_root,
const char *branch_instance_id,