You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2011/03/10 18:11:42 UTC

svn commit: r1080285 - in /subversion/trunk/subversion: libsvn_client/merge.c tests/cmdline/merge_reintegrate_tests.py

Author: stsp
Date: Thu Mar 10 17:11:42 2011
New Revision: 1080285

URL: http://svn.apache.org/viewvc?rev=1080285&view=rev
Log:
Make 'svn merge' use individual checks to determine suitability of the
merge target, instead of svn_wc_revision_status2() (which will always
run all checks). Perform the cheap checks first, and don't run more
expensive checks unless required.

* subversion/tests/cmdline/merge_reintegrate_tests.py
  (reintegrate_fail_on_modified_wc, reintegrate_fail_on_switched_wc):
   These tests were relying on the order in which checks are performed.
   They were suddenly failing because of mixed revisions, instead of
   the expected errors (local mods and switched subtrees, respectively).
   Update working copies before performing a merge so that the expected
   error is raised.

* subversion/libsvn_client/merge.c
  (ensure_wc_is_suitable_merge_target): Call svn_wc__min_max_revisions(),
   svn_wc__has_switched_subtrees(), and svn_wc__has_local_mods(), in that
   order, instead of calling svn_wc_revision_status2().

Modified:
    subversion/trunk/subversion/libsvn_client/merge.c
    subversion/trunk/subversion/tests/cmdline/merge_reintegrate_tests.py

Modified: subversion/trunk/subversion/libsvn_client/merge.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/merge.c?rev=1080285&r1=1080284&r2=1080285&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/merge.c (original)
+++ subversion/trunk/subversion/libsvn_client/merge.c Thu Mar 10 17:11:42 2011
@@ -8987,31 +8987,20 @@ ensure_wc_is_suitable_merge_target(const
                                    svn_boolean_t allow_switched_subtrees,
                                    apr_pool_t *scratch_pool)
 {
-  svn_wc_revision_status_t *wc_stat;
-
-  /* Avoid the following status crawl if we don't need it. */
+  /* Avoid the following checks if we don't need them. */
   if (allow_mixed_rev && allow_local_mods && allow_switched_subtrees)
     return SVN_NO_ERROR;
 
-  /* Get a WC summary with min/max revisions set to the BASE revision. */
-  SVN_ERR(svn_wc_revision_status2(&wc_stat, ctx->wc_ctx, target_abspath, NULL,
-                                  FALSE, ctx->cancel_func, ctx->cancel_baton,
-                                  scratch_pool, scratch_pool));
-
-  if (! allow_switched_subtrees && wc_stat->switched)
-    return svn_error_create(SVN_ERR_CLIENT_NOT_READY_TO_MERGE, NULL,
-                            _("Cannot merge into a working copy "
-                              "with a switched subtree"));
-
-  if (! allow_local_mods && wc_stat->modified)
-    return svn_error_create(SVN_ERR_CLIENT_NOT_READY_TO_MERGE, NULL,
-                            _("Cannot merge into a working copy "
-                              "that has local modifications"));
-
+  /* Perform the mixed-revision check first because it's the cheapest one. */
   if (! allow_mixed_rev)
     {
-      if (! (SVN_IS_VALID_REVNUM(wc_stat->min_rev)
-             && SVN_IS_VALID_REVNUM(wc_stat->max_rev)))
+      svn_revnum_t min_rev;
+      svn_revnum_t max_rev;
+
+      SVN_ERR(svn_wc__min_max_revisions(&min_rev, &max_rev, ctx->wc_ctx,
+                                        target_abspath, FALSE, scratch_pool));
+
+      if (!(SVN_IS_VALID_REVNUM(min_rev) && SVN_IS_VALID_REVNUM(max_rev)))
         {
           svn_boolean_t is_added;
 
@@ -9026,11 +9015,38 @@ ensure_wc_is_suitable_merge_target(const
                                       "copy"));
         }
 
-      if (wc_stat->min_rev != wc_stat->max_rev)
+      if (min_rev != max_rev)
         return svn_error_createf(SVN_ERR_CLIENT_NOT_READY_TO_MERGE, NULL,
                                  _("Cannot merge into mixed-revision working "
                                    "copy [%lu:%lu]; try updating first"),
-                                   wc_stat->min_rev, wc_stat->max_rev);
+                                   min_rev, max_rev);
+    }
+
+  /* Next, check for switched subtrees. */
+  if (! allow_switched_subtrees)
+    {
+      svn_boolean_t is_switched;
+
+      SVN_ERR(svn_wc__has_switched_subtrees(&is_switched, ctx->wc_ctx,
+                                            target_abspath, NULL,
+                                            scratch_pool));
+      if (is_switched)
+        return svn_error_create(SVN_ERR_CLIENT_NOT_READY_TO_MERGE, NULL,
+                                _("Cannot merge into a working copy "
+                                  "with a switched subtree"));
+    }
+
+  /* This is the most expensive check, so it is performed last.*/
+  if (! allow_local_mods)
+    {
+      svn_boolean_t is_modified;
+
+      SVN_ERR(svn_wc__has_local_mods(&is_modified, ctx->wc_ctx,
+                                     target_abspath, scratch_pool));
+      if (is_modified)
+        return svn_error_create(SVN_ERR_CLIENT_NOT_READY_TO_MERGE, NULL,
+                                _("Cannot merge into a working copy "
+                                  "that has local modifications"));
     }
 
   return SVN_NO_ERROR;

Modified: subversion/trunk/subversion/tests/cmdline/merge_reintegrate_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/merge_reintegrate_tests.py?rev=1080285&r1=1080284&r2=1080285&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/merge_reintegrate_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/merge_reintegrate_tests.py Thu Mar 10 17:11:42 2011
@@ -672,6 +672,7 @@ def reintegrate_fail_on_modified_wc(sbox
   mu_path = os.path.join(A_path, "mu")
   ignored_expected_disk, ignored_expected_status = set_up_branch(sbox)
   svntest.main.file_write(mu_path, "Changed on 'trunk' (the merge target).")
+  sbox.simple_update() # avoid mixed-revision error
   svntest.actions.run_and_verify_merge(
     A_path, None, None, sbox.repo_url + '/A_COPY', None, None, None, None,
     None, None, None,
@@ -740,6 +741,7 @@ def reintegrate_fail_on_switched_wc(sbox
                                         expected_disk,
                                         expected_status,
                                         None, None, None, None, False);
+  sbox.simple_update() # avoid mixed-revision error
   svntest.actions.run_and_verify_merge(
     A_path, None, None, sbox.repo_url + '/A_COPY', None, None, None, None,
     None, None, None,