subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhuij...@apache.org
Subject svn commit: r1717845 - in /subversion/branches/ra-git: ./ subversion/include/private/ subversion/libsvn_delta/ subversion/tests/cmdline/ tools/dev/svnmover/
Date Thu, 03 Dec 2015 20:47:21 GMT
Author: rhuijben
Date: Thu Dec  3 20:47:21 2015
New Revision: 1717845

URL: http://svn.apache.org/viewvc?rev=1717845&view=rev
Log:
On the ra-git branch: Catch up with trunk @r1717844

Modified:
    subversion/branches/ra-git/   (props changed)
    subversion/branches/ra-git/subversion/include/private/svn_branch.h
    subversion/branches/ra-git/subversion/include/private/svn_branch_impl.h
    subversion/branches/ra-git/subversion/include/private/svn_element.h
    subversion/branches/ra-git/subversion/libsvn_delta/branch.c
    subversion/branches/ra-git/subversion/libsvn_delta/branch_nested.c
    subversion/branches/ra-git/subversion/libsvn_delta/element.c
    subversion/branches/ra-git/subversion/tests/cmdline/svnmover_tests.py
    subversion/branches/ra-git/tools/dev/svnmover/merge3.c
    subversion/branches/ra-git/tools/dev/svnmover/svnmover.c
    subversion/branches/ra-git/tools/dev/svnmover/svnmover.h

Propchange: subversion/branches/ra-git/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec  3 20:47:21 2015
@@ -95,4 +95,4 @@
 /subversion/branches/verify-at-commit:1462039-1462408
 /subversion/branches/verify-keep-going:1439280-1546110
 /subversion/branches/wc-collate-path:1402685-1480384
-/subversion/trunk:1583624-1717592
+/subversion/trunk:1583624-1717844

Modified: subversion/branches/ra-git/subversion/include/private/svn_branch.h
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/include/private/svn_branch.h?rev=1717845&r1=1717844&r2=1717845&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/include/private/svn_branch.h (original)
+++ subversion/branches/ra-git/subversion/include/private/svn_branch.h Thu Dec  3 20:47:21
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/branches/ra-git/subversion/include/private/svn_branch_impl.h
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/include/private/svn_branch_impl.h?rev=1717845&r1=1717844&r2=1717845&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/include/private/svn_branch_impl.h (original)
+++ subversion/branches/ra-git/subversion/include/private/svn_branch_impl.h Thu Dec  3 20:47:21
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/branches/ra-git/subversion/include/private/svn_element.h
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/include/private/svn_element.h?rev=1717845&r1=1717844&r2=1717845&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/include/private/svn_element.h (original)
+++ subversion/branches/ra-git/subversion/include/private/svn_element.h Thu Dec  3 20:47:21
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/branches/ra-git/subversion/libsvn_delta/branch.c
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_delta/branch.c?rev=1717845&r1=1717844&r2=1717845&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_delta/branch.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_delta/branch.c Thu Dec  3 20:47:21 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/branches/ra-git/subversion/libsvn_delta/branch_nested.c
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_delta/branch_nested.c?rev=1717845&r1=1717844&r2=1717845&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_delta/branch_nested.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_delta/branch_nested.c Thu Dec  3 20:47:21
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/branches/ra-git/subversion/libsvn_delta/element.c
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_delta/element.c?rev=1717845&r1=1717844&r2=1717845&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_delta/element.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_delta/element.c Thu Dec  3 20:47:21 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/branches/ra-git/subversion/tests/cmdline/svnmover_tests.py
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/tests/cmdline/svnmover_tests.py?rev=1717845&r1=1717844&r2=1717845&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/tests/cmdline/svnmover_tests.py (original)
+++ subversion/branches/ra-git/subversion/tests/cmdline/svnmover_tests.py Thu Dec  3 20:47:21
2015
@@ -1622,7 +1622,57 @@ def simple_branch(sbox):
 
   # The compatibility layer doesn't record the copy properly
   test_svnmover_verify_log(sbox.repo_url,
-                           ['A /top0/Y (from /top0/X:2)'])
+                           ['A /top0/Y (from /top0/X:1)',
+                            'A /top0/Y/A (from /top0/X/A:2)'])
+
+def merge_move_into_subtree(sbox):
+  "merge move into subtree"
+  sbox_build_svnmover(sbox, content=initial_content_ttb)
+  repo_url = sbox.repo_url
+
+  # This tests the behaviour of merging a subtree. In this case, we expect
+  # each element in the union of (YCA subtree, source subtree, target subtree)
+  # to be merged. (Other behaviours -- such as merging only the elements in
+  # the intersection of those three subtrees -- could be provided in future.)
+  #
+  # This test tests a merge with no conflicts.
+
+  # create initial state in trunk
+  # (r2)
+  test_svnmover2(sbox, '/trunk',
+                 reported_br_diff('trunk') +
+                 reported_add('A') +
+                 reported_add('B2') +
+                 reported_add('B2/C2'),
+                'mkdir A',
+                'mkdir B2',
+                'mkdir B2/C2')
+
+  # branch (r3)
+  test_svnmover2(sbox, '',
+                 reported_br_diff('') +
+                 reported_br_add('branches/br1'),
+                'branch trunk branches/br1')
+
+  # on trunk: move B2 into subtree A (r4)
+  test_svnmover2(sbox, 'trunk',
+                 reported_br_diff('trunk') +
+                 reported_move('B2', 'A/B2'),
+                'mv B2 A/B2')
+
+  # on branch: make a non-conflicting change to 'B2' (r5)
+  test_svnmover2(sbox, 'branches/br1',
+                 reported_br_diff('branches/br1') +
+                 reported_move('B2', 'B3'),
+                'mv B2 B3')
+
+  # merge subtree 'A' from trunk to branch (r6)
+  # expect the move-into-subtree to be merged with the rename-outside-subtree
+  test_svnmover2(sbox, '',
+                 reported_mg_diff() +
+                 reported_br_diff('branches/br1') +
+                 reported_move('B3', 'A/B3'),
+                'merge trunk/A@4 branches/br1/A trunk/A@2')
 
 ######################################################################
 
