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 2012/03/15 11:49:13 UTC

svn commit: r1300906 - in /subversion/trunk/subversion: include/private/svn_wc_private.h libsvn_client/merge.c

Author: julianfoad
Date: Thu Mar 15 10:49:12 2012
New Revision: 1300906

URL: http://svn.apache.org/viewvc?rev=1300906&view=rev
Log:
Make the reintegrate merge APIs throw an error instead of an assertion
failure if the target WC is a locally added node.  This was not triggered by
the current 'svn' client but could be triggered by other clients.

merge_tests.py 111 and 112 exercise the 'locally added node' code path in
the function target_node_location().  I tested the new error code in the
function find_reintegrate_merge() by temporarily disabling the source and
target relatedness check in svn/merge-cmd.c and running reintegrate merges
manually.

* subversion/include/private/svn_wc_private.h
  (svn_wc__node_get_origin): Correct the documentation of what this does for
    a copied node and for an added node.

* subversion/libsvn_client/merge.c
  (merge_target_t): Correct a doc string: s/NULL/SVN_INVALID_REVNUM/.
  (target_node_location): Add a comment explaining the code path for an
    added node. Assert that the required outputs are produced.
  (find_reintegrate_merge): Throw a friendly error if the target is a
    locally added node, to prevent an assertion failure later on.

Modified:
    subversion/trunk/subversion/include/private/svn_wc_private.h
    subversion/trunk/subversion/libsvn_client/merge.c

Modified: subversion/trunk/subversion/include/private/svn_wc_private.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/private/svn_wc_private.h?rev=1300906&r1=1300905&r2=1300906&view=diff
==============================================================================
--- subversion/trunk/subversion/include/private/svn_wc_private.h (original)
+++ subversion/trunk/subversion/include/private/svn_wc_private.h Thu Mar 15 10:49:12 2012
@@ -477,8 +477,9 @@ svn_wc__node_get_url(const char **url,
 
 /**
  * Retrieves the origin of the node as it is known in the repository. For
- * added nodes this retrieves where the node is copied from, and the repository
- * location for other nodes.
+ * a copied node this retrieves where the node is copied from, for an added
+ * node this returns NULL/INVALID outputs, and for any other node this
+ * retrieves the repository location.
  *
  * All output arguments may be NULL.
  *

Modified: subversion/trunk/subversion/libsvn_client/merge.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/merge.c?rev=1300906&r1=1300905&r2=1300906&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/merge.c (original)
+++ subversion/trunk/subversion/libsvn_client/merge.c Thu Mar 15 10:49:12 2012
@@ -189,7 +189,7 @@ typedef struct merge_target_t
   /* URL of the node, or NULL if node is locally added */
   const char *url;
 
-  /* Revision of the node, or NULL if node is locally added */
+  /* Revision of the node, or SVN_INVALID_REVNUM if node is locally added */
   svn_revnum_t rev;
 
   /* Repository root URL and UUID, even if node is locally added */
@@ -9284,6 +9284,9 @@ target_node_location(merge_target_t **ta
     }
   else
     {
+      /* It's probably a locally added node.  Find the repository root URL
+       * and UUID anyway, and leave the node URL and revision as NULL/INVALID.
+       * Some kinds of merge can use such a target; others can't. */
       target->url = NULL;
       SVN_ERR(svn_client_get_repos_root(&target->repos_root.url,
                                         &target->repos_root.uuid,
@@ -9291,6 +9294,7 @@ target_node_location(merge_target_t **ta
                                         ctx, result_pool, scratch_pool));
     }
 
+  SVN_ERR_ASSERT(target->repos_root.url && target->repos_root.uuid);
   *target_p = target;
   return SVN_NO_ERROR;
 }
@@ -10438,6 +10442,14 @@ find_reintegrate_merge(svn_ra_session_t 
   svn_error_t *err;
   apr_hash_t *subtrees_with_mergeinfo;
 
+  if (! target->url)
+    return svn_error_createf(SVN_ERR_CLIENT_UNRELATED_RESOURCES, NULL,
+                             _("Can't reintegrate into '%s' because it is "
+                               "locally added and therefore not related to "
+                               "the merge source"),
+                             svn_dirent_local_style(target->abspath,
+                                                    scratch_pool));
+
   /* Make sure we're dealing with a real URL. */
   SVN_ERR(svn_client_url_from_path2(&source_url, source_path_or_url, ctx,
                                     scratch_pool, scratch_pool));