subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From julianf...@apache.org
Subject svn commit: r1717785 - in /subversion/trunk: subversion/include/private/ subversion/libsvn_delta/ tools/dev/svnmover/
Date Thu, 03 Dec 2015 15:55:55 GMT
Author: julianfoad
Date: Thu Dec  3 15:55:55 2015
New Revision: 1717785

URL: http://svn.apache.org/viewvc?rev=1717785&view=rev
Log:
In 'svnmover', tweak the 'branch state' API to slightly simplify both the
implementation and some callers.

* subversion/include/private/svn_branch.h
  (svn_branch__state_set_element): New.

* subversion/include/private/svn_branch_impl.h
  (svn_branch__state_v_set_element_t): New.
  (svn_branch__state_v_alter_one_t,
   svn_branch__state_v_delete_one_t): Delete.
  (svn_branch__state_vtable_t): Replace 'alter_one' and 'delete_one' with
    'set_element'.

* subversion/include/private/svn_element.h,
  subversion/libsvn_delta/element.c
  (svn_element__tree_set): Constify the input.

* subversion/libsvn_delta/branch.c
  (branch_map_set): Constify the input.
  (branch_state_delete_one,
   branch_state_alter): Delete.
  (branch_state_set_element,
   svn_branch__state_set_element): New.
  (svn_branch__state_alter_one,
   svn_branch__state_delete_one): Change implementations to forward to
    svn_branch__state_set_element.
  (branch_state_create): Update the vtable.
  (svn_branch__map_add_subtree,
   svn_branch__state_parse): Update callers.

* subversion/libsvn_delta/branch_nested.c
  (branch_instantiate_elements): Use the new method. Add a missing SVN_ERR().

* tools/dev/svnmover/merge3.c
  (branch_merge_subtree_r): Use the new method.

* tools/dev/svnmover/svnmover.c
  (branch_elements_replay,
   update_wc_base_r): Use the new method.

Modified:
    subversion/trunk/subversion/include/private/svn_branch.h
    subversion/trunk/subversion/include/private/svn_branch_impl.h
    subversion/trunk/subversion/include/private/svn_element.h
    subversion/trunk/subversion/libsvn_delta/branch.c
    subversion/trunk/subversion/libsvn_delta/branch_nested.c
    subversion/trunk/subversion/libsvn_delta/element.c
    subversion/trunk/tools/dev/svnmover/merge3.c
    subversion/trunk/tools/dev/svnmover/svnmover.c

Modified: subversion/trunk/subversion/include/private/svn_branch.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/private/svn_branch.h?rev=1717785&r1=1717784&r2=1717785&view=diff
==============================================================================
--- subversion/trunk/subversion/include/private/svn_branch.h (original)
+++ subversion/trunk/subversion/include/private/svn_branch.h Thu Dec  3 15:55:55 2015
@@ -514,6 +514,17 @@ svn_branch__state_get_element(const svn_
                               int eid,
                               apr_pool_t *result_pool);
 
