subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From julianf...@apache.org
Subject svn commit: r1463250 - in /subversion/trunk/subversion: include/svn_client.h libsvn_client/merge.c svn/merge-cmd.c tests/cmdline/svntest/deeptrees.py
Date Mon, 01 Apr 2013 19:02:33 GMT
Author: julianfoad
Date: Mon Apr  1 19:02:33 2013
New Revision: 1463250

URL: http://svn.apache.org/r1463250
Log:
Teach svn_client_merge_peg5() to do an automatic merge when no revision
ranges are specified, and let 'svn merge' rely on that instead of calling
the dedicated automatic merge APIs.

This leaves the dedicated 'automatic merge' APIs in place for now; we might
want to remove them or make them private.

This reduces the amount of progress feedback displayed when running an
automatic merge with the new '--verbose' option: the two phases that were
introduced by 'Calculating automatic merge' and 'Merging' messages are now
introduced by a single 'Merging' message.

* subversion/include/svn_client.h,
  subversion/libsvn_client/merge.c
  (svn_client_merge_peg5): Do an automatic merge if no revision range is
    specified.
  (svn_client_merge_peg4): Tweak the doc string to account for this change.

* subversion/svn/merge-cmd.c
  (automatic_merge): Delete.
  (run_merge): Don't take special action to handle an automatic merge, let
    the pegged merge code path handle it.

* subversion/tests/cmdline/svntest/deeptrees.py
  (deep_trees_run_tests_scheme_for_merge): To keep the tests working, specify
    a revision range to the merge so that it will still be allowed even when
    using 'ignore ancestry'.  In other words, avoid invoking the automatic
    merge checks.

Modified:
    subversion/trunk/subversion/include/svn_client.h
    subversion/trunk/subversion/libsvn_client/merge.c
    subversion/trunk/subversion/svn/merge-cmd.c
    subversion/trunk/subversion/tests/cmdline/svntest/deeptrees.py

Modified: subversion/trunk/subversion/include/svn_client.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_client.h?rev=1463250&r1=1463249&r2=1463250&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_client.h (original)
+++ subversion/trunk/subversion/include/svn_client.h Mon Apr  1 19:02:33 2013
@@ -3792,10 +3792,23 @@ svn_client_merge_reintegrate(const char 
                              apr_pool_t *pool);
 
 /**
- * Merge the changes between the filesystem object @a source_path_or_url in peg
- * revision @a source_peg_revision, as it changed between the ranges described
- * in @a ranges_to_merge.
- *
+ * Merge changes from the source branch identified by
+ * @a source_path_or_url in peg revision @a source_peg_revision,
+ * into the target branch working copy at @a target_wcpath.
+ *
+ * If @a ranges_to_merge is NULL then perform an automatic merge of
+ * all the eligible changes up to @a source_peg_revision.  Do this in
+ * the same way as calling svn_client_find_automatic_merge() and then
+ * svn_client_do_automatic_merge().  If the merge is determined to be
+ * of the 'reintegrate' kind, then return an error if the WC contains
+ * mixed revisions, local modifications and/or switched subtrees; if
+ * the merge is determined to be of the non-reintegrate kind, then
+ * return an error if @a allow_mixed_rev is false and the WC contains
+ * mixed revisions.
+ *
+ * If @a ranges_to_merge is not NULL then merge the changes specified
+ * by the revision ranges in @a ranges_to_merge, or, when honouring
+ * mergeinfo, only the eligible parts of those revision ranges.
  * @a ranges_to_merge is an array of <tt>svn_opt_revision_range_t
  * *</tt> ranges.  These ranges may describe additive and/or
  * subtractive merge ranges, they may overlap fully or partially,
@@ -3804,6 +3817,8 @@ svn_client_merge_reintegrate(const char 
  * list of provided ranges has an `unspecified' or unrecognized
  * `kind', return #SVN_ERR_CLIENT_BAD_REVISION.
  *
+ * If @a ranges_to_merge is an empty array, then do nothing.
+ *
  * All other options are handled identically to svn_client_merge5().
  *
  * @since New in 1.8.
@@ -3825,7 +3840,8 @@ svn_client_merge_peg5(const char *source
                       apr_pool_t *pool);
 
 /**
- * Similar to svn_client_merge_peg5(), but the single @a ignore_ancestry
+ * Similar to svn_client_merge_peg5(), but automatic merge is not available
+ * (@a ranges_to_merge must not be NULL), and the single @a ignore_ancestry
  * parameter maps to both @c ignore_mergeinfo and @c diff_ignore_ancestry.
  *
  * @deprecated Provided for backward compatibility with the 1.7 API.

Modified: subversion/trunk/subversion/libsvn_client/merge.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/merge.c?rev=1463250&r1=1463249&r2=1463250&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/merge.c (original)
+++ subversion/trunk/subversion/libsvn_client/merge.c Mon Apr  1 19:02:33 2013
@@ -11762,13 +11762,43 @@ svn_client_merge_peg5(const char *source
   conflict_report_t *conflict_report;
 
   /* No ranges to merge?  No problem. */
