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 2014/11/17 16:32:42 UTC
svn commit: r1640172 - in /subversion/branches/move-tracking-2/subversion:
include/private/svn_editor3.h libsvn_delta/branching.c
libsvn_delta/compat3b.c
Author: julianfoad
Date: Mon Nov 17 15:32:42 2014
New Revision: 1640172
URL: http://svn.apache.org/r1640172
Log:
On the 'move-tracking-2' branch: Get rid of recursive delete functions.
Deleting a single element implies deleting its children, unless the children
are specifically moved to somewhere else. We don't need any recursive delete
functions. Instead, treat children of a subbranch-root element as unlinked, so
they are automatically considered deleted by the "purge orphans" function etc.
* subversion/include/private/svn_editor3.h
(svn_branch_map_update_as_subbranch_root): Declare.
(svn_branch_map_delete_children): Delete.
(svn_branch_map_branch_children,
svn_branch_map_copy_children): Clarify and correct doc strings.
* subversion/libsvn_delta/compat3b.c
(svn_branch_branchify): Convert the old subtree root element to a subbranch
root element instead of deleting all its children.
* subversion/libsvn_delta/branching.c
(svn_branch_map_update_as_subbranch_root): Rename & make public.
(svn_branch_map_purge_orphans): Purge any children in the outer branch
of a subbranch root element, as well as children of a nonexistent parent.
(svn_branch_map_delete_children,
branch_instance_delete,
branch_instance_delete_r,
svn_branch_delete_subtree_r): Delete.
(svn_branch_branch_subtree_r): Track the rename.
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/libsvn_delta/compat3b.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=1640172&r1=1640171&r2=1640172&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 Mon Nov 17 15:32:42 2014
@@ -1840,6 +1840,13 @@ svn_branch_el_rev_content_equal(const sv
apr_pool_t *scratch_pool);
+/* Declare that the following function requires/implies that in BRANCH's
+ * mapping, for each existing element, the parent also exists.
+ *
+ * ### Find a better word? flattened, canonical, finalized, ...
+ */
+#define SVN_BRANCH_SEQUENCE_POINT(branch)
+
/* In BRANCH, get element EID's node (parent, name, content).
*
* If element EID is not present, return null. Otherwise, the returned
@@ -1866,55 +1873,49 @@ svn_branch_map_update(svn_branch_instanc
const char *new_name,
const svn_editor3_node_content_t *new_content);
+/* Set or change the EID:element mapping for EID in BRANCH to reflect a
+ * subbranch root node. This node has no content in this branch; the
+ * corresponding element of the subbranch will define its content.
+ *
+ * Duplicate NEW_NAME into the branch mapping's pool.
+ */
+void
+svn_branch_map_update_as_subbranch_root(svn_branch_instance_t *branch,
+ int eid,
+ svn_editor3_eid_t new_parent_eid,
+ const char *new_name);
+
/* Remove from BRANCH's mapping any elements that do not have a complete
* line of parents to the branch root. In other words, remove elements
* that have been implicitly deleted.
*
* This does not remove subbranches.
*
- * ### TODO: Clarify sequencing requirements.
+ * ### TODO: Clarify sequencing requirements. (This leaves BRANCH's mapping
+ * in a [sequence-point/flattened/...?] state.)
*/
void
svn_branch_map_purge_orphans(svn_branch_instance_t *branch,
apr_pool_t *scratch_pool);
-/* In BRANCH, update the path mappings to delete all children of EID,
- * recursively (but not deleting subbranches).
+/* Branch a subtree.
*
- * EID may be any element id in BRANCH: existing or nonexistent, root or
- * normal or subbranch root (useful if we have just branchified a subtree).
- */
-svn_error_t *
-svn_branch_map_delete_children(svn_branch_instance_t *branch,
- int eid,
- apr_pool_t *scratch_pool);
-
-/* Adjust BRANCH and its subbranches (recursively),
- * to reflect deletion of the subtree at EID.
+ * For each element that in FROM_BRANCH is a pathwise descendant of
+ * FROM_PARENT_EID, excluding FROM_PARENT_EID itself, instantiate the
+ * same element in TO_BRANCH. For each element, keep the same parent
+ * element (except, for first-level children, change FROM_PARENT_EID to
+ * TO_PARENT_EID), name, and content that it had in FROM_BRANCH.
*
- * Element EID MUST be the location of a non-root element of BRANCH.
- * If EID is the root of a subbranch and/or contains nested
- * subbranches, also delete them.
- */
-svn_error_t *
-svn_branch_delete_subtree_r(svn_branch_instance_t *branch,
- int eid,
- apr_pool_t *scratch_pool);
-
-/* Update the mappings to reflect branching the subtree [### the what?!]
- * at FROM_BRANCH:FROM_PARENT_EID to TO_BRANCH:TO_PARENT_EID.
+ * ### It's not particularly useful to allow TO_PARENT_EID != FROM_PARENT_EID.
*
* FROM_BRANCH and TO_BRANCH must be different branch instances in the
* same branch family.
*
- * FROM_PATH MUST be an existing path in FROM_BRANCH, and may be the
- * root path of FROM_BRANCH.
- *
- * TO_PATH MUST be a path in TO_BRANCH at which nothing currently exists
- * if INCLUDE_SELF, or an existing path if not INCLUDE_SELF.
+ * FROM_PARENT_EID MUST be an existing element in FROM_BRANCH. It may be the
+ * root element of FROM_BRANCH.
*
- * If INCLUDE_SELF is true, include the element at FROM_PATH, otherwise
- * only act on children (recursively) of FROM_PATH.
+ * TO_PARENT_EID MUST be an existing element in TO_BRANCH. It may be the
+ * root element of TO_BRANCH.
*/
svn_error_t *
svn_branch_map_branch_children(svn_branch_instance_t *from_branch,
@@ -1923,7 +1924,9 @@ svn_branch_map_branch_children(svn_branc
int to_parent_eid,
apr_pool_t *scratch_pool);
-/* Adjust TO_OUTER_BRANCH and its subbranches (recursively),
+/* Branch a subtree.
+ *
+ * Adjust TO_OUTER_BRANCH and its subbranches (recursively),
* to reflect branching a subtree from FROM_BRANCH:FROM_EID to
* create a new subbranch of TO_OUTER_BRANCH at TO_OUTER_PARENT_EID:NEW_NAME.
*
@@ -1945,9 +1948,13 @@ svn_branch_branch_subtree_r(svn_branch_i
const char *new_name,
apr_pool_t *scratch_pool);
-/* In TO_BRANCH, assign new EIDs and path mappings to reflect the copying
- * of all children of FROM_BRANCH:FROM_PARENT_EID to TO_BRANCH:TO_PARENT_EID,
- * recursively, excluding the specified parent element itself.
+/* Copy a subtree.
+ *
+ * For each element that in FROM_BRANCH is a pathwise descendant of
+ * FROM_PARENT_EID, excluding FROM_PARENT_EID itself, instantiate a
+ * new element in TO_BRANCH. For each element, keep the same parent
+ * element (except, for first-level children, change FROM_PARENT_EID to
+ * TO_PARENT_EID), name, and content that it had in FROM_BRANCH.
*
* Assign a new EID in TO_BRANCH's family for each copied element.
*
@@ -1955,10 +1962,10 @@ svn_branch_branch_subtree_r(svn_branch_i
* in the same or different branch families.
*
* FROM_PARENT_EID MUST be an existing element in FROM_BRANCH. It may be the
- * root element of FROM_BRANCH, but not a subtree root.
+ * root element of FROM_BRANCH.
*
- * TO_PARENT_EID MUST be an existing path in TO_BRANCH. It may be the
- * root element of TO_BRANCH, but not a subtree root.
+ * TO_PARENT_EID MUST be an existing element in TO_BRANCH. It may be the
+ * root element of TO_BRANCH.
*/
svn_error_t *
svn_branch_map_copy_children(svn_branch_instance_t *from_branch,
@@ -1967,7 +1974,9 @@ svn_branch_map_copy_children(svn_branch_
int to_parent_eid,
apr_pool_t *scratch_pool);
-/* Adjust TO_BRANCH and its subbranches (recursively), to reflect a copy
+/* Copy a subtree.
+ *
+ * Adjust TO_BRANCH and its subbranches (recursively), to reflect a copy
* of a subtree from FROM_EL_REV to TO_PARENT_EID:TO_NAME.
*
* FROM_EL_REV must be an existing element. (It may be a branch root.)
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=1640172&r1=1640171&r2=1640172&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/libsvn_delta/branching.c (original)
+++ subversion/branches/move-tracking-2/subversion/libsvn_delta/branching.c Mon Nov 17 15:32:42 2014
@@ -462,17 +462,11 @@ svn_branch_map_update(svn_branch_instanc
branch_map_set(branch, eid, node);
}
-/* Set or change the EID:element mapping for EID in BRANCH to reflect a
- * subbranch root node. This node has no content in this branch; the
- * corresponding element of the subbranch will define its content.
- *
- * Duplicate NEW_NAME into the branch mapping's pool.
- */
-static void
-branch_map_update_as_subbranch_root(svn_branch_instance_t *branch,
- int eid,
- svn_editor3_eid_t new_parent_eid,
- const char *new_name)
+void
+svn_branch_map_update_as_subbranch_root(svn_branch_instance_t *branch,
+ int eid,
+ svn_editor3_eid_t new_parent_eid,
+ const char *new_name)
{
apr_pool_t *map_pool = apr_hash_pool_get(branch->e_map);
svn_branch_el_rev_content_t *node
@@ -508,12 +502,18 @@ svn_branch_map_purge_orphans(svn_branch_
int this_eid = *(const int *)apr_hash_this_key(hi);
svn_branch_el_rev_content_t *this_node = apr_hash_this_val(hi);
- if (this_node->parent_eid != -1
- && ! svn_branch_map_get(branch, this_node->parent_eid))
+ if (this_node->parent_eid != -1)
{
- SVN_DBG(("purge orphan: e%d", this_eid));
- svn_branch_map_delete(branch, this_eid);
- changed = TRUE;
+ svn_branch_el_rev_content_t *parent_node
+ = svn_branch_map_get(branch, this_node->parent_eid);
+
+ /* Purge if parent is deleted or is a subbranch-root node */
+ if (! parent_node || ! parent_node->content)
+ {
+ SVN_DBG(("purge orphan: e%d", this_eid));
+ svn_branch_map_delete(branch, this_eid);
+ changed = TRUE;
+ }
}
}
}
@@ -654,34 +654,6 @@ copy_content_from(svn_editor3_node_conte
}
svn_error_t *
-svn_branch_map_delete_children(svn_branch_instance_t *branch,
- int eid,
- apr_pool_t *scratch_pool)
-{
- apr_hash_index_t *hi;
-
- for (hi = apr_hash_first(scratch_pool, branch->e_map);
- hi; hi = apr_hash_next(hi))
- {
- int this_eid = *(const int *)apr_hash_this_key(hi);
- svn_branch_el_rev_content_t *this_node = apr_hash_this_val(hi);
-
- if (this_node->parent_eid == eid)
- {
- /* Recurse. (We don't try to check whether it's a directory node,
- as we might not have the node kind in the map.) */
- SVN_ERR(svn_branch_map_delete_children(branch, this_eid,
- scratch_pool));
-
- /* Delete this immediate child. */
- svn_branch_map_delete(branch, this_eid);
- }
- }
-
- return SVN_NO_ERROR;
-}
-
-svn_error_t *
svn_branch_map_copy_children(svn_branch_instance_t *from_branch,
int from_parent_eid,
svn_branch_instance_t *to_branch,
@@ -828,56 +800,6 @@ svn_branch_get_all_sub_branches(const sv
result_pool, scratch_pool);
}
-/* Delete the branch instance BRANCH by removing the record of it from its
- * revision-root.
- */
-static svn_error_t *
-branch_instance_delete(svn_branch_instance_t *branch,
- apr_pool_t *scratch_pool)
-{
- apr_array_header_t *branch_instances = branch->rev_root->branch_instances;
- int i;
-
- for (i = 0; i < branch_instances->nelts; i++)
- {
- svn_branch_instance_t *b
- = APR_ARRAY_IDX(branch_instances, i, void *);
-
- if (b == branch)
- {
- svn_sort__array_delete(branch_instances, i, 1);
- break;
- }
- }
-
- return SVN_NO_ERROR;
-}
-
-/* Delete the branch instance object BRANCH and any nested branch instances,
- * recursively.
- */
-static svn_error_t *
-branch_instance_delete_r(svn_branch_instance_t *branch,
- apr_pool_t *scratch_pool)
-{
- apr_array_header_t *subbranches
- = svn_branch_get_all_sub_branches(branch, scratch_pool, scratch_pool);
- int i;
-
- /* Delete nested branch instances, recursively */
- for (i = 0; i < subbranches->nelts; i++)
- {
- svn_branch_instance_t *b = APR_ARRAY_IDX(subbranches, i, void *);
-
- branch_instance_delete_r(b, scratch_pool);
- }
-
- /* Remove the record of this branch instance */
- SVN_ERR(branch_instance_delete(branch, scratch_pool));
-
- return SVN_NO_ERROR;
-}
-
svn_branch_instance_t *
svn_branch_add_new_branch_instance(svn_branch_instance_t *outer_branch,
int outer_eid,
@@ -1314,33 +1236,6 @@ svn_branch_repos_find_el_rev_by_path_rev
*/
svn_error_t *
-svn_branch_delete_subtree_r(svn_branch_instance_t *branch,
- int eid,
- apr_pool_t *scratch_pool)
-{
- apr_array_header_t *subbranches;
- int i;
-
- /* Delete any nested subbranches at or inside EID. */
- subbranches = branch_get_sub_branches(branch, eid,
- scratch_pool, scratch_pool);
- for (i = 0; i < subbranches->nelts; i++)
- {
- svn_branch_instance_t *subbranch
- = APR_ARRAY_IDX(subbranches, i, void *);
-
- /* Delete the whole subbranch (recursively) */
- SVN_ERR(branch_instance_delete_r(subbranch, scratch_pool));
- }
-
- /* update the element mapping in this branch */
- svn_branch_map_delete(branch, eid /* ### , since_rev? */);
- /* ### TODO: delete all elements under EID too. */
-
- return SVN_NO_ERROR;
-}
-
-svn_error_t *
svn_branch_branch_subtree_r(svn_branch_instance_t **new_branch_p,
svn_branch_instance_t *from_branch,
int from_eid,
@@ -1362,8 +1257,8 @@ svn_branch_branch_subtree_r(svn_branch_i
/* assign new eid to root node (outer branch) */
to_outer_eid
= svn_branch_family_add_new_element(to_outer_branch->sibling_defn->family);
- branch_map_update_as_subbranch_root(to_outer_branch, to_outer_eid,
- to_outer_parent_eid, new_name);
+ svn_branch_map_update_as_subbranch_root(to_outer_branch, to_outer_eid,
+ to_outer_parent_eid, new_name);
/* create new inner branch sibling & instance */
/* ### On sub-branches, should not add new branch sibling, only instance. */
Modified: subversion/branches/move-tracking-2/subversion/libsvn_delta/compat3b.c
URL: http://svn.apache.org/viewvc/subversion/branches/move-tracking-2/subversion/libsvn_delta/compat3b.c?rev=1640172&r1=1640171&r2=1640172&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/libsvn_delta/compat3b.c (original)
+++ subversion/branches/move-tracking-2/subversion/libsvn_delta/compat3b.c Mon Nov 17 15:32:42 2014
@@ -926,31 +926,29 @@ svn_branch_branchify(svn_editor3_t *edit
new_branch = svn_branch_add_new_branch_instance(outer_branch, outer_eid,
new_branch_def,
scratch_pool);
+ svn_branch_el_rev_content_t *old_content;
SVN_DBG(("branchify(b%d e%d at ^/%s): new f%d b%d e%d",
outer_branch->sibling_defn->bid, outer_eid,
svn_branch_get_root_rrpath(new_branch, scratch_pool),
new_family->fid, new_branch_def->bid, new_branch_def->root_eid));
- /* Initialize the root element */
- {
- svn_branch_el_rev_content_t *old_content = svn_branch_map_get(outer_branch,
- outer_eid);
-
- svn_branch_map_update(new_branch, new_branch_def->root_eid,
- -1, "", old_content->content);
- }
+ /* create the new root element */
+ old_content = svn_branch_map_get(outer_branch, outer_eid);
+ svn_branch_map_update(new_branch, new_branch_def->root_eid,
+ -1, "", old_content->content);
- /* assign new EIDs and update the path mappings in this branch */
+ /* copy all the children into the new branch, assigning new EIDs */
SVN_ERR(svn_branch_map_copy_children(outer_branch, outer_eid,
new_branch, new_branch_def->root_eid,
scratch_pool));
- /* remove old element mappings in outer branch */
- SVN_ERR(svn_branch_map_delete_children(outer_branch, outer_eid,
- scratch_pool));
-
- /* ### and convert the old root element to a subbranch-root element? */
+ /* convert the old root element to a subbranch-root element (which
+ implicitly deletes all its children from the old branch, if nothing
+ further touches them) */
+ svn_branch_map_update_as_subbranch_root(outer_branch, outer_eid,
+ old_content->parent_eid,
+ old_content->name);
return SVN_NO_ERROR;
}