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/08/25 11:43:33 UTC

svn commit: r1697632 - in /subversion/branches/move-tracking-2: BRANCH-README subversion/include/private/svn_editor3e.h subversion/libsvn_delta/compat3e.c subversion/libsvn_delta/editor3e.c subversion/svnmover/svnmover.c

Author: julianfoad
Date: Tue Aug 25 09:43:32 2015
New Revision: 1697632

URL: http://svn.apache.org/r1697632
Log:
On the 'move-tracking-2' branch: Combine the near-identical 'add' and
'alter' methods in the editor API.

* BRANCH-README
  Remove this TODO item.

* subversion/include/private/svn_editor3e.h,
  subversion/libsvn_delta/editor3e.c
    Combine the 'alter' and 'add' methods into a single 'alter' method.

* subversion/libsvn_delta/compat3e.c
  (editor3_add,
   editor3_alter): Combine as 'editor3_alter'.
  (svn_editor3_in_memory,
   svn_editor3__ev3_from_delta_for_commit): Update the editor vtables.

* subversion/svnmover/svnmover.c
  (do_mkdir,
   do_put_file,
   mk_branch): Adjust calls: s/svn_editor3_add/svn_editor3_alter/.

Modified:
    subversion/branches/move-tracking-2/BRANCH-README
    subversion/branches/move-tracking-2/subversion/include/private/svn_editor3e.h
    subversion/branches/move-tracking-2/subversion/libsvn_delta/compat3e.c
    subversion/branches/move-tracking-2/subversion/libsvn_delta/editor3e.c
    subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c

Modified: subversion/branches/move-tracking-2/BRANCH-README
URL: http://svn.apache.org/viewvc/subversion/branches/move-tracking-2/BRANCH-README?rev=1697632&r1=1697631&r2=1697632&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/BRANCH-README (original)
+++ subversion/branches/move-tracking-2/BRANCH-README Tue Aug 25 09:43:32 2015
@@ -136,23 +136,7 @@ Work on this branch:
 
     Tidying things to do:
 
-      Combine editor3 methods 'alter' and 'add' into a single method.
-
-        They have basically the same meaning apart from the precondition
-        (element does or does not already exist). The pre-existence should
-        *not* be considered, I think, because ... idempotency?
-        Likewise, 'delete' should not care if it was already deleted.
-        The special thing about 'add' is we need a way to specify a new
-        EID; this was recently made possible by adding a 'new_eid' method.
-        Specifying a new EID is not unique to the 'add' method; it is also
-        needed sometimes when specifying a new parent-eid (in 'add' or in
-        'alter') that refers to an element that is being added. Acquiring
-        the new eid separately and combining the two methods into one will
-        remove the ordering dependency between the 'add' and the use of a
-        parent-eid that refers to it.
-
-        The unifying principle is it's communicating a partial description
-        of the new state, without reference to the old state.
+      (none listed)
 
   * The model.
 

Modified: subversion/branches/move-tracking-2/subversion/include/private/svn_editor3e.h
URL: http://svn.apache.org/viewvc/subversion/branches/move-tracking-2/subversion/include/private/svn_editor3e.h?rev=1697632&r1=1697631&r2=1697632&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/include/private/svn_editor3e.h (original)
+++ subversion/branches/move-tracking-2/subversion/include/private/svn_editor3e.h Tue Aug 25 09:43:32 2015
@@ -593,25 +593,43 @@ svn_error_t *
 svn_editor3_new_eid(svn_editor3_t *editor,
                     svn_branch_eid_t *eid_p);
 
-/** Create a new element in branch @a branch_id.
- * 
- * Assign the new element a new element id; store this in @a *eid_p if
- * @a eid_p is not null.
+/** Specify the tree position and payload of the element of @a branch_id
+ * identified by @a eid.
+ *
+ * This may create a new element or alter an existing element.
  *
  * Set the element's parent and name to @a new_parent_eid and @a new_name.
  *
  * Set the payload to @a new_payload. If @a new_payload is null, create a
  * subbranch-root element instead of a normal element.
  *
+ * A no-op change MUST be accepted but, in the interest of efficiency,
+ * SHOULD NOT be sent.
+ *
  * @see #svn_editor3_t
+ *
+ * If the element ...                   we can describe the effect as ...
+ *
+ *   exists in the branch               =>  altering it;
+ *   previously existed in the branch   =>  resurrecting it;
+ *   only existed in other branches     =>  branching it;
+ *   never existed anywhere             =>  creating or adding it.
+ *
+ * However, these are imprecise descriptions and not mutually exclusive.
+ * For example, if it existed previously in this branch and another, then
+ * we may describe the result as 'resurrecting' and/or as 'branching'.
+ *
+ * ### When converting this edit to an Ev1 edit, do we need a way to specify
+ *     where the Ev1 node is to be "copied" from, when this is branching the
+ *     element?
  */
 svn_error_t *