-  if (ranges_to_merge->nelts == 0)
+  if (ranges_to_merge != NULL && ranges_to_merge->nelts == 0)
     return SVN_NO_ERROR;
 
   SVN_ERR(get_target_and_lock_abspath(&target_abspath, &lock_abspath,
                                       target_wcpath, ctx, pool));
 
-  if (!dry_run)
+  /* Do an automatic merge if no revision ranges are specified. */
+  if (ranges_to_merge == NULL)
+    {
+      svn_client_automatic_merge_t *merge;
+
+      if (ignore_mergeinfo)
+        return svn_error_create(SVN_ERR_INCORRECT_PARAMS, NULL,
+                                _("Cannot merge automatically while "
+                                  "ignoring mergeinfo"));
+
+      /* Find the details of the merge needed. */
+      SVN_ERR(svn_client_find_automatic_merge(&merge,
+                                              source_path_or_url,
+                                              source_peg_revision,
+                                              target_wcpath,
+                                              allow_mixed_rev,
+                                              TRUE /*allow_local_mods*/,
+                                              TRUE /*allow_switched_subtrees*/,
+                                              ctx, pool, pool));
+
+      SVN_ERR(svn_client_do_automatic_merge(merge, target_wcpath, depth,
+                                            diff_ignore_ancestry,
+                                            force_delete, record_only,
+                                            dry_run, merge_options,
+                                            ctx, pool));
+
+      /* We already dealt with returning any conflict error, inside the
+       * above calls. */
+      conflict_report = NULL;
+    }
+  else if (!dry_run)
     SVN_WC__CALL_WITH_WRITE_LOCK(
       merge_peg_locked(&conflict_report,
                        source_path_or_url, source_peg_revision,

Modified: subversion/trunk/subversion/svn/merge-cmd.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/merge-cmd.c?rev=1463250&r1=1463249&r2=1463250&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/merge-cmd.c (original)
+++ subversion/trunk/subversion/svn/merge-cmd.c Mon Apr  1 19:02:33 2013
@@ -63,83 +63,6 @@ ensure_wc_path_has_repo_revision(const c
   return SVN_NO_ERROR;
 }
 
-/* Automatic, merge-tracking merge, used for sync or reintegrate purposes. */
-static svn_error_t *
-automatic_merge(const char *source_path_or_url,
-                const svn_opt_revision_t *source_revision,
-                const char *target_wcpath,
-                svn_depth_t depth,
-                svn_boolean_t diff_ignore_ancestry,
-                svn_boolean_t force_delete,
-                svn_boolean_t record_only,
-                svn_boolean_t dry_run,
-                svn_boolean_t allow_mixed_rev,
-                svn_boolean_t allow_local_mods,
-                svn_boolean_t allow_switched_subtrees,
-                svn_boolean_t verbose,
-                const apr_array_header_t *merge_options,
-                svn_client_ctx_t *ctx,
-                apr_pool_t *scratch_pool)
-{
-  svn_client_automatic_merge_t *merge;
-
-  if (verbose)
-    SVN_ERR(svn_cmdline_printf(scratch_pool, _("--- Checking branch relationship\n")));
-  SVN_ERR_W(svn_cl__check_related_source_and_target(
-              source_path_or_url, source_revision,
-              target_wcpath, &unspecified_revision, ctx, scratch_pool),
-            _("Source and target must be different but related branches"));
-
-  if (verbose)
-    SVN_ERR(svn_cmdline_printf(scratch_pool, _("--- Calculating automatic merge\n")));
-
-  /* Find the 3-way merges needed (and check suitability of the WC). */
-  SVN_ERR(svn_client_find_automatic_merge(&merge,
-                                          source_path_or_url, source_revision,
-                                          target_wcpath, allow_mixed_rev,
-                                          allow_local_mods, allow_switched_subtrees,
-                                          ctx, scratch_pool, scratch_pool));
-
-  if (svn_client_automatic_merge_is_reintegrate_like(merge))
-    {
-      if (record_only)
-        return svn_error_create(SVN_ERR_CL_MUTUALLY_EXCLUSIVE_ARGS, NULL,
-                                _("The required merge is reintegrate-like, "
-                                  "and the --record-only option "
-                                  "cannot be used with this kind of merge"));
-
-      if (depth != svn_depth_unknown)
-        return svn_error_create(SVN_ERR_CL_MUTUALLY_EXCLUSIVE_ARGS, NULL,
-                                _("The required merge is reintegrate-like, "
-                                  "and the --depth option "
-                                  "cannot be used with this kind of merge"));
-
-      if (force_delete)
-        return svn_error_create(SVN_ERR_CL_MUTUALLY_EXCLUSIVE_ARGS, NULL,
-                                _("The required merge is reintegrate-like, "
-                                  "and the --force option "
-                                  "cannot be used with this kind of merge"));
-
-      if (allow_mixed_rev)
-        return svn_error_create(SVN_ERR_CL_MUTUALLY_EXCLUSIVE_ARGS, NULL,
-                                _("The required merge is reintegrate-like, "
-                                  "and the --allow-mixed-revisions option "
-                                  "cannot be used with this kind of merge"));
-    }
-
-  if (verbose)
-    SVN_ERR(svn_cmdline_printf(scratch_pool, _("--- Merging\n")));
-
-  /* Perform the 3-way merges */
-  SVN_ERR(svn_client_do_automatic_merge(merge, target_wcpath, depth,
-                                        diff_ignore_ancestry,
-                                        force_delete, record_only,
-                                        dry_run, merge_options,
-                                        ctx, scratch_pool));
-
-  return SVN_NO_ERROR;
-}
-
 /* Run a merge.
  *
  * (No docs yet, as this code was just hoisted out of svn_cl__merge().)
@@ -163,26 +86,7 @@ run_merge(svn_boolean_t two_sources_spec
 {
   svn_error_t *merge_err;
 
-  /* Do an automatic merge if just one source and no revisions. */
-  if ((! two_sources_specified)
-      && (! opt_state->reintegrate)
-      && (! opt_state->ignore_ancestry)
-      && first_range_start.kind == svn_opt_revision_unspecified
-      && first_range_end.kind == svn_opt_revision_unspecified)
-    {
-      merge_err = automatic_merge(sourcepath1, &peg_revision1, targetpath,
-                                  opt_state->depth,
-                                  FALSE /*diff_ignore_ancestry*/,
-                                  opt_state->force, /* force_delete */
-                                  opt_state->record_only,
-                                  opt_state->dry_run,
-                                  opt_state->allow_mixed_rev,
-                                  TRUE /*allow_local_mods*/,
-                                  TRUE /*allow_switched_subtrees*/,
-                                  opt_state->verbose,
-                                  options, ctx, scratch_pool);
-    }
-  else if (opt_state->reintegrate)
+  if (opt_state->reintegrate)
     {
       merge_err = svn_client_merge_reintegrate(
                     sourcepath1, &peg_revision1, targetpath,
@@ -196,13 +100,7 @@ run_merge(svn_boolean_t two_sources_spec
       if ((first_range_start.kind == svn_opt_revision_unspecified)
           && (first_range_end.kind == svn_opt_revision_unspecified))
         {
-          svn_opt_revision_range_t *range = apr_pcalloc(scratch_pool,
-                                                        sizeof(*range));
-          ranges_to_merge = apr_array_make(scratch_pool, 1, sizeof(range));
-          range->start.kind = svn_opt_revision_number;
-          range->start.value.number = 1;
-          range->end = peg_revision1;
-          APR_ARRAY_PUSH(ranges_to_merge, svn_opt_revision_range_t *) = range;
+          ranges_to_merge = NULL;
 
           /* This must be a 'sync' merge so check branch relationship. */
           if (opt_state->verbose)

Modified: subversion/trunk/subversion/tests/cmdline/svntest/deeptrees.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svntest/deeptrees.py?rev=1463250&r1=1463249&r2=1463250&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svntest/deeptrees.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svntest/deeptrees.py Mon Apr  1 19:02:33 2013
@@ -985,7 +985,7 @@ def deep_trees_run_tests_scheme_for_merg
       if ignore_ancestry:
         varargs = varargs + ('--ignore-ancestry',)
 
-      run_and_verify_merge(local, None, None, incoming, None,
+      run_and_verify_merge(local, '0', 'HEAD', incoming, None,
                            x_out, None, None, x_disk, None, x_skip,
                            test_case.error_re_string,
                            None, None, None, None,



Mime
View raw message