subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From julianf...@apache.org
Subject svn commit: r1706304 - in /subversion/branches/move-tracking-2/subversion: include/private/svn_branch.h libsvn_delta/branch.c libsvn_delta/compat3e.c svnmover/svnmover.c
Date Thu, 01 Oct 2015 18:32:34 GMT
Author: julianfoad
Date: Thu Oct  1 18:32:34 2015
New Revision: 1706304

URL: http://svn.apache.org/viewvc?rev=1706304&view=rev
Log:
On the 'move-tracking-2' branch: Simpify an API.

* subversion/include/private/svn_branch.h,
  subversion/libsvn_delta/branch.c
  (svn_branch_instantiate_elements): Rename from
    'svn_branch_instantiate_subtree'. Don't take new parent-eid and name
    parameters; instead, take these from the 'elements' input.

* subversion/libsvn_delta/compat3e.c
  (editor3_branch): Adjust the caller.

* subversion/svnmover/svnmover.c
  (do_branch_into): Adjust the caller.

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/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=1706304&r1=1706303&r2=1706304&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
18:32:34 2015
@@ -604,26 +604,18 @@ void
 svn_branch_purge_r(svn_branch_state_t *branch,
                    apr_pool_t *scratch_pool);
 
-/* Instantiate a subtree.
+/* Instantiate elements in a branch.
  *
  * In TO_BRANCH, instantiate (or alter, if existing) each element of
- * FROM_SUBTREE, with the given tree structure and payload. Set the subtree
- * root element's parent to NEW_PARENT_EID and name to NEW_NAME.
+ * ELEMENTS, each with its given tree structure (parent, name) and payload.
  *
- * Also branch the subbranches in FROM_SUBTREE, creating corresponding new
+ * Also branch the subbranches in ELEMENTS, creating corresponding new
  * subbranches in TO_BRANCH, recursively.
- *
- * If FROM_SUBTREE.root_eid is the same as TO_BRANCH.root_eid, then
- * (NEW_PARENT_EID, NEW_NAME) must be (-1, ""); otherwise, NEW_PARENT_EID
- * must be an existing element (it may be the root element) of TO_BRANCH and
- * NEW_NAME must not be not "".
  */
 svn_error_t *
