[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

calculate_remaining_ranges() in merge.c

From: Julian Foad <julianfoad_at_btopenworld.com>
Date: Tue, 1 May 2012 09:53:05 +0100 (BST)

I'm just trying to follow some existing code.  The comment that I'm adding in this pseudo-patch is a stalled attempt to describe the following code block.

[[[
/* Helper for do_file_merge and do_directory_merge (by way of
   populate_remaining_ranges() for the latter).

   Determine what portions of SOURCE have already been merged
   to CHILD->ABSPATH and populate CHILD->REMAINING_RANGES with
   the ranges that still need merging.

   [...]  TARGET_MERGEINFO is the working mergeinfo on CHILD.
   [...]
*/

static svn_error_t *
calculate_remaining_ranges(svn_client__merge_path_t *parent,
                           svn_client__merge_path_t *child,
                           const merge_source_t *source,
                           svn_mergeinfo_t target_mergeinfo,
                           const apr_array_header_t *implicit_src_gap,
                           svn_boolean_t child_inherits_implicit,
                           svn_ra_session_t *ra_session,
                           svn_client_ctx_t *ctx,
                           apr_pool_t *result_pool,
                           apr_pool_t *scratch_pool)
{
  const char *mergeinfo_path;
  const char *primary_url = (source->loc1->rev < source->loc2->rev)
                            ? source->loc2->url : source->loc1->url;
  svn_mergeinfo_t adjusted_target_mergeinfo = NULL;
  svn_revnum_t child_base_revision;

  /* Determine which of the requested ranges to consider merging... */
  SVN_ERR(svn_ra__get_fspath_relative_to_root(ra_session, &mergeinfo_path,
                                              primary_url, result_pool));

+ /* [Let's see if we can describe the following if-else block.]
+

+    Set ADJUSTED_TARGET_MERGEINFO to ... let's see ... in some cases,
+    the portion of CHILD's pre-merge mergeinfo that represents merges
+    from the branch-segment SOURCE.  If CHILD has no mergeinfo that
+    refers to SOURCE, this could leave it as NULL or set it to an
+    empty hash.  In other cases, set it to TARGET_MERGEINFO -- that is,
+    CHILD's current working mergeinfo, in its entirety.

+
+    [That doesn't seem too coherent.  Maybe we can better describe this
+    code block in terms of preparing for the next step:]
+

+    We need to pass mergeinfo in to filter_merged_revisions(), which says
+    its TARGET_MERGEINFO input should be "the CHILD->ABSPATH's explicit
+    or inherited mergeinfo [NULL if none, empty if empty]".  So ...
+

+    [But we're calculating something more specific here.  The doc string on
+    filter_merged_revisions() doesn't say, but apparent from this code (its
+    only caller) is that it should not always be passed the whole mergeinfo
+    of CHILD.]
+  */
  /* Consider: CHILD might have explicit mergeinfo '/MERGEINFO_PATH:M-N'
     where M-N fall into the gap in SOURCE's natural
     history allowed by 'MERGEINFO MERGE SOURCE NORMALIZATION'.  If this is
     the case, then '/MERGEINFO_PATH:N' actually refers to a completely
     different line of history than SOURCE and we
     *don't* want to consider those revisions merged already. */
  if (implicit_src_gap && child->pre_merge_mergeinfo)
    {
      apr_array_header_t *explicit_mergeinfo_gap_ranges =
        apr_hash_get(child->pre_merge_mergeinfo, mergeinfo_path,
                     APR_HASH_KEY_STRING);

      if (explicit_mergeinfo_gap_ranges)
        {
          svn_mergeinfo_t gap_mergeinfo = apr_hash_make(scratch_pool);

          apr_hash_set(gap_mergeinfo, mergeinfo_path, APR_HASH_KEY_STRING,
                       implicit_src_gap);
          SVN_ERR(svn_mergeinfo_remove2(&adjusted_target_mergeinfo,
                                        gap_mergeinfo, target_mergeinfo,
                                        FALSE, result_pool, scratch_pool));
        }
    }
  else
    {
      adjusted_target_mergeinfo = target_mergeinfo;
    }

  /* Initialize CHILD->REMAINING_RANGES and filter out revisions already
     merged (or, in the case of reverse merges, ranges not yet merged). */
  SVN_ERR(filter_merged_revisions(parent, child, mergeinfo_path,
                                  adjusted_target_mergeinfo,
                                  source->loc1->rev, source->loc2->rev,
                                  child_inherits_implicit,
                                  ra_session, ctx, result_pool,
                                  scratch_pool));

  [...]
}

- Julian
Received on 2012-05-01 10:53:42 CEST

This is an archived mail posted to the Subversion Dev mailing list.