@@ -1654,6 +1704,7 @@ test_list = [ None,
               replace_via_rm_cp,
               see_the_revision_just_committed,
               simple_branch,
+              merge_move_into_subtree,
             ]
 
 if __name__ == '__main__':

Modified: subversion/branches/ra-git/tools/dev/svnmover/merge3.c
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/tools/dev/svnmover/merge3.c?rev=1717845&r1=1717844&r2=1717845&view=diff
==============================================================================
--- subversion/branches/ra-git/tools/dev/svnmover/merge3.c (original)
+++ subversion/branches/ra-git/tools/dev/svnmover/merge3.c Thu Dec  3 20:47:21 2015
@@ -50,6 +50,9 @@
 
 /* ====================================================================== */
 
+#define is_branch_root_element(branch, eid) \
+  (svn_branch__root_eid(branch) == (eid))
+
 /* Return a string suitable for appending to a displayed element name or
  * element id to indicate that it is a subbranch root element for SUBBRANCH.
  * Return "" if SUBBRANCH is null.
@@ -1124,6 +1127,9 @@ detect_orphans(apr_hash_t **orphans_p,
 
 /* Merge ...
  *
+ * The elements to merge are the union of the elements in the three input
+ * subtrees (SRC, TGT, YCA).
+ *
  * Merge any sub-branches in the same way, recursively.
  *
  * ### TODO: Store the merge result separately, without overwriting the
@@ -1173,14 +1179,12 @@ branch_merge_subtree_r(svn_branch__txn_t
   SVN_ERR(svn_branch__get_subtree(src->branch, &s_src, src->eid, scratch_pool));
   SVN_ERR(svn_branch__get_subtree(tgt->branch, &s_tgt, tgt->eid, scratch_pool));
   SVN_ERR(svn_branch__get_subtree(yca->branch, &s_yca, yca->eid, scratch_pool));
-  SVN_ERR(svnmover_element_differences(&diff_yca_src,
-                                       s_yca->tree, s_src->tree,
-                                       scratch_pool, scratch_pool));
-  /* ### We only need to query for YCA:TO differences in elements that are
-         different in YCA:FROM, but right now we ask for all differences. */
-  SVN_ERR(svnmover_element_differences(&diff_yca_tgt,
-                                       s_yca->tree, s_tgt->tree,
-                                       scratch_pool, scratch_pool));
+
+  /* ALL_ELEMENTS enumerates the elements in union of subtrees YCA,SRC,TGT. */
+  all_elements = hash_overlay(s_src->tree->e_map,
+                              s_tgt->tree->e_map);
+  all_elements = hash_overlay(s_yca->tree->e_map,
+                              all_elements);
 
   SVN_ERR(svn_branch__state_get_elements(src->branch, &src_elements,
                                          scratch_pool));