-svn_branch_instantiate_subtree(svn_branch_state_t *to_branch,
-                               svn_branch_eid_t new_parent_eid,
-                               const char *new_name,
-                               svn_branch_subtree_t from_subtree,
-                               apr_pool_t *scratch_pool);
+svn_branch_instantiate_elements(svn_branch_state_t *to_branch,
+                                svn_branch_subtree_t elements,
+                                apr_pool_t *scratch_pool);
 
 /* Create a copy of NEW_SUBTREE in TO_BRANCH.
  *

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=1706304&r1=1706303&r2=1706304&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 18:32:34
2015
@@ -831,54 +831,29 @@ svn_branch_map_add_subtree(svn_branch_st
 }
 
 svn_error_t *
-svn_branch_instantiate_subtree(svn_branch_state_t *to_branch,
-                               svn_branch_eid_t new_parent_eid,
-                               const char *new_name,
-                               svn_branch_subtree_t new_subtree,
-                               apr_pool_t *scratch_pool)
+svn_branch_instantiate_elements(svn_branch_state_t *to_branch,
+                                svn_branch_subtree_t elements,
+                                apr_pool_t *scratch_pool)
 {
   apr_hash_index_t *hi;
-  svn_branch_el_rev_content_t *new_root_content;
 
-  /* Source element must not be the same as the target parent element */
-  if (new_subtree.root_eid == new_parent_eid)
-    {
-      return svn_error_createf(SVN_ERR_BRANCHING, NULL,
-                               _("Cannot branch from e%d to %s e%d/%s: "
-                                 "target element cannot be its own parent"),
-                               new_subtree.root_eid,
-                               svn_branch_get_id(to_branch, scratch_pool),
-                               new_parent_eid, new_name);
-    }
-
-  /* Instantiate the root element of NEW_SUBTREE */
-  new_root_content = svn_int_hash_get(new_subtree.e_map, new_subtree.root_eid);
-  if (new_root_content->payload)
-    svn_branch_update_element(to_branch, new_subtree.root_eid,
-                              new_parent_eid, new_name,
-                              new_root_content->payload);
-  else
-    svn_branch_update_subbranch_root_element(to_branch, new_subtree.root_eid,
-                                             new_parent_eid, new_name);
-
-  /* Instantiate all the children of NEW_SUBTREE */
-  for (hi = apr_hash_first(scratch_pool, new_subtree.e_map);
+  /* Instantiate all the elements of NEW_SUBTREE */
+  for (hi = apr_hash_first(scratch_pool, elements.e_map);
        hi; hi = apr_hash_next(hi))
     {
       int this_eid = svn_int_hash_this_key(hi);
       svn_branch_el_rev_content_t *this_element = apr_hash_this_val(hi);
 
-      if (this_eid != new_subtree.root_eid)
-        {
-          branch_map_set(to_branch, this_eid, this_element);
-        }
+      branch_map_set(to_branch, this_eid,
+                     svn_branch_el_rev_content_dup(
+                       this_element, apr_hash_pool_get(to_branch->e_map)));
     }
 
   /* branch any subbranches */
   {
     SVN_ITER_T(svn_branch_subtree_t) *bi;
 
-    for (SVN_HASH_ITER(bi, scratch_pool, new_subtree.subbranches))
+    for (SVN_HASH_ITER(bi, scratch_pool, elements.subbranches))
       {
         int this_outer_eid = svn_int_hash_this_key(bi->apr_hi);
         svn_branch_subtree_t *this_subtree = bi->val;
@@ -891,8 +866,8 @@ svn_branch_instantiate_subtree(svn_branc
                                                this_subtree->root_eid,
                                                bi->iterpool);
 
-        SVN_ERR(svn_branch_instantiate_subtree(new_branch, -1, "", *this_subtree,
-                                               bi->iterpool));
+        SVN_ERR(svn_branch_instantiate_elements(new_branch, *this_subtree,
+                                                bi->iterpool));
       }
   }
 

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=1706304&r1=1706303&r2=1706304&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 18:32:34
2015
@@ -1254,8 +1254,8 @@ editor3_branch(void *baton,
                                          from->eid, scratch_pool);
 
   /* Populate the mapping from the 'from' source */
-  SVN_ERR(svn_branch_instantiate_subtree(new_branch, -1, "", *from_subtree,
-                                         scratch_pool));
+  SVN_ERR(svn_branch_instantiate_elements(new_branch, *from_subtree,
+                                          scratch_pool));
 
   *new_branch_id_p = svn_branch_get_id(new_branch, result_pool);
   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=1706304&r1=1706303&r2=1706304&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c (original)
+++ subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c Thu Oct  1 18:32:34
2015
@@ -2433,6 +2433,7 @@ do_branch_into(svn_branch_state_t *from_
                apr_pool_t *scratch_pool)
 {
   svn_branch_subtree_t *from_subtree;
+  svn_branch_el_rev_content_t *new_root_content;
 
   /* Source element must exist */
   if (! svn_branch_get_path_by_eid(from_branch, from_eid, scratch_pool))
@@ -2446,9 +2447,18 @@ do_branch_into(svn_branch_state_t *from_
 
   from_subtree = svn_branch_get_subtree(from_branch, from_eid, scratch_pool);
 
+  /* Change this subtree's root element to TO_PARENT_EID/NEW_NAME. */
+  new_root_content
+    = svn_int_hash_get(from_subtree->e_map, from_subtree->root_eid);
+  new_root_content
+    = svn_branch_el_rev_content_create(to_parent_eid, new_name,
+                                       new_root_content->payload, scratch_pool);
+  svn_int_hash_set(from_subtree->e_map, from_subtree->root_eid,
+                   new_root_content);
+
   /* Populate the new branch mapping */
-  SVN_ERR(svn_branch_instantiate_subtree(to_branch, to_parent_eid, new_name,
-                                         *from_subtree, scratch_pool));
+  SVN_ERR(svn_branch_instantiate_elements(to_branch, *from_subtree,
+                                          scratch_pool));
   notify_v("A+   %s (subtree)",
            svn_branch_get_path_by_eid(to_branch, from_eid, scratch_pool));
 



Mime
View raw message