+/** Equivalent to
+ *    alter_one(..., element->parent_eid, element->name, element->payload),
+ * or, if @a element is null, to
+ *    delete_one(...).
+ */
+svn_error_t *
+svn_branch__state_set_element(svn_branch__state_t *branch,
+                              int eid,
+                              const svn_element__content_t *element,
+                              apr_pool_t *result_pool);
+
 /** Specify that the element of @a branch identified by @a eid shall not
  * be present.
  *

Modified: subversion/trunk/subversion/include/private/svn_branch_impl.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/private/svn_branch_impl.h?rev=1717785&r1=1717784&r2=1717785&view=diff
==============================================================================
--- subversion/trunk/subversion/include/private/svn_branch_impl.h (original)
+++ subversion/trunk/subversion/include/private/svn_branch_impl.h Thu Dec  3 15:55:55 2015
@@ -160,12 +160,10 @@ typedef svn_error_t *(*svn_branch__state
   int eid,
   apr_pool_t *result_pool);
 
-typedef svn_error_t *(*svn_branch__state_v_alter_one_t)(
+typedef svn_error_t *(*svn_branch__state_v_set_element_t)(
   svn_branch__state_t *branch,
   svn_branch__eid_t eid,
-  svn_branch__eid_t new_parent_eid,
-  const char *new_name,
-  const svn_element__payload_t *new_payload,
+  const svn_element__content_t *element,
   apr_pool_t *scratch_pool);
 
 typedef svn_error_t *(*svn_branch__state_v_copy_one_t)(
@@ -184,11 +182,6 @@ typedef svn_error_t *(*svn_branch__state
   const char *new_name,
   apr_pool_t *scratch_pool);
 
-typedef svn_error_t *(*svn_branch__state_v_delete_one_t)(
-  svn_branch__state_t *branch,
-  svn_branch__eid_t eid,
-  apr_pool_t *scratch_pool);
-
 typedef svn_error_t *(*svn_branch__state_v_purge_t)(
   svn_branch__state_t *branch,
   apr_pool_t *scratch_pool);
@@ -209,10 +202,9 @@ struct svn_branch__state_vtable_t
 
   svn_branch__state_v_get_elements_t get_elements;
   svn_branch__state_v_get_element_t get_element;
-  svn_branch__state_v_alter_one_t alter_one;
+  svn_branch__state_v_set_element_t set_element;
   svn_branch__state_v_copy_one_t copy_one;
   svn_branch__state_v_copy_tree_t copy_tree;
-  svn_branch__state_v_delete_one_t delete_one;
   svn_branch__state_v_purge_t purge;
   svn_branch__state_v_get_merge_ancestor_t get_merge_ancestor;
   svn_branch__state_v_add_merge_ancestor_t add_merge_ancestor;

Modified: subversion/trunk/subversion/include/private/svn_element.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/private/svn_element.h?rev=1717785&r1=1717784&r2=1717785&view=diff
==============================================================================
--- subversion/trunk/subversion/include/private/svn_element.h (original)
+++ subversion/trunk/subversion/include/private/svn_element.h Thu Dec  3 15:55:55 2015
@@ -351,7 +351,7 @@ svn_element__tree_get(const svn_element_
 svn_error_t *
 svn_element__tree_set(svn_element__tree_t *tree,
                       int eid,
-                      svn_element__content_t *element);
+                      const svn_element__content_t *element);
 
 /* Purge entries from E_MAP that don't connect, via parent directory hierarchy,
  * to ROOT_EID. In other words, remove elements that have been implicitly

Modified: subversion/trunk/subversion/libsvn_delta/branch.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_delta/branch.c?rev=1717785&r1=1717784&r2=1717785&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_delta/branch.c (original)
+++ subversion/trunk/subversion/libsvn_delta/branch.c Thu Dec  3 15:55:55 2015
@@ -1020,7 +1020,7 @@ branch_state_get_element(const svn_branc
 static void
 branch_map_set(svn_branch__state_t *branch,
                int eid,
-               svn_element__content_t *element)
+               const svn_element__content_t *element)
 {
   apr_pool_t *map_pool = apr_hash_pool_get(branch->priv->element_tree->e_map);
 
@@ -1035,44 +1035,32 @@ branch_map_set(svn_branch__state_t *bran
 
 /* An #svn_branch__state_t method. */
 static svn_error_t *
