You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by pb...@apache.org on 2011/08/30 23:03:51 UTC

svn commit: r1163383 - in /subversion/trunk/subversion: libsvn_client/mergeinfo.c tests/cmdline/mergeinfo_tests.py

Author: pburba
Date: Tue Aug 30 21:03:50 2011
New Revision: 1163383

URL: http://svn.apache.org/viewvc?rev=1163383&view=rev
Log:
Fix issue #3791 'svn mergeinfo shows natural history of added subtrees as
eligible'.

* subversion/libsvn_client/mergeinfo.c

  (find_nearest_ancestor): Add output parameter to signal if a path's
   nearest "ancestor" is actually the path itself.

  (filter_log_entry_with_rangelist): Don't consider as eligible a path
   deleted, added, or replaced in the merge source if the path exits in the
   target and has mergeinfo describing merges younger than the
   deletion/addition/replacement.

* subversion/tests/cmdline/mergeinfo_tests.py

  (natural_history_is_not_eligible_nor_merged): Remove XFail decorators and
   comments.

Modified:
    subversion/trunk/subversion/libsvn_client/mergeinfo.c
    subversion/trunk/subversion/tests/cmdline/mergeinfo_tests.py

Modified: subversion/trunk/subversion/libsvn_client/mergeinfo.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/mergeinfo.c?rev=1163383&r1=1163382&r2=1163383&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/mergeinfo.c (original)
+++ subversion/trunk/subversion/libsvn_client/mergeinfo.c Tue Aug 30 21:03:50 2011
@@ -1320,16 +1320,20 @@ svn_client__elide_mergeinfo_catalog(svn_
    Return a pointer to the mergeinfo value of the nearest path-wise ancestor
    of ABS_REPOS_PATH in DEPTH_FIRST_CATALOG_INDEX.  A path is considered its
    own ancestor, so if a key exactly matches ABS_REPOS_PATH, return that
-   key's mergeinfo.
+   key's mergeinfo and set *ANCESTOR_IS_SELF to true (set it to false in all
+   other cases).
 
    If DEPTH_FIRST_CATALOG_INDEX is NULL, empty, or no ancestor is found, then
    return NULL. */
 static svn_mergeinfo_t
 find_nearest_ancestor(const apr_array_header_t *depth_first_catalog_index,
+                      svn_boolean_t *ancestor_is_self,
                       const char *abs_repos_path)
 {
   int ancestor_index = -1;
 
+  *ancestor_is_self = FALSE;
+
   if (depth_first_catalog_index)
     {
       int i;
@@ -1338,9 +1342,18 @@ find_nearest_ancestor(const apr_array_he
         {
           svn_sort__item_t item = APR_ARRAY_IDX(depth_first_catalog_index, i,
                                                 svn_sort__item_t);
-          if (svn_fspath__is_ancestor(item.key, abs_repos_path)
-              || svn_path_compare_paths(item.key, abs_repos_path) == 0)
-            ancestor_index = i;
+          if (svn_fspath__is_ancestor(item.key, abs_repos_path))
+            {
+              ancestor_index = i;
+
+              /* There's no nearer ancestor than ABS_REPOS_PATH itself. */
+              if (strcmp(item.key, abs_repos_path) == 0)
+                {
+                  *ancestor_is_self = TRUE;
+                  break;
+                }
+            }
+
         }
     }
 
@@ -1467,6 +1480,7 @@ filter_log_entry_with_rangelist(void *ba
           svn_boolean_t found_this_revision = FALSE;
           const char *merge_source_rel_target;
           const char *merge_source_path;
+          svn_boolean_t ancestor_is_self;
 
           svn_pool_clear(iterpool);
 
@@ -1502,7 +1516,36 @@ filter_log_entry_with_rangelist(void *ba
 
           nearest_ancestor_mergeinfo =
             find_nearest_ancestor(fleb->depth_first_catalog_index,
+                                  &ancestor_is_self,
                                   target_path_affected);
+
+          /* Issue #3791: A path should never have explicit mergeinfo
+             describing its own addition (that's self-referential).  Nor will
+             it have explicit mergeinfo describing its own deletion (we
+             obviously can't add new mergeinfo to a path we are deleting).
+
+             This lack of explicit mergeinfo should not cause such revisions
+             to show up as eligible however.  If PATH was deleted, replaced,
+             or added in LOG_ENTRY->REVISION, but the corresponding
+             TARGET_PATH_AFFECTED already exists and has explicit mergeinfo
+             describing merges from PATH *after* LOG_ENTRY->REVISION, then
+             ignore this PATH.  If it was deleted in LOG_ENTRY->REVISION it's
+             obviously back.  If it was added or replaced it's still around
+             possibly it was replaced one or more times, but it's back now.
+             Regardless, LOG_ENTRY->REVISION is *not* an eligible revision! */
+          if (ancestor_is_self /* Explicit mergeinfo on TARGET_PATH_AFFECTED */
+              && (change->action != 'M'))
+            {
+              apr_array_header_t *rangelist = apr_hash_get(
+                nearest_ancestor_mergeinfo, path, APR_HASH_KEY_STRING);
+              svn_merge_range_t *youngest_range = APR_ARRAY_IDX(
+                rangelist, rangelist->nelts - 1, svn_merge_range_t *);
+
+              if (youngest_range
+                  && (youngest_range->end > log_entry->revision))
+                continue;
+            }
+
           if (nearest_ancestor_mergeinfo)
             {
               for (hi2 = apr_hash_first(iterpool, nearest_ancestor_mergeinfo);

Modified: subversion/trunk/subversion/tests/cmdline/mergeinfo_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/mergeinfo_tests.py?rev=1163383&r1=1163382&r2=1163383&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/mergeinfo_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/mergeinfo_tests.py Tue Aug 30 21:03:50 2011
@@ -628,7 +628,6 @@ def wc_target_inherits_mergeinfo_from_re
 # A test for issue 3791 'svn mergeinfo shows natural history of added
 # subtrees as eligible'.
 @Issue(3791)
-@XFail()
 @SkipUnless(server_has_mergeinfo)
 def natural_history_is_not_eligible_nor_merged(sbox):
   "natural history is not eligible nor merged"
@@ -669,29 +668,12 @@ def natural_history_is_not_eligible_nor_
   # that svn mergeinfo -R agrees.
   #
   # First check if there are eligible revisions, there should be none.
-  #
-  # This fails because r7 is reported as only partially merged:
-  #
-  #   >svn mergeinfo --show-revs eligible ^/A A_COPY -R
-  #   r7*
-  #
-  # ...But r7 is the addition of A/C/nu, which we clearly merged in r8.
   svntest.actions.run_and_verify_mergeinfo(
     adjust_error_for_server_version(''),
     [], sbox.repo_url + '/A',
     A_COPY_path, '--show-revs', 'eligible', '-R')
 
   # Now check that all operative revisions show as merged.
-  #
-  # This fails because r7 is reported as only partially merged:
-  #
-  #   >svn mergeinfo --show-revs merged ^/A A_COPY -R
-  #   r3
-  #   r4
-  #   r5
-  #   r6
-  #   r7*
-  #   r9
   svntest.actions.run_and_verify_mergeinfo(
     adjust_error_for_server_version(''),
     ['3','4','5','6','7','9'], sbox.repo_url + '/A',