-svn_editor3_add(svn_editor3_t *editor,
-                const char *branch_id,
-                svn_branch_eid_t eid,
-                svn_branch_eid_t new_parent_eid,
-                const char *new_name,
-                const svn_element_payload_t *new_payload);
+svn_editor3_alter(svn_editor3_t *editor,
+                  const char *branch_id,
+                  svn_branch_eid_t eid,
+                  svn_branch_eid_t new_parent_eid,
+                  const char *new_name,
+                  const svn_element_payload_t *new_payload);
 
 /** Create a new element that is copied from a pre-existing
  * <SVN_EDITOR3_WITH_COPY_FROM_THIS_REV> or newly created </>
@@ -730,42 +748,6 @@ svn_editor3_delete(svn_editor3_t *editor
                    const char *branch_id,
                    svn_branch_eid_t eid);
 
-/** Specify the tree position and payload of the element of @a branch_id
- * identified by @a eid.
- *
- * Set the element's parent and name to @a new_parent_eid and @a new_name.
- *
- * Set the payload to @a new_payload. If @a new_payload is null, create a
- * subbranch-root element instead of a normal element.
- *
- * A no-op change MUST be accepted but, in the interest of efficiency,
- * SHOULD NOT be sent.
- *
- * @see #svn_editor3_t
- *
- * If the element ...                   we can describe the effect as ...
- *
- *   exists in the branch               =>  altering it;
- *   previously existed in the branch   =>  resurrecting it;
- *   only existed in other branches     =>  branching it;
- *   never existed anywhere             =>  creating it.
- *
- * However, these are imprecise descriptions and not mutually exclusive.
- * For example, if it existed previously in this branch and another, then
- * we may describe the result as 'resurrecting' and/or as 'branching'.
- *
- * ### When converting this edit to an Ev1 edit, do we need a way to specify
- *     where the Ev1 node is to be "copied" from, when this is branching the
- *     element?
- */
-svn_error_t *
-svn_editor3_alter(svn_editor3_t *editor,
-                  const char *branch_id,
-                  svn_branch_eid_t eid,
-                  svn_branch_eid_t new_parent_eid,
-                  const char *new_name,
-                  const svn_element_payload_t *new_payload);
-
 /** Fetch full payload.
  *
  * If the payload in @a element is defined only by reference (to a
@@ -846,9 +828,9 @@ typedef svn_error_t *(*svn_editor3_cb_ne
   svn_branch_eid_t *eid_p,
   apr_pool_t *scratch_pool);
 
-/** @see svn_editor3_add(), #svn_editor3_t
+/** @see svn_editor3_alter(), #svn_editor3_t
  */