@@ -1188,10 +1192,21 @@ branch_merge_subtree_r(svn_branch__txn_t
                                          scratch_pool));
   SVN_ERR(svn_branch__state_get_elements(yca->branch, &yca_elements,
                                          scratch_pool));
-  all_elements = hash_overlay(src_elements->e_map,
-                              tgt_elements->e_map);
-  all_elements = hash_overlay(yca_elements->e_map,
-                              all_elements);
+
+  /* Find the two changes for each element that is in any of the subtrees,
+     even for an element that is (for example) not in YCA or SRC but has
+     been moved into TGT. */
+  SVN_ERR(svnmover_element_differences(&diff_yca_src,
+                                       yca_elements, src_elements,
+                                       all_elements,
+                                       scratch_pool, scratch_pool));
+  /* ### We only need to know about YCA:TGT differences for elements that
+         differ in YCA:SRC, but right now we ask for all differences. */
+  SVN_ERR(svnmover_element_differences(&diff_yca_tgt,
+                                       yca_elements, tgt_elements,
+                                       all_elements,
+                                       scratch_pool, scratch_pool));
+
   for (SVN_EID__HASH_ITER_SORTED_BY_EID(ei, all_elements, scratch_pool))
     {
       int eid = ei->eid;
@@ -1225,6 +1240,24 @@ branch_merge_subtree_r(svn_branch__txn_t
       e_src = e_yca_src[1];
       e_tgt = e_yca_tgt ? e_yca_tgt[1] : e_yca_src[0];
 
+      /* If some but not all of the three subtree-root elements are branch
+         roots, then we will see the parentage of this element changing to
+         or from 'no parent' in one or both sides of the merge. We want to
+         ignore this part of the difference, as parentage of a subtree root
+         element is by definition not part of a 'subtree', so blank it out.
+         (If we merged it, it could break the single-rooted-tree invariant
+         of the target branch.)
+       */
+      if (is_branch_root_element(src->branch, eid)
+          || is_branch_root_element(tgt->branch, eid)
+          || is_branch_root_element(yca->branch, eid))
+        {
+          e_src = svn_element__content_create(
+                    e_tgt->parent_eid, e_tgt->name, e_src->payload, iterpool);
+          e_yca = svn_element__content_create(
+                    e_tgt->parent_eid, e_tgt->name, e_yca->payload, iterpool);
+        }
+
       element_merge(&result, &conflict,
                     eid, e_src, e_tgt, e_yca,
                     &policy,
@@ -1236,47 +1269,38 @@ branch_merge_subtree_r(svn_branch__txn_t
           svn_eid__hash_set(e_conflicts, eid,
                             element_merge3_conflict_dup(conflict, result_pool));
         }
-      else if (e_tgt && result)
+      else
         {
-          svnmover_notify_v("M/V  e%d %s%s",
-                            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));
+          if (e_tgt && result)
+            {
+              svnmover_notify_v("M/V  e%d %s%s",
+                                eid, result->name,
+                                subbranch_str(tgt->branch, eid, iterpool));
+            }
+          else if (e_tgt)
+            {
+              svnmover_notify_v("D    e%d %s%s",
+                                eid, e_yca->name,
+                                subbranch_str(yca->branch, eid, iterpool));
+
+              /* ### If this is a subbranch-root element being deleted, shouldn't
+                 we see if there were any changes to be merged in the subbranch,
+                 and raise a delete-vs-edit conflict if so? */
+            }
+          else if (result)
+            {
+              svnmover_notify_v("A    e%d %s%s",
+                                eid, result->name,
+                                subbranch_str(src->branch, eid, iterpool));
+            }
 
-          SVN_ERR(merge_subbranch(edit_txn, src, tgt, yca, eid, iterpool));
-        }
-      else if (e_tgt)
-        {
-          svnmover_notify_v("D    e%d %s%s",
-                            eid, e_yca->name,
-                            subbranch_str(yca->branch, eid, iterpool));
-          SVN_ERR(svn_branch__state_delete_one(tgt->branch, eid, iterpool));
-
-          /* ### If this is a subbranch-root element being deleted, shouldn't
-             we see if there were any changes to be merged in the subbranch,
-             and raise a delete-vs-edit conflict if so? */
-        }
-      else if (result)
-        {
-          svnmover_notify_v("A    e%d %s%s",
-                            eid, result->name,
-                            subbranch_str(src->branch, eid, iterpool));
-
-          /* In BRANCH, create an instance of the element EID with new content.
-           *
-           * Translated to old language, this means create a new node-copy
-           * copied (branched) from the source-right version of the merge
-           * (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));
+          if (result)
+            {
+              SVN_ERR(merge_subbranch(edit_txn, src, tgt, yca, eid, iterpool));
+            }
         }
     }
   svn_pool_destroy(iterpool);

Modified: subversion/branches/ra-git/tools/dev/svnmover/svnmover.c
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/tools/dev/svnmover/svnmover.c?rev=1717845&r1=1717844&r2=1717845&view=diff
==============================================================================
--- subversion/branches/ra-git/tools/dev/svnmover/svnmover.c (original)
+++ subversion/branches/ra-git/tools/dev/svnmover/svnmover.c Thu Dec  3 20:47:21 2015
@@ -484,19 +484,27 @@ svn_error_t *
 svnmover_element_differences(apr_hash_t **diff_p,
                              const svn_element__tree_t *left,
                              const svn_element__tree_t *right,
+                             apr_hash_t *elements,
                              apr_pool_t *result_pool,
                              apr_pool_t *scratch_pool)
 {
   apr_hash_t *diff = apr_hash_make(result_pool);
   apr_hash_index_t *hi;
 
+  if (! left)
+    left = svn_element__tree_create(NULL, 0 /*root_eid*/, scratch_pool);
+  if (! right)
+    right = svn_element__tree_create(NULL, 0 /*root_eid*/, scratch_pool);
+
   /*SVN_DBG(("element_differences(b%s r%ld, b%s r%ld, e%d)",
            svn_branch__get_id(left->branch, scratch_pool), left->rev,
            svn_branch__get_id(right->branch, scratch_pool), right->rev,
            right->eid));*/
 
-  for (hi = apr_hash_first(scratch_pool,
-                           hash_overlay(left->e_map, right->e_map));
+  if (!elements)
+    elements = hash_overlay(left->e_map, right->e_map);
+
+  for (hi = apr_hash_first(scratch_pool, elements);
        hi; hi = apr_hash_next(hi))
     {
       int e = svn_eid__hash_this_key(hi);
@@ -629,6 +637,7 @@ txn_is_changed(svn_branch__txn_t *edit_t
       SVN_ERR(svnmover_element_differences(&diff,
                                            edit_branch_elements,
                                            base_branch_elements,
+                                           NULL /*all elements*/,
                                            scratch_pool, scratch_pool));
       if (apr_hash_count(diff))
         {
@@ -640,28 +649,42 @@ txn_is_changed(svn_branch__txn_t *edit_t
   return SVN_NO_ERROR;
 }
 
-/* Replay differences between S_LEFT and S_RIGHT into EDITOR:EDIT_BRANCH.
+/* Replay the whole-element changes between LEFT_BRANCH and RIGHT_BRANCH
+ * into EDIT_BRANCH.
+ *
+ * Replaying means, for each element E that is changed (added, modified
+ * or deleted) between left and right branches, we set element E in
+ * EDIT_BRANCH to whole value of E in RIGHT_BRANCH. This is not like
+ * merging: each change resets an element's whole value.
  *
- * S_LEFT and/or S_RIGHT may be null meaning an empty set.
+ * ELEMENTS_TO_DIFF (eid -> [anything]) says which elements to diff; if
+ * null, diff all elements in the union of left & right branches.
+ *
+ * LEFT_BRANCH and/or RIGHT_BRANCH may be null which means the equivalent
+ * of an empty branch.
  *
  * Non-recursive: single branch only.
  */
 static svn_error_t *
-subtree_replay(svn_branch__state_t *edit_branch,
-               const svn_element__tree_t *s_left,
-               const svn_element__tree_t *s_right,
-               apr_pool_t *scratch_pool)
+branch_elements_replay(svn_branch__state_t *edit_branch,
+                       const svn_branch__state_t *left_branch,
+                       const svn_branch__state_t *right_branch,
+                       apr_hash_t *elements_to_diff,
+                       apr_pool_t *scratch_pool)
 {
+  svn_element__tree_t *s_left = NULL, *s_right = NULL;
   apr_hash_t *diff_left_right;
   apr_hash_index_t *hi;
 
-  if (! s_left)
-    s_left = svn_element__tree_create(NULL, 0 /*root_eid*/, scratch_pool);
-  if (! s_right)
-    s_right = svn_element__tree_create(NULL, 0 /*root_eid*/, scratch_pool);
-
+  if (left_branch)
+    SVN_ERR(svn_branch__state_get_elements(left_branch, &s_left,
+                                           scratch_pool));
+  if (right_branch)
+    SVN_ERR(svn_branch__state_get_elements(right_branch, &s_right,
+                                           scratch_pool));
   SVN_ERR(svnmover_element_differences(&diff_left_right,
                                        s_left, s_right,
+                                       elements_to_diff,
                                        scratch_pool, scratch_pool));
 
   /* Go through the per-element differences. */
@@ -676,26 +699,8 @@ subtree_replay(svn_branch__state_t *edit
                      || svn_element__payload_invariants(e0->payload));
       SVN_ERR_ASSERT(!e1
                      || svn_element__payload_invariants(e1->payload));
-      if (e0 || e1)
-        {
-          if (e0 && e1)
-            {
-              SVN_ERR(svn_branch__state_alter_one(edit_branch, eid,
-                                                  e1->parent_eid, e1->name,
-                                                  e1->payload, scratch_pool));
-            }
-          else if (e0)
-            {
-              SVN_ERR(svn_branch__state_delete_one(edit_branch, eid,
-                                                   scratch_pool));
-            }
-          else
-            {
-              SVN_ERR(svn_branch__state_alter_one(edit_branch, eid,
-                                                  e1->parent_eid, e1->name,
-                                                  e1->payload, scratch_pool));
-            }
-        }
+      SVN_ERR(svn_branch__state_set_element(edit_branch, eid,
+                                            e1, scratch_pool));
     }
 
   return SVN_NO_ERROR;
@@ -748,17 +753,10 @@ svn_branch__replay(svn_branch__txn_t *ed
   if (right_branch)
     {
       /* Replay this branch */
-      svn_element__tree_t *s_left = NULL;
-      svn_element__tree_t *s_right = NULL;
+      apr_hash_t *elements_to_diff = NULL;  /*means the union of left & right*/
 
-      if (left_branch)
-        SVN_ERR(svn_branch__state_get_elements(left_branch, &s_left,
-                                               scratch_pool));
-      if (right_branch)
-        SVN_ERR(svn_branch__state_get_elements(right_branch, &s_right,
-                                               scratch_pool));
-      SVN_ERR(subtree_replay(edit_branch, s_left, s_right,
-                             scratch_pool));
+      SVN_ERR(branch_elements_replay(edit_branch, left_branch, right_branch,
+                                     elements_to_diff, scratch_pool));
     }
   else
     {
@@ -941,22 +939,19 @@ update_wc_base_r(svnmover_wc_t *wc,
                  svn_revnum_t new_rev,
                  apr_pool_t *scratch_pool)
 {
-  svn_element__tree_t *base_elements, *working_elements;
+  svn_element__tree_t *base_elements = NULL, *working_elements = NULL;
   apr_hash_t *committed_elements;
   apr_hash_index_t *hi;
 
   if (base_branch)
     SVN_ERR(svn_branch__state_get_elements(base_branch, &base_elements,
                                            scratch_pool));
-  else
-    base_elements = svn_element__tree_create(NULL, 0, scratch_pool);
   if (work_branch)
     SVN_ERR(svn_branch__state_get_elements(work_branch, &working_elements,
                                            scratch_pool));
-  else
-    working_elements = svn_element__tree_create(NULL, 0, scratch_pool);
   SVN_ERR(svnmover_element_differences(&committed_elements,
                                        base_elements, working_elements,
+                                       NULL /*all elements*/,
                                        scratch_pool, scratch_pool));
 
   for (hi = apr_hash_first(scratch_pool, committed_elements);
@@ -968,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 */
@@ -1872,6 +1863,7 @@ typedef struct diff_item_t
 } diff_item_t;
 
 /* Return differences between branch subtrees S_LEFT and S_RIGHT.
+ * Diff the union of S_LEFT's and S_RIGHT's elements.
  *
  * Set *DIFF_CHANGES to a hash of (eid -> diff_item_t).
  *
@@ -1893,6 +1885,7 @@ subtree_diff(apr_hash_t **diff_changes,
 
   SVN_ERR(svnmover_element_differences(&diff_left_right,
                                        s_left->tree, s_right->tree,
+                                       NULL /*union of s_left & s_right*/,
                                        result_pool, scratch_pool));
 
   for (hi = apr_hash_first(scratch_pool, diff_left_right);
@@ -1950,6 +1943,8 @@ diff_ordering_major_paths(const struct s
 /* Display differences between subtrees LEFT and RIGHT, which are subtrees
  * of branches LEFT_BID and RIGHT_BID respectively.
  *
+ * Diff the union of LEFT's and RIGHT's elements.
+ *
  * Use EDITOR to fetch content when needed.
  *
  * Write a line containing HEADER before any other output, if it is not

Modified: subversion/branches/ra-git/tools/dev/svnmover/svnmover.h
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/tools/dev/svnmover/svnmover.h?rev=1717845&r1=1717844&r2=1717845&view=diff
==============================================================================
--- subversion/branches/ra-git/tools/dev/svnmover/svnmover.h (original)
+++ subversion/branches/ra-git/tools/dev/svnmover/svnmover.h Thu Dec  3 20:47:21 2015
@@ -94,7 +94,12 @@ typedef struct svnmover_wc_version_t
 } svnmover_wc_version_t;
 
 /* Return (left, right) pairs of element content that differ between
- * subtrees LEFT and RIGHT.
+ * LEFT and RIGHT.
+ *
+ * Examine only the elements listed in ELEMENTS, a hash of (eid ->
+ * [anything]). If ELEMENTS is NULL, use the union of LEFT and RIGHT.
+ *
+ * LEFT and/or RIGHT may be null, meaning an empty set of elements.
  *
  * Set *DIFF_P to a hash of (eid -> (svn_element__content_t *)[2]).
  */
@@ -102,6 +107,7 @@ svn_error_t *
 svnmover_element_differences(apr_hash_t **diff_p,
                              const svn_element__tree_t *left,
                              const svn_element__tree_t *right,
+                             apr_hash_t *elements,
                              apr_pool_t *result_pool,
                              apr_pool_t *scratch_pool);
 
@@ -157,8 +163,10 @@ struct conflict_storage_t
 
 /* Merge SRC into TGT, using the common ancestor YCA.
  *
- * Merge the two sets of changes: YCA -> SRC and YCA -> TGT, applying
- * the result to the transaction at TGT.
+ * The elements to merge are the union of the elements in the three input
+ * subtrees (SRC, TGT, YCA). For each such element, merge the two changes:
+ * YCA -> SRC and YCA -> TGT, applying the result to TGT which is assumed
+ * to be a branch in EDIT_TXN.
  *
  * If conflicts arise, return them in *CONFLICT_STORAGE_P; otherwise set
  * that to null.



Mime
View raw message