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/10/27 18:02:31 UTC

svn commit: r1710847 - in /subversion/branches/move-tracking-2/subversion/svnmover: merge3.c svnmover.c

Author: julianfoad
Date: Tue Oct 27 17:02:31 2015
New Revision: 1710847

URL: http://svn.apache.org/viewvc?rev=1710847&view=rev
Log:
On the 'move-tracking-2' branch: Allow merge/update/switch to operate even
when the branch root eid differs, as this is well defined, but give a
warning at the application level as it is unusual.

Such merges don't quite work as intended at the moment -- they tend to lose
changes silently -- but that's a separate bug.

* subversion/svnmover/merge3.c
  (branch_merge_subtree_r): Remove assertion.
  (svnmover_branch_merge): Remove error.

* subversion/svnmover/svnmover.c
  (do_switch): Detect the existence of local changes, instead of assuming
    there are some. Warn if switching to a branch with different root
    element if there are local changes. Correct some doc string errors.
  (execute): Warn if merging branches with differing root element.

Modified:
    subversion/branches/move-tracking-2/subversion/svnmover/merge3.c
    subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c

Modified: subversion/branches/move-tracking-2/subversion/svnmover/merge3.c
URL: http://svn.apache.org/viewvc/subversion/branches/move-tracking-2/subversion/svnmover/merge3.c?rev=1710847&r1=1710846&r2=1710847&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/svnmover/merge3.c (original)
+++ subversion/branches/move-tracking-2/subversion/svnmover/merge3.c Tue Oct 27 17:02:31 2015
@@ -720,9 +720,6 @@ branch_merge_subtree_r(svn_branch_txn_t
   const merge_conflict_policy_t policy = { TRUE, TRUE, TRUE, TRUE, TRUE };
   apr_pool_t *iterpool = svn_pool_create(scratch_pool);
 
-  SVN_ERR_ASSERT(src->eid == tgt->eid);
-  SVN_ERR_ASSERT(src->eid == yca->eid);
-
   SVN_DBG(("merge src: r%2ld %s e%3d",
            src->rev,
            svn_branch_get_id(src->branch, scratch_pool), src->eid));
@@ -882,11 +879,6 @@ svnmover_branch_merge(svn_branch_txn_t *
   /*SVN_ERR(verify_exists_in_branch(from, scratch_pool));*/
   /*SVN_ERR(verify_exists_in_branch(to, scratch_pool));*/
   /*SVN_ERR(verify_exists_in_branch(yca, scratch_pool));*/
-  if (src->eid != tgt->eid || src->eid != yca->eid)
-    return svn_error_createf(SVN_ERR_BRANCHING, NULL,
-                             _("Merge branches must all be same element "
-                               "(from: e%d, to: e%d, yca: e%d)"),
-                             src->eid, tgt->eid, yca->eid);
   /*SVN_ERR(verify_not_subbranch_root(from, scratch_pool));*/
   /*SVN_ERR(verify_not_subbranch_root(to, scratch_pool));*/
   /*SVN_ERR(verify_not_subbranch_root(yca, scratch_pool));*/

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=1710847&r1=1710846&r2=1710847&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c (original)
+++ subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c Tue Oct 27 17:02:31 2015
@@ -1218,8 +1218,8 @@ list_all_branches(svn_branch_txn_t *txn,
   return SVN_NO_ERROR;
 }
 
-/* Switch the WC to revision BASE_REVISION (SVN_INVALID_REVNUM means HEAD)
- * and branch BRANCH_ID.
+/* Switch the WC to revision REVISION (SVN_INVALID_REVNUM means HEAD)
+ * and branch TARGET_BRANCH.
  *
  * Merge any changes in the existing txn into the new txn.
  */
@@ -1234,19 +1234,25 @@ do_switch(svnmover_wc_t *wc,
   /* Keep hold of the previous WC txn */
   svn_branch_state_t *previous_base_br = wc->base->branch;
   svn_branch_state_t *previous_working_br = wc->working->branch;
-  svn_boolean_t has_local_changes = TRUE /* ### wc_has_local_changes(wc) */;
+  svn_boolean_t has_local_changes;
 
+  SVN_ERR(txn_is_changed(previous_working_br->txn,
+                         &has_local_changes, scratch_pool));
+
+  /* Usually one would switch the WC to another branch (or just another
+     revision) rooted at the same element. Switching to a branch rooted
+     at a different element is well defined, but give a warning. */
   if (has_local_changes
       && svn_branch_root_eid(target_branch)
          != svn_branch_root_eid(previous_base_br))
     {
-      return svn_error_createf(SVN_ERR_BRANCHING, NULL,
-                               _("Cannot switch to branch '%s' and preserve "
-                                 "local changes as the new root element e%d "
-                                 "is not related to the old root element e%d"),
-                               target_branch_id,
-                               svn_branch_root_eid(target_branch),
-                               svn_branch_root_eid(previous_base_br));
+      notify(_("Warning: you are switching from %s rooted at e%d "
+               "to %s rooted at e%d, a different root element, "
+               "while there are local changes. "),
+             svn_branch_get_id(previous_base_br, scratch_pool),
+             svn_branch_root_eid(previous_base_br),
+             target_branch_id,
+             svn_branch_root_eid(target_branch));
     }
 
   /* Complete the old edit drive into the 'WC' txn */
@@ -2802,6 +2808,13 @@ execute(svnmover_wc_t *wc,
             VERIFY_EID_EXISTS("merge", 0);
             VERIFY_EID_EXISTS("merge", 1);
             VERIFY_EID_EXISTS("merge", 2);
+            if (arg[0]->el_rev->eid != arg[1]->el_rev->eid
+                || arg[0]->el_rev->eid != arg[2]->el_rev->eid)
+              {
+                notify(_("Warning: root elements differ in the requested merge "
+                         "(from: e%d, to: e%d, yca: e%d)"),
+                       arg[0]->el_rev->eid, arg[1]->el_rev->eid, arg[2]->el_rev->eid);
+              }
             SVN_ERR(svnmover_branch_merge(wc->edit_txn,
                                           &conflicts,
                                           arg[0]->el_rev /*from*/,