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/04/10 18:29:22 UTC
svn commit: r1672697 - in /subversion/branches/move-tracking-2/subversion:
include/private/svn_branch.h libsvn_delta/branch.c svnmover/svnmover.c
tests/cmdline/svnmover_tests.py
Author: julianfoad
Date: Fri Apr 10 16:29:22 2015
New Revision: 1672697
URL: http://svn.apache.org/r1672697
Log:
On the 'move-tracking-2' branch: Implement an 'svnmover branch-into' command
and use it to make a test work again.
* subversion/include/private/svn_branch.h,
subversion/libsvn_delta/branch.c
(svn_branch_branch_into): New function.
* subversion/svnmover/svnmover.c
(action_code_t,
action_defn): Add a 'branch-into' command.
(execute): Implement it.
* subversion/tests/cmdline/svnmover_tests.py
(restructure_repo_projects_ttb_to_ttb_projects): Use 'branch-into' to do
the rearrangement. Remove 'XFail' marker.
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/svnmover/svnmover.c
subversion/branches/move-tracking-2/subversion/tests/cmdline/svnmover_tests.py
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=1672697&r1=1672696&r2=1672697&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 Fri Apr 10 16:29:22 2015
@@ -704,6 +704,21 @@ svn_branch_branch(svn_branch_instance_t
const char *new_name,
apr_pool_t *scratch_pool);
+/* Branch the subtree of FROM_BRANCH found at FROM_EID, to appear
+ * in the existing branch TO_BRANCH at TO_PARENT_EID:NEW_NAME.
+ *
+ * FROM_BRANCH must be in the same family as TO_BRANCH.
+ * No element of FROM_BRANCH:FROM_EID may already exist in TO_BRANCH.
+ * (### Or, perhaps, elements that already exist should be altered?)
+ */
+svn_error_t *
+svn_branch_branch_into(svn_branch_instance_t *from_branch,
+ int from_eid,
+ svn_branch_instance_t *to_branch,
+ svn_branch_eid_t to_parent_eid,
+ const char *new_name,
+ apr_pool_t *scratch_pool);
+
/* Get the full id of branch BRANCH.
*/
const char *
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=1672697&r1=1672696&r2=1672697&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/libsvn_delta/branch.c (original)
+++ subversion/branches/move-tracking-2/subversion/libsvn_delta/branch.c Fri Apr 10 16:29:22 2015
@@ -1503,6 +1503,64 @@ svn_branch_branch(svn_branch_instance_t
}
svn_error_t *
+svn_branch_branch_into(svn_branch_instance_t *from_branch,
+ int from_eid,
+ svn_branch_instance_t *to_branch,
+ svn_branch_eid_t to_parent_eid,
+ const char *new_name,
+ apr_pool_t *scratch_pool)
+{
+ svn_branch_subtree_t from_subtree
+ = svn_branch_map_get_subtree(from_branch, from_eid, scratch_pool);
+
+ /* 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 b%d e%d: "
+ "does not exist"),
+ from_branch->sibling_defn->bsid, from_eid);
+ }
+
+ /* FROM_BRANCH must be in the same family as TO_BRANCH. */
+ if (! BRANCHES_IN_SAME_FAMILY(from_branch, to_branch))
+ {
+ return svn_error_createf(
+ SVN_ERR_BRANCHING, NULL,
+ _("The source branch %s and target branch %s must be within "
+ "the same family"),
+ svn_branch_instance_get_id(from_branch, scratch_pool),
+ svn_branch_instance_get_id(to_branch, scratch_pool));
+ }
+
+ /* Populate the new branch mapping */
+ SVN_ERR(svn_branch_instantiate_subtree(to_branch, to_parent_eid, new_name,
+ from_subtree, scratch_pool));
+
+ /* branch any subbranches under FROM_BRANCH:FROM_EID */
+ {
+ SVN_ITER_T(svn_branch_instance_t) *bi;
+
+ for (SVN_ARRAY_ITER(bi, svn_branch_get_subbranches(
+ from_branch, from_subtree.root_eid,
+ scratch_pool, scratch_pool), scratch_pool))
+ {
+ svn_branch_instance_t *subbranch = bi->val;
+
+ /* branch this subbranch into NEW_BRANCH (recursing) */
+ SVN_ERR(svn_branch_branch_subtree_r2(NULL,
+ subbranch,
+ subbranch->sibling_defn->root_eid,
+ to_branch, subbranch->outer_eid,
+ subbranch->sibling_defn,
+ bi->iterpool));
+ }
+ }
+
+ return SVN_NO_ERROR;
+}
+
+svn_error_t *
svn_branch_copy_subtree_r(const svn_branch_el_rev_id_t *from_el_rev,
svn_branch_instance_t *to_branch,
svn_branch_eid_t to_parent_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=1672697&r1=1672696&r2=1672697&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c (original)
+++ subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c Fri Apr 10 16:29:22 2015
@@ -225,6 +225,7 @@ typedef enum action_code_t {
ACTION_LIST_BRANCHES_R,
ACTION_LS,
ACTION_BRANCH,
+ ACTION_BRANCH_INTO,
ACTION_MKBRANCH,
ACTION_MERGE,
ACTION_MV,
@@ -256,6 +257,10 @@ static const action_defn_t action_defn[]
{ACTION_BRANCH, "branch", 2, "SRC DST",
"branch the branch-root or branch-subtree at SRC" NL
"to make a new branch at DST"},
+ {ACTION_BRANCH_INTO, "branch-into", 2, "SRC DST",
+ "make a copy of the branch-root or branch-subtree at SRC" NL
+ "appear at DST in the existing branch that contains DST" NL
+ "(like merging the creation of the subtree at SRC to DST)"},
{ACTION_MKBRANCH, "mkbranch", 1, "ROOT",
"make a directory that's the root of a new branch" NL
"in a new branching family"},
@@ -1677,6 +1682,20 @@ execute(const apr_array_header_t *action
}
made_changes = TRUE;
break;
+ case ACTION_BRANCH_INTO:
+ VERIFY_EID_EXISTS("branch-into", 0);
+ VERIFY_REV_UNSPECIFIED("branch-into", 1);
+ VERIFY_EID_NONEXISTENT("branch-into", 1);
+ VERIFY_PARENT_EID_EXISTS("branch-into", 1);
+ {
+ SVN_ERR(svn_branch_branch_into(el_rev[0]->branch, el_rev[0]->eid,
+ el_rev[1]->branch,
+ parent_el_rev[1]->eid, path_name[1],
+ iterpool));
+ notify("A+ %s (subtree)", action->relpath[1]);
+ }
+ made_changes = TRUE;
+ break;
case ACTION_MKBRANCH:
VERIFY_REV_UNSPECIFIED("mkbranch", 0);
VERIFY_EID_NONEXISTENT("mkbranch", 0);
Modified: subversion/branches/move-tracking-2/subversion/tests/cmdline/svnmover_tests.py
URL: http://svn.apache.org/viewvc/subversion/branches/move-tracking-2/subversion/tests/cmdline/svnmover_tests.py?rev=1672697&r1=1672696&r2=1672697&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/tests/cmdline/svnmover_tests.py (original)
+++ subversion/branches/move-tracking-2/subversion/tests/cmdline/svnmover_tests.py Fri Apr 10 16:29:22 2015
@@ -899,7 +899,6 @@ def restructure_repo_ttb_projects_to_pro
# family, and so would be linked to their old history by the weaker "copied
# from" relationship.)
#
-@XFail()
def restructure_repo_projects_ttb_to_ttb_projects(sbox):
"restructure repo: projects/ttb to ttb/projects"
sbox_build_svnmover(sbox, content=initial_content_projects_ttb)
@@ -961,7 +960,8 @@ def restructure_repo_projects_ttb_to_ttb
reported_add(proj + '/lib/foo/file') +
reported_add(proj + '/lib/foo/y2') +
reported_add(proj + '/lib/foo/z'),
- 'mv', proj + '/trunk', 'trunk/' + proj,
+ 'branch-into', proj + '/trunk', 'trunk/' + proj,
+ 'rm', proj + '/trunk',
)
test_svnmover2(sbox, '',
reported_br_diff(0, '', '') +
@@ -973,7 +973,8 @@ def restructure_repo_projects_ttb_to_ttb
reported_add(proj + '/bar/file') +
reported_add(proj + '/bar/y2') +
reported_add(proj + '/bar/z'),
- 'mv', proj + '/branches/br1', 'branches/br1/' + proj,
+ 'branch-into', proj + '/branches/br1', 'branches/br1/' + proj,
+ 'rm', proj + '/branches/br1',
)
# Remove the old project directory
test_svnmover2(sbox, '', None,