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/03/06 15:18:56 UTC
svn commit: r1664630 - in /subversion/branches/move-tracking-2/subversion:
libsvn_delta/branch.c svnmover/svnmover.c
Author: julianfoad
Date: Fri Mar 6 14:18:56 2015
New Revision: 1664630
URL: http://svn.apache.org/r1664630
Log:
On the 'move-tracking-2' branch: Fix bugs in 'svnmover branchify'.
* subversion/libsvn_delta/branch.c
(IS_BRANCH_ROOT_EID): New macro, factored out.
(branch_map_node_validate,
svn_branch_get_path_by_eid): Use it.
(branch_branchify): New, extracted...
(svn_branch_branchify): ... from here. Return an error if the target is already a
branch root, otherwise it would abort deeper down.
* subversion/svnmover/svnmover.c
(get_subbranches): Key the resulting hash by full branch ids, not just BIDs, as
BIDs are not unique across branch families.
(svn_branch_diff_r): Adjust caller.
Modified:
subversion/branches/move-tracking-2/subversion/libsvn_delta/branch.c
subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c
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=1664630&r1=1664629&r2=1664630&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/libsvn_delta/branch.c (original)
+++ subversion/branches/move-tracking-2/subversion/libsvn_delta/branch.c Fri Mar 6 14:18:56 2015
@@ -50,6 +50,9 @@
((branch1)->sibling_defn->family->fid \
== (branch2)->sibling_defn->family->fid)
+#define IS_BRANCH_ROOT_EID(branch, eid) \
+ ((eid) == (branch)->sibling_defn->root_eid)
+
/* Is BRANCH1 the same branch as BRANCH2? Compare by full branch-ids; don't
require identical branch-instance objects. */
#define BRANCH_IS_SAME_BRANCH(branch1, branch2, scratch_pool) \
@@ -440,7 +443,7 @@ branch_map_node_validate(const svn_branc
/* Parent EID must be valid and different from this node's EID, or -1
iff this is the branch root element. */
SVN_ERR_ASSERT_NO_RETURN(
- (eid == branch->sibling_defn->root_eid)
+ IS_BRANCH_ROOT_EID(branch, eid)
? (node->parent_eid == -1)
: (node->parent_eid != eid
&& BRANCH_FAMILY_HAS_ELEMENT(branch, node->parent_eid)));
@@ -448,7 +451,7 @@ branch_map_node_validate(const svn_branc
/* Node name must be given, and empty iff EID is the branch root. */
SVN_ERR_ASSERT_NO_RETURN(
node->name
- && (eid == branch->sibling_defn->root_eid) == (*node->name == '\0'));
+ && IS_BRANCH_ROOT_EID(branch, eid) == (*node->name == '\0'));
/* Content, if specified, must be in full or by reference. */
if (node->content)
@@ -645,14 +648,14 @@ svn_branch_get_path_by_eid(const svn_bra
SVN_ERR_ASSERT_NO_RETURN(BRANCH_FAMILY_HAS_ELEMENT(branch, eid));
- for (; eid != branch->sibling_defn->root_eid; eid = node->parent_eid)
+ for (; ! IS_BRANCH_ROOT_EID(branch, eid); eid = node->parent_eid)
{
node = svn_branch_map_get(branch, eid);
if (! node)
return NULL;
path = svn_relpath_join(node->name, path, result_pool);
}
- SVN_ERR_ASSERT_NO_RETURN(eid == branch->sibling_defn->root_eid);
+ SVN_ERR_ASSERT_NO_RETURN(IS_BRANCH_ROOT_EID(branch, eid));
return path;
}
@@ -1528,15 +1531,13 @@ svn_branch_branch(svn_branch_instance_t
return SVN_NO_ERROR;
}
-svn_error_t *
-svn_branch_branchify(svn_branch_instance_t **new_branch_p,
- svn_branch_instance_t *outer_branch,
- svn_branch_eid_t outer_eid,
- apr_pool_t *scratch_pool)
+/* The body of svn_branch_branchify(), which see */
+static svn_error_t *
+branch_branchify(svn_branch_instance_t **new_branch_p,
+ svn_branch_instance_t *outer_branch,
+ svn_branch_eid_t outer_eid,
+ apr_pool_t *scratch_pool)
{
- /* ### TODO: First check the element is not already a branch root
- and its subtree does not contain any branch roots. */
-
svn_branch_family_t *new_family
= svn_branch_family_add_new_subfamily(outer_branch->sibling_defn->family);
int new_root_eid = svn_branch_family_add_new_element(new_family);
@@ -1580,6 +1581,24 @@ svn_branch_branchify(svn_branch_instance
return SVN_NO_ERROR;
}
+svn_error_t *
+svn_branch_branchify(svn_branch_instance_t **new_branch_p,
+ svn_branch_instance_t *outer_branch,
+ svn_branch_eid_t outer_eid,
+ apr_pool_t *scratch_pool)
+{
+ /* Check the element is not already a branch root */
+ /* ### TODO: and its subtree does not contain any branch roots. */
+ if (IS_BRANCH_ROOT_EID(outer_branch, outer_eid)
+ || svn_branch_get_subbranch_at_eid(outer_branch, outer_eid, scratch_pool))
+ return svn_error_createf(SVN_ERR_BRANCHING, NULL,
+ _("is already a subbranch root"));
+
+ SVN_ERR(branch_branchify(new_branch_p,
+ outer_branch, outer_eid, scratch_pool));
+ 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,
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=1664630&r1=1664629&r2=1664630&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c (original)
+++ subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c Fri Mar 6 14:18:56 2015
@@ -1084,9 +1084,7 @@ svn_branch_diff(svn_editor3_t *editor,
return SVN_NO_ERROR;
}
-/* Return a hash of (BID -> BRANCH) of the subbranches of BRANCH.
- *
- * ### Wrong, because BID is not a unique identifier
+/* Return a hash of (full-branch-id -> BRANCH) of the subbranches of BRANCH.
*
* Return an empty hash if BRANCH is null.
*/
@@ -1107,7 +1105,7 @@ get_subbranches(svn_branch_instance_t *b
{
svn_branch_instance_t *b = bi->val;
- svn_int_hash_set(result, b->sibling_defn->bid, b);
+ svn_hash_sets(result, svn_branch_get_root_rrpath(b, result_pool), b);
}
}
return result;
@@ -1174,9 +1172,9 @@ svn_branch_diff_r(svn_editor3_t *editor,
for (hi = apr_hash_first(scratch_pool, subbranches_all);
hi; hi = apr_hash_next(hi))
{
- int bid = svn_int_hash_this_key(hi);
- svn_branch_instance_t *branch_l = svn_int_hash_get(subbranches_l, bid);
- svn_branch_instance_t *branch_r = svn_int_hash_get(subbranches_r, bid);
+ const char *bid = apr_hash_this_key(hi);
+ svn_branch_instance_t *branch_l = svn_hash_gets(subbranches_l, bid);
+ svn_branch_instance_t *branch_r = svn_hash_gets(subbranches_r, bid);
svn_branch_el_rev_id_t *sub_left = NULL, *sub_right = NULL;
if (branch_l)