-typedef svn_error_t *(*svn_editor3_cb_add_t)(
+typedef svn_error_t *(*svn_editor3_cb_alter_t)(
   void *baton,
   const char *branch_id,
   svn_branch_eid_t eid,
@@ -887,17 +869,6 @@ typedef svn_error_t *(*svn_editor3_cb_de
   svn_branch_eid_t eid,
   apr_pool_t *scratch_pool);
 
-/** @see svn_editor3_alter(), #svn_editor3_t
- */
-typedef svn_error_t *(*svn_editor3_cb_alter_t)(
-  void *baton,
-  const char *branch_id,
-  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);
-
 /** @see svn_editor3_payload_resolve(), #svn_editor3_t
  */
 typedef svn_error_t *(*svn_editor3_cb_payload_resolve_t)(
@@ -941,11 +912,10 @@ typedef svn_error_t *(*svn_editor3_cb_ab
 typedef struct svn_editor3_cb_funcs_t
 {
   svn_editor3_cb_new_eid_t cb_new_eid;
-  svn_editor3_cb_add_t cb_add;
+  svn_editor3_cb_alter_t cb_alter;
   svn_editor3_cb_copy_one_t cb_copy_one;
   svn_editor3_cb_copy_tree_t cb_copy_tree;
   svn_editor3_cb_delete_t cb_delete;
-  svn_editor3_cb_alter_t cb_alter;
   svn_editor3_cb_payload_resolve_t cb_payload_resolve;
 
   svn_editor3_cb_sequence_point_t cb_sequence_point;

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=1697632&r1=1697631&r2=1697632&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/libsvn_delta/compat3e.c (original)
+++ subversion/branches/move-tracking-2/subversion/libsvn_delta/compat3e.c Tue Aug 25 09:43:32 2015
@@ -1150,13 +1150,13 @@ editor3_new_eid(void *baton,
 
 /* An #svn_editor3_t method. */
 static svn_error_t *
-editor3_add(void *baton,
-            const char *branch_id,
-            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)
+editor3_alter(void *baton,
+              const char *branch_id,
+              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)
 {
   ev3_from_delta_baton_t *eb = baton;
   svn_branch_state_t *branch
@@ -1165,7 +1165,7 @@ editor3_add(void *baton,
 
   if (new_payload)
     {
-      SVN_DBG(("add(e%d): parent e%d, name '%s', kind %s",
+      SVN_DBG(("alter(e%d): parent e%d, name '%s', kind %s",
                eid, new_parent_eid,
                new_name, svn_node_kind_to_word(new_payload->kind)));
 
@@ -1174,7 +1174,7 @@ editor3_add(void *baton,
     }
   else
     {
-      SVN_DBG(("add subbranch-root (e%d): parent e%d, name '%s'",
+      SVN_DBG(("alter(e%d): parent e%d, name '%s', kind (subbranch)",
                eid, new_parent_eid, new_name));
 
       svn_branch_update_subbranch_root_element(branch, eid,
@@ -1307,37 +1307,6 @@ editor3_delete(void *baton,
   return SVN_NO_ERROR;
 }
 
-/* An #svn_editor3_t method. */
-static svn_error_t *
-editor3_alter(void *baton,
-              const char *branch_id,
-              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)
-{
-  ev3_from_delta_baton_t *eb = baton;
-  svn_branch_state_t *branch
-    = svn_branch_revision_root_get_branch_by_id(eb->edited_rev_root,
-                                                branch_id, scratch_pool);
-
-  SVN_DBG(("alter(e%d): parent e%d, name '%s', kind %s",
-           eid,
-           new_parent_eid,
-           new_name ? new_name : "(same)",
-           new_payload ? svn_node_kind_to_word(new_payload->kind) : "(subbranch)"));
-
-  if (new_payload)
-    svn_branch_update_element(
-      branch, eid, new_parent_eid, new_name, new_payload);
-  else
-    svn_branch_update_subbranch_root_element(
-      branch, eid, new_parent_eid, new_name);
-
-  return SVN_NO_ERROR;
-}
-
 /* Update *PATHS, a hash of (storage_rrpath -> svn_branch_el_rev_id_t),
  * creating or filling in entries for all elements in BRANCH.
  */
@@ -1960,11 +1929,10 @@ svn_editor3_in_memory(svn_editor3_t **ed
 {
   static const svn_editor3_cb_funcs_t editor_funcs = {
     editor3_new_eid,
-    editor3_add,
+    editor3_alter,
     editor3_copy_one,
     editor3_copy_tree,
     editor3_delete,
-    editor3_alter,
     editor3_payload_resolve,
     editor3_sequence_point,
     editor3_mem_complete,
@@ -2003,11 +1971,10 @@ svn_editor3__ev3_from_delta_for_commit(
 {
   static const svn_editor3_cb_funcs_t editor_funcs = {
     editor3_new_eid,
-    editor3_add,
+    editor3_alter,
     editor3_copy_one,
     editor3_copy_tree,
     editor3_delete,
-    editor3_alter,
     editor3_payload_resolve,
     editor3_sequence_point,
     editor3_complete,

Modified: subversion/branches/move-tracking-2/subversion/libsvn_delta/editor3e.c
URL: http://svn.apache.org/viewvc/subversion/branches/move-tracking-2/subversion/libsvn_delta/editor3e.c?rev=1697632&r1=1697631&r2=1697632&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/libsvn_delta/editor3e.c (original)
+++ subversion/branches/move-tracking-2/subversion/libsvn_delta/editor3e.c Tue Aug 25 09:43:32 2015
@@ -204,20 +204,22 @@ svn_editor3_new_eid(svn_editor3_t *edito
 }
 
 svn_error_t *
-svn_editor3_add(svn_editor3_t *editor,
-                const char *branch_id,
-                svn_branch_eid_t eid,
-                svn_branch_eid_t new_parent_eid,
-                const char *new_name,
-                const svn_element_payload_t *new_payload)
+svn_editor3_alter(svn_editor3_t *editor,
+                  const char *branch_id,
+                  svn_branch_eid_t eid,
+                  svn_branch_eid_t new_parent_eid,
+                  const char *new_name,
+                  const svn_element_payload_t *new_payload)
 {
   SVN_ERR_ASSERT(VALID_EID(eid));
-  SVN_ERR_ASSERT(VALID_EID(new_parent_eid));
-  SVN_ERR_ASSERT(VALID_NAME(new_name));
+  /*SVN_ERR_ASSERT(eid == branch->root_eid ? new_parent_eid == -1
+                                         : VALID_EID(new_parent_eid));*/
+  /*SVN_ERR_ASSERT(eid == branch->root_eid ? *new_name == '\0'
+                                         : VALID_NAME(new_name));*/
   SVN_ERR_ASSERT(!new_payload || VALID_PAYLOAD(new_payload));
   VERIFY(alter, new_parent_eid != eid);
 
-  DO_CALLBACK(editor, cb_add,
+  DO_CALLBACK(editor, cb_alter,
               5(branch_id, eid,
                 new_parent_eid, new_name,
                 new_payload));
@@ -285,30 +287,6 @@ svn_editor3_delete(svn_editor3_t *editor
 }
 
 svn_error_t *
-svn_editor3_alter(svn_editor3_t *editor,
-                  const char *branch_id,
-                  svn_branch_eid_t eid,
-                  svn_branch_eid_t new_parent_eid,
-                  const char *new_name,
-                  const svn_element_payload_t *new_payload)
-{
-  SVN_ERR_ASSERT(VALID_EID(eid));
-  /*SVN_ERR_ASSERT(eid == branch->root_eid ? new_parent_eid == -1
-                                         : VALID_EID(new_parent_eid));*/
-  /*SVN_ERR_ASSERT(eid == branch->root_eid ? *new_name == '\0'
-                                         : VALID_NAME(new_name));*/
-  SVN_ERR_ASSERT(! new_payload || VALID_PAYLOAD(new_payload));
-  VERIFY(alter, new_parent_eid != eid);
-
-  DO_CALLBACK(editor, cb_alter,
-              5(branch_id, eid,
-                new_parent_eid, new_name,
-                new_payload));
-
-  return SVN_NO_ERROR;
-}
-
-svn_error_t *
 svn_editor3_payload_resolve(svn_editor3_t *editor,
                             svn_branch_el_rev_content_t *element)
 {
@@ -432,21 +410,23 @@ wrap_new_eid(void *baton,
 }
 
 static svn_error_t *
-wrap_add(void *baton,
-         const char *branch_id,
-         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)
+wrap_alter(void *baton,
+           const char *branch_id,
+           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)
 {
   wrapper_baton_t *eb = baton;
 
-  dbg(eb, scratch_pool, "... : add(p=%s, n=%s, c=...)",
-      eid_str(new_parent_eid, scratch_pool), new_name);
-  SVN_ERR(svn_editor3_add(eb->wrapped_editor,
-                          branch_id, eid,
-                          new_parent_eid, new_name, new_payload));
+  dbg(eb, scratch_pool, "%s : alter(p=%s, n=%s, k=%s)",
+      eid_str(eid, scratch_pool),
+      eid_str(new_parent_eid, scratch_pool), new_name,
+      new_payload ? svn_node_kind_to_word(new_payload->kind) : "subbranch");
+  SVN_ERR(svn_editor3_alter(eb->wrapped_editor,
+                            branch_id, eid,
+                            new_parent_eid, new_name, new_payload));
   return SVN_NO_ERROR;
 }
 
@@ -508,26 +488,6 @@ wrap_delete(void *baton,
 }
 
 static svn_error_t *
-wrap_alter(void *baton,
-           const char *branch_id,
-           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)
-{
-  wrapper_baton_t *eb = baton;
-
-  dbg(eb, scratch_pool, "%s : alter(p=%s, n=%s, c=...)",
-      eid_str(eid, scratch_pool), eid_str(eid, scratch_pool),
-      eid_str(new_parent_eid, scratch_pool), new_name);
-  SVN_ERR(svn_editor3_alter(eb->wrapped_editor,
-                            branch_id, eid,
-                            new_parent_eid, new_name, new_payload));
-  return SVN_NO_ERROR;
-}
-
-static svn_error_t *
 wrap_payload_resolve(void *baton,
                      svn_branch_el_rev_content_t *element,
                      apr_pool_t *scratch_pool)
@@ -579,11 +539,10 @@ svn_editor3__get_debug_editor(svn_editor
 {
   static const svn_editor3_cb_funcs_t wrapper_funcs = {
     wrap_new_eid,
-    wrap_add,
+    wrap_alter,
     wrap_copy_one,
     wrap_copy_tree,
     wrap_delete,
-    wrap_alter,
     wrap_payload_resolve,
     wrap_sequence_point,
     wrap_complete,
@@ -639,20 +598,20 @@ change_detection_new_eid(void *baton,
 }
 
 static svn_error_t *
-change_detection_add(void *baton,
-         const char *branch_id,
-         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)
+change_detection_alter(void *baton,
+           const char *branch_id,
+           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)
 {
   change_detection_baton_t *eb = baton;
 
   *eb->change_detected = TRUE;
-  SVN_ERR(svn_editor3_add(eb->wrapped_editor,
-                          branch_id, eid,
-                          new_parent_eid, new_name, new_payload));
+  SVN_ERR(svn_editor3_alter(eb->wrapped_editor,
+                            branch_id, eid,
+                            new_parent_eid, new_name, new_payload));
   return SVN_NO_ERROR;
 }
 
@@ -708,24 +667,6 @@ change_detection_delete(void *baton,
 }
 
 static svn_error_t *
-change_detection_alter(void *baton,
-           const char *branch_id,
-           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)
-{
-  change_detection_baton_t *eb = baton;
-
-  *eb->change_detected = TRUE;
-  SVN_ERR(svn_editor3_alter(eb->wrapped_editor,
-                            branch_id, eid,
-                            new_parent_eid, new_name, new_payload));
-  return SVN_NO_ERROR;
-}
-
-static svn_error_t *
 change_detection_payload_resolve(void *baton,
                      svn_branch_el_rev_content_t *element,
                      apr_pool_t *scratch_pool)
@@ -775,11 +716,10 @@ svn_editor3__change_detection_editor(svn
 {
   static const svn_editor3_cb_funcs_t wrapper_funcs = {
     change_detection_new_eid,
-    change_detection_add,
+    change_detection_alter,
     change_detection_copy_one,
     change_detection_copy_tree,
     change_detection_delete,
-    change_detection_alter,
     change_detection_payload_resolve,
     change_detection_sequence_point,
     change_detection_complete,

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=1697632&r1=1697631&r2=1697632&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c (original)
+++ subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c Tue Aug 25 09:43:32 2015
@@ -2096,9 +2096,9 @@ do_mkdir(svn_editor3_t *editor,
   int new_eid;
 
   SVN_ERR(svn_editor3_new_eid(editor, &new_eid));
-  SVN_ERR(svn_editor3_add(editor,
-                          to_branch_id, new_eid,
-                          to_parent_eid, new_name, payload));
+  SVN_ERR(svn_editor3_alter(editor,
+                            to_branch_id, new_eid,
+                            to_parent_eid, new_name, payload));
   notify_v("A    %s",
            branch_peid_name_to_path(to_branch, to_parent_eid, new_name,
                                     scratch_pool));
@@ -2171,10 +2171,10 @@ do_put_file(svn_editor3_t *editor,
       int new_eid;
 
       SVN_ERR(svn_editor3_new_eid(editor, &new_eid));
-      SVN_ERR(svn_editor3_add(editor,
-                              branch_id, new_eid,
-                              parent_eid, name,
-                              payload));
+      SVN_ERR(svn_editor3_alter(editor,
+                                branch_id, new_eid,
+                                parent_eid, name,
+                                payload));
       file_el_rev->eid = new_eid;
     }
   notify_v("A    %s",
@@ -2251,10 +2251,10 @@ mk_branch(svn_branch_state_t **new_branc
   svn_branch_state_t *new_branch;
 
   SVN_ERR(svn_editor3_new_eid(editor, &new_outer_eid));
-  SVN_ERR(svn_editor3_add(editor,
-                          outer_branch_id, new_outer_eid,
-                          outer_parent_eid, outer_name,
-                          NULL /*new_payload*/));
+  SVN_ERR(svn_editor3_alter(editor,
+                            outer_branch_id, new_outer_eid,
+                            outer_parent_eid, outer_name,
+                            NULL /*new_payload*/));
   new_branch = svn_branch_add_new_branch(
                  outer_branch->rev_root,
                  outer_branch, new_outer_eid, -1/*new_root_eid*/,