-branch_state_delete_one(svn_branch__state_t *branch,
-                        svn_branch__eid_t eid,
-                        apr_pool_t *scratch_pool)
-{
-  SVN_ERR_ASSERT(EID_IS_ALLOCATED(branch, eid));
-
-  branch_map_set(branch, eid, NULL);
-
-  return SVN_NO_ERROR;
-}
-
-/* An #svn_branch__state_t method. */
-static svn_error_t *
-branch_state_alter(svn_branch__state_t *branch,
-                   svn_branch__eid_t eid,
-                   svn_branch__eid_t new_parent_eid,
-                   const char *new_name,
-                   const svn_element__payload_t *new_payload,
-                   apr_pool_t *scratch_pool)
+branch_state_set_element(svn_branch__state_t *branch,
+                         svn_branch__eid_t eid,
+                         const svn_element__content_t *element,
+                         apr_pool_t *scratch_pool)
 {
   apr_pool_t *map_pool = apr_hash_pool_get(branch->priv->element_tree->e_map);
-  svn_element__content_t *element
-    = svn_element__content_create(new_parent_eid, new_name, new_payload,
-                                  map_pool);
 
   /* EID must be a valid element id */
   SVN_ERR_ASSERT(EID_IS_ALLOCATED(branch, eid));
-  /* NEW_PAYLOAD must be specified, either in full or by reference */
-  SVN_ERR_ASSERT(new_payload);
 
-  if ((new_parent_eid == -1) != IS_BRANCH_ROOT_EID(branch, eid)
-      || (*new_name == '\0') != IS_BRANCH_ROOT_EID(branch, eid))
+  if (element)
     {
-      return svn_error_createf(SVN_BRANCH__ERR, NULL,
-                               _("Cannot set e%d to (parent=e%d, name='%s'): "
-                                 "branch root is e%d"),
-                               eid, new_parent_eid, new_name,
-                               branch->priv->element_tree->root_eid);
+      element = svn_element__content_dup(element, map_pool);
+
+      /* NEW_PAYLOAD must be specified, either in full or by reference */
+      SVN_ERR_ASSERT(element->payload);
+
+      if ((element->parent_eid == -1) != IS_BRANCH_ROOT_EID(branch, eid)
+          || (*element->name == '\0') != IS_BRANCH_ROOT_EID(branch, eid))
+        {
+          return svn_error_createf(SVN_BRANCH__ERR, NULL,
+                                   _("Cannot set e%d to (parent=e%d, name='%s'): "
+                                     "branch root is e%d"),
+                                   eid, element->parent_eid, element->name,
+                                   branch->priv->element_tree->root_eid);
+        }
     }
 
   /* Insert the new version */
@@ -1194,10 +1182,11 @@ svn_branch__map_add_subtree(svn_branch__
 
   /* Create the new subtree root element */
   new_root_content = svn_element__tree_get(new_subtree, new_subtree->root_eid);
-  SVN_ERR(branch_state_alter(to_branch, to_eid,
-                             new_parent_eid, new_name,
-                             new_root_content->payload,
-                             scratch_pool));
+  new_root_content = svn_element__content_create(new_parent_eid, new_name,
+                                                 new_root_content->payload,
+                                                 scratch_pool);
+  SVN_ERR(branch_state_set_element(to_branch, to_eid, new_root_content,
+                                   scratch_pool));
 
   /* Process its immediate children */
   for (hi = apr_hash_first(scratch_pool, new_subtree->e_map);
@@ -1280,6 +1269,18 @@ svn_branch__state_get_element(const svn_
 }
 
 svn_error_t *
+svn_branch__state_set_element(svn_branch__state_t *branch,
+                              int eid,
+                              const svn_element__content_t *element,
+                              apr_pool_t *scratch_pool)
+{
+  SVN_ERR(branch->vtable->set_element(branch,
+                                      eid, element,
+                                      scratch_pool));
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
 svn_branch__state_alter_one(svn_branch__state_t *branch,
                             svn_branch__eid_t eid,
                             svn_branch__eid_t new_parent_eid,
@@ -1287,9 +1288,11 @@ svn_branch__state_alter_one(svn_branch__
                             const svn_element__payload_t *new_payload,
                             apr_pool_t *scratch_pool)
 {
-  SVN_ERR(branch->vtable->alter_one(branch,
-                                    eid, new_parent_eid, new_name, new_payload,
-                                    scratch_pool));
+  svn_element__content_t *element
+    = svn_element__content_create(new_parent_eid, new_name, new_payload,
+                                  scratch_pool);
+
+  SVN_ERR(svn_branch__state_set_element(branch, eid, element, scratch_pool));
   return SVN_NO_ERROR;
 }
 
@@ -1311,9 +1314,7 @@ svn_branch__state_delete_one(svn_branch_
                              svn_branch__eid_t eid,
                              apr_pool_t *scratch_pool)
 {
-  SVN_ERR(branch->vtable->delete_one(branch,
-                                     eid,
-                                     scratch_pool));
+  SVN_ERR(svn_branch__state_set_element(branch, eid, NULL, scratch_pool));
   return SVN_NO_ERROR;
 }
 
@@ -1385,10 +1386,9 @@ branch_state_create(const char *bid,
     {0},
     branch_state_get_elements,
     branch_state_get_element,
-    branch_state_alter,
+    branch_state_set_element,
     branch_state_copy_one,
     branch_state_copy_tree,
-    branch_state_delete_one,
     branch_state_purge,
     branch_state_get_merge_ancestor,
     branch_state_add_merge_ancestor,
@@ -1611,6 +1611,8 @@ svn_branch__state_parse(svn_branch__stat
       if (this_name)
         {
           svn_element__payload_t *payload;
+          svn_element__content_t *element;
+
           if (! is_subbranch)
             {
               payload = svn_element__payload_create_ref(txn->rev, bid, eid,
@@ -1621,9 +1623,11 @@ svn_branch__state_parse(svn_branch__stat
               payload
                 = svn_element__payload_create_subbranch(result_pool);
             }
-          SVN_ERR(branch_state_alter(
-            branch_state, eid, this_parent_eid, this_name, payload,
-            scratch_pool));
+          element = svn_element__content_create(this_parent_eid,
+                                                this_name, payload,
+                                                scratch_pool);
+          SVN_ERR(branch_state_set_element(branch_state, eid, element,
+                                           scratch_pool));
         }
     }
 

Modified: subversion/trunk/subversion/libsvn_delta/branch_nested.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_delta/branch_nested.c?rev=1717785&r1=1717784&r2=1717785&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_delta/branch_nested.c (original)
+++ subversion/trunk/subversion/libsvn_delta/branch_nested.c Thu Dec  3 15:55:55 2015
@@ -244,11 +244,8 @@ branch_instantiate_elements(svn_branch__
       int this_eid = svn_eid__hash_this_key(hi);
       svn_element__content_t *this_element = apr_hash_this_val(hi);
 
-      svn_branch__state_alter_one(to_branch, this_eid,
-                                  this_element->parent_eid,
-                                  this_element->name,
-                                  this_element->payload,
-                                  scratch_pool);
+      SVN_ERR(svn_branch__state_set_element(to_branch, this_eid,
+                                            this_element, scratch_pool));
     }
 
   return SVN_NO_ERROR;

Modified: subversion/trunk/subversion/libsvn_delta/element.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_delta/element.c?rev=1717785&r1=1717784&r2=1717785&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_delta/element.c (original)
+++ subversion/trunk/subversion/libsvn_delta/element.c Thu Dec  3 15:55:55 2015
@@ -376,7 +376,7 @@ svn_element__tree_get(const svn_element_
 svn_error_t *
 svn_element__tree_set(svn_element__tree_t *tree,
                       int eid,
-                      svn_element__content_t *element)
+                      const svn_element__content_t *element)
 {
   svn_eid__hash_set(tree->e_map, eid, element);
 

Modified: subversion/trunk/tools/dev/svnmover/merge3.c
URL: http://svn.apache.org/viewvc/subversion/trunk/tools/dev/svnmover/merge3.c?rev=1717785&r1=1717784&r2=1717785&view=diff
==============================================================================
--- subversion/trunk/tools/dev/svnmover/merge3.c (original)
+++ subversion/trunk/tools/dev/svnmover/merge3.c Thu Dec  3 15:55:55 2015
@@ -1275,9 +1275,8 @@ branch_merge_subtree_r(svn_branch__txn_t
                             eid, result->name,
                             subbranch_str(tgt->branch, eid, iterpool));
 
-          SVN_ERR(svn_branch__state_alter_one(tgt->branch, eid,
-                                              result->parent_eid, result->name,
-                                              result->payload, iterpool));
+          SVN_ERR(svn_branch__state_set_element(tgt->branch, eid,
+                                                result, iterpool));
 
           SVN_ERR(merge_subbranch(edit_txn, src, tgt, yca, eid, iterpool));
         }
@@ -1305,9 +1304,8 @@ branch_merge_subtree_r(svn_branch__txn_t
            * (which is not specified here, but will need to be),
            * which may be in this branch or in another branch.
            */
-          SVN_ERR(svn_branch__state_alter_one(tgt->branch, eid,
-                                              result->parent_eid, result->name,
-                                              result->payload, iterpool));
+          SVN_ERR(svn_branch__state_set_element(tgt->branch, eid,
+                                                result, iterpool));
 
           SVN_ERR(merge_subbranch(edit_txn, src, tgt, yca, eid, iterpool));
         }

Modified: subversion/trunk/tools/dev/svnmover/svnmover.c
URL: http://svn.apache.org/viewvc/subversion/trunk/tools/dev/svnmover/svnmover.c?rev=1717785&r1=1717784&r2=1717785&view=diff
==============================================================================
--- subversion/trunk/tools/dev/svnmover/svnmover.c (original)
+++ subversion/trunk/tools/dev/svnmover/svnmover.c Thu Dec  3 15:55:55 2015
@@ -699,17 +699,8 @@ branch_elements_replay(svn_branch__state
                      || svn_element__payload_invariants(e0->payload));
       SVN_ERR_ASSERT(!e1
                      || svn_element__payload_invariants(e1->payload));
-      if (e1)
-        {
-          SVN_ERR(svn_branch__state_alter_one(edit_branch, eid,
-                                              e1->parent_eid, e1->name,
-                                              e1->payload, scratch_pool));
-        }
-      else
-        {
-          SVN_ERR(svn_branch__state_delete_one(edit_branch, eid,
-                                               scratch_pool));
-        }
+      SVN_ERR(svn_branch__state_set_element(edit_branch, eid,
+                                            e1, scratch_pool));
     }
 
   return SVN_NO_ERROR;
@@ -972,12 +963,8 @@ update_wc_base_r(svnmover_wc_t *wc,
       if (work_branch)
         SVN_ERR(svn_branch__state_get_element(work_branch, &content,
                                               eid, scratch_pool));
-      if (content)
-        SVN_ERR(svn_branch__state_alter_one(base_branch, eid,
-                                            content->parent_eid, content->name,
-                                            content->payload, scratch_pool));
-      else
-        SVN_ERR(svn_branch__state_delete_one(base_branch, eid, scratch_pool));
+      SVN_ERR(svn_branch__state_set_element(base_branch, eid,
+                                            content, scratch_pool));
       svnmover_wc_set_base_rev(wc, base_branch, eid, new_rev);
 
       /* recurse into nested branches that exist in working */



Mime
View raw message