Modified: subversion/branches/ra-git/subversion/libsvn_client/merge.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_client/merge.c?rev=1764214&r1=1764213&r2=1764214&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_client/merge.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_client/merge.c Tue Oct 11 
09:11:50 2016
@@ -215,32 +215,6 @@
 
 /*** Repos-Diff Editor Callbacks ***/
 
-/* */
-typedef struct merge_source_t
-{
-  /* "left" side URL and revision (inclusive iff youngest) */
-  const svn_client__pathrev_t *loc1;
-
-  /* "right" side URL and revision (inclusive iff youngest) */
-  const svn_client__pathrev_t *loc2;
-
-  /* True iff LOC1 is an ancestor of LOC2 or vice-versa (history-wise). */
-  svn_boolean_t ancestral;
-} merge_source_t;
-
-/* Description of the merge target root node (a WC working node) */
-typedef struct merge_target_t
-{
-  /* Absolute path to the WC node */
-  const char *abspath;
-
-  /* The repository location of the base node of the target WC.  If the node
-   * is locally added, then URL & REV are NULL & SVN_INVALID_REVNUM.
-   * REPOS_ROOT_URL and REPOS_UUID are always valid. */
-  svn_client__pathrev_t loc;
-
-} merge_target_t;
-
 typedef struct merge_cmd_baton_t {
   svn_boolean_t force_delete;         /* Delete a file/dir even if modified */
   svn_boolean_t dry_run;
@@ -1236,7 +1210,7 @@ struct merge_file_baton_t
 
   /* If a tree conflict will be installed once edited, it's reason. If a skip
      should be produced its reason. Some special values are defined. See the
-     merge_tree_baton_t for an explanation. */
+     merge_dir_baton_t for an explanation. */
   svn_wc_conflict_reason_t tree_conflict_reason;
   svn_wc_conflict_action_t tree_conflict_action;
   svn_node_kind_t tree_conflict_local_node_kind;
@@ -1295,6 +1269,15 @@ record_skip(merge_cmd_baton_t *merge_b,
   return SVN_NO_ERROR;
 }
 
+/* Forward declaration */
+static svn_client__merge_path_t *
+find_nearest_ancestor_with_intersecting_ranges(
+  svn_revnum_t *start,
+  svn_revnum_t *end,
+  const apr_array_header_t *children_with_mergeinfo,
+  svn_boolean_t path_is_own_ancestor,
+  const char *local_abspath);
+
 /* Record a tree conflict in the WC, unless this is a dry run or a record-
  * only merge, or if a tree conflict is already flagged for the VICTIM_PATH.
  * (The latter can happen if a merge-tracking-aware merge is doing multiple
@@ -1366,11 +1349,45 @@ record_tree_conflict(merge_cmd_baton_t *
             reason = svn_wc_conflict_reason_moved_here;
         }
 
-      SVN_ERR(make_conflict_versions(&left, &right, local_abspath,
-                                     merge_left_node_kind,
-                                     merge_right_node_kind,
-                                     &merge_b->merge_source, merge_b->target,
-                                     result_pool, scratch_pool));
+      if (HONOR_MERGEINFO(merge_b) && merge_b->merge_source.ancestral)
+        {
+          struct merge_source_t *source;
+          svn_client__pathrev_t *loc1;
+          svn_client__pathrev_t *loc2;
+          svn_merge_range_t range =
+            {SVN_INVALID_REVNUM, SVN_INVALID_REVNUM, TRUE};
+
+          /* We are honoring mergeinfo so do not blindly record
+           * a conflict describing the merge of
+           * SOURCE->LOC1->URL@SOURCE->LOC1->REV through
+           * SOURCE->LOC2->URL@SOURCE->LOC2->REV
+           * but figure out the actual revision range merged. */
+          (void)find_nearest_ancestor_with_intersecting_ranges(
+            &(range.start), &(range.end),
+            merge_b->notify_begin.nodes_with_mergeinfo,
+            action != svn_wc_conflict_action_delete,
+            local_abspath);
+          loc1 = svn_client__pathrev_dup(merge_b->merge_source.loc1,
+                                         scratch_pool);
+          loc2 = svn_client__pathrev_dup(merge_b->merge_source.loc2,
+                                         scratch_pool);
+          loc1->rev = range.start;
+          loc2->rev = range.end;
+          source = merge_source_create(loc1, loc2,
+                                       merge_b->merge_source.ancestral,
+                                       scratch_pool);
+          SVN_ERR(make_conflict_versions(&left, &right, local_abspath,
+                                         merge_left_node_kind,
+                                         merge_right_node_kind,
+                                         source, merge_b->target,
+                                         result_pool, scratch_pool));
+        }
+      else
+        SVN_ERR(make_conflict_versions(&left, &right, local_abspath,
+                                       merge_left_node_kind,
+                                       merge_right_node_kind,
+                                       &merge_b->merge_source, merge_b->target,
+                                       result_pool, scratch_pool));
 
       /* Fix up delete of file, add of dir replacement (or other way around) */
       if (existing_conflict != NULL && existing_conflict->src_left_version)
@@ -5481,29 +5498,16 @@ single_range_conflict_report_create(cons
   return report;
 }
 
-/* Data for reporting when a merge aborted because of raising conflicts.
- *
- * ### TODO: More info, including the ranges (or other parameters) the user
- *     needs to complete the merge.
- */
-typedef struct conflict_report_t
-{
-  const char *target_abspath;
-  /* The revision range during which conflicts were raised */
-  const merge_source_t *conflicted_range;
-  /* Was the conflicted range the last range in the whole requested merge? */
-  svn_boolean_t was_last_range;
-} conflict_report_t;
-
-/* Return a new conflict_report_t containing deep copies of the parameters,
- * allocated in RESULT_POOL. */
-static conflict_report_t *
+/* Return a new svn_client__conflict_report_t containing deep copies of the
+ * parameters, allocated in RESULT_POOL. */
+static svn_client__conflict_report_t *
 conflict_report_create(const char *target_abspath,
                        const merge_source_t *conflicted_range,
                        svn_boolean_t was_last_range,
                        apr_pool_t *result_pool)
 {
-  conflict_report_t *report = apr_palloc(result_pool, sizeof(*report));
+  svn_client__conflict_report_t *report = apr_palloc(result_pool,
+                                                     sizeof(*report));
 
   report->target_abspath = apr_pstrdup(result_pool, target_abspath);
   report->conflicted_range = merge_source_dup(conflicted_range, result_pool);
@@ -5512,11 +5516,12 @@ conflict_report_create(const char *targe
 }
 
 /* Return a deep copy of REPORT, allocated in RESULT_POOL. */
-static conflict_report_t *
-conflict_report_dup(const conflict_report_t *report,
+static svn_client__conflict_report_t *
+conflict_report_dup(const svn_client__conflict_report_t *report,
                     apr_pool_t *result_pool)
 {
-  conflict_report_t *new = apr_pmemdup(result_pool, report, sizeof(*new));
+  svn_client__conflict_report_t *new = apr_pmemdup(result_pool, report,
+                                                   sizeof(*new));
 
   new->target_abspath = apr_pstrdup(result_pool, report->target_abspath);
   new->conflicted_range = merge_source_dup(report->conflicted_range,
@@ -5524,11 +5529,9 @@ conflict_report_dup(const conflict_repor
   return new;
 }
 
-/* Create and return an error structure appropriate for the unmerged
-   revisions range(s). */
-static APR_INLINE svn_error_t *
-make_merge_conflict_error(conflict_report_t *report,
-                          apr_pool_t *scratch_pool)
+svn_error_t *
+svn_client__make_merge_conflict_error(svn_client__conflict_report_t *report,
+                                      apr_pool_t *scratch_pool)
 {
   assert(!report || svn_dirent_is_absolute(report->target_abspath));
 
@@ -9762,7 +9765,7 @@ ensure_ra_session_url(svn_ra_session_t *
 static svn_error_t *
 do_merge(apr_hash_t **modified_subtrees,
          svn_mergeinfo_catalog_t result_catalog,
-         conflict_report_t **conflict_report,
+         svn_client__conflict_report_t **conflict_report,
          svn_boolean_t *use_sleep,
          const apr_array_header_t *merge_sources,
          const merge_target_t *target,
@@ -10085,23 +10088,24 @@ do_merge(apr_hash_t **modified_subtrees,
    SCRATCH_POOL is used for all temporary allocations.
  */
 static svn_error_t *
-merge_cousins_and_supplement_mergeinfo(conflict_report_t **conflict_report,
-                                       svn_boolean_t *use_sleep,
-                                       const merge_target_t *target,
-                                       svn_ra_session_t *URL1_ra_session,
-                                       svn_ra_session_t *URL2_ra_session,
-                                       const merge_source_t *source,
-                                       const svn_client__pathrev_t *yca,
-                                       svn_boolean_t same_repos,
-                                       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,
-                                       const apr_array_header_t *merge_options,
-                                       svn_client_ctx_t *ctx,
-                                       apr_pool_t *result_pool,
-                                       apr_pool_t *scratch_pool)
+merge_cousins_and_supplement_mergeinfo(
+  svn_client__conflict_report_t **conflict_report,
+  svn_boolean_t *use_sleep,
+  const merge_target_t *target,
+  svn_ra_session_t *URL1_ra_session,
+  svn_ra_session_t *URL2_ra_session,
+  const merge_source_t *source,
+  const svn_client__pathrev_t *yca,
+  svn_boolean_t same_repos,
+  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,
+  const apr_array_header_t *merge_options,
+  svn_client_ctx_t *ctx,
+  apr_pool_t *result_pool,
+  apr_pool_t *scratch_pool)
 {
   apr_array_header_t *remove_sources, *add_sources;
   apr_hash_t *modified_subtrees = NULL;
@@ -10425,24 +10429,24 @@ open_target_wc(merge_target_t **target_p
  *
  * IGNORE_MERGEINFO and DIFF_IGNORE_ANCESTRY are as in do_merge().
  */
-static svn_error_t *
-merge_locked(conflict_report_t **conflict_report,
-             const char *source1,
-             const svn_opt_revision_t *revision1,
-             const char *source2,
-             const svn_opt_revision_t *revision2,
-             const char *target_abspath,
-             svn_depth_t depth,
-             svn_boolean_t ignore_mergeinfo,
-             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,
-             const apr_array_header_t *merge_options,
-             svn_client_ctx_t *ctx,
-             apr_pool_t *result_pool,
-             apr_pool_t *scratch_pool)
+svn_error_t *
+svn_client__merge_locked(svn_client__conflict_report_t **conflict_report,
+                         const char *source1,
+                         const svn_opt_revision_t *revision1,
+                         const char *source2,
+                         const svn_opt_revision_t *revision2,
+                         const char *target_abspath,
+                         svn_depth_t depth,
+                         svn_boolean_t ignore_mergeinfo,
+                         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,
+                         const apr_array_header_t *merge_options,
+                         svn_client_ctx_t *ctx,
+                         apr_pool_t *result_pool,
+                         apr_pool_t *scratch_pool)
 {
   merge_target_t *target;
   svn_client__pathrev_t *source1_loc, *source2_loc;
@@ -10639,7 +10643,7 @@ svn_client_merge5(const char *source1,
                   apr_pool_t *pool)
 {
   const char *target_abspath, *lock_abspath;
-  conflict_report_t *conflict_report;
+  svn_client__conflict_report_t *conflict_report;
 
   /* Sanity check our input -- we require specified revisions,
    * and either 2 paths or 2 URLs. */
@@ -10662,22 +10666,23 @@ svn_client_merge5(const char *source1,
 
   if (!dry_run)
     SVN_WC__CALL_WITH_WRITE_LOCK(
-      merge_locked(&conflict_report,
-                   source1, revision1, source2, revision2,
-                   target_abspath, depth, ignore_mergeinfo,
-                   diff_ignore_ancestry,
-                   force_delete, record_only, dry_run,
-                   allow_mixed_rev, merge_options, ctx, pool, pool),
+      svn_client__merge_locked(&conflict_report,
+                               source1, revision1, source2, revision2,
+                               target_abspath, depth, ignore_mergeinfo,
+                               diff_ignore_ancestry,
+                               force_delete, record_only, dry_run,
+                               allow_mixed_rev, merge_options, ctx, pool, 
pool),
       ctx->wc_ctx, lock_abspath, FALSE /* lock_anchor */, pool);
   else
-    SVN_ERR(merge_locked(&conflict_report,
-                   source1, revision1, source2, revision2,
-                   target_abspath, depth, ignore_mergeinfo,
-                   diff_ignore_ancestry,
-                   force_delete, record_only, dry_run,
-                   allow_mixed_rev, merge_options, ctx, pool, pool));
+    SVN_ERR(svn_client__merge_locked(&conflict_report,
+                                     source1, revision1, source2, revision2,
+                                     target_abspath, depth, ignore_mergeinfo,
+                                     diff_ignore_ancestry,
+                                     force_delete, record_only, dry_run,
+                                     allow_mixed_rev, merge_options, ctx, pool,
+                                     pool));
 
-  SVN_ERR(make_merge_conflict_error(conflict_report, pool));
+  SVN_ERR(svn_client__make_merge_conflict_error(conflict_report, pool));
   return SVN_NO_ERROR;
 }
 
@@ -11696,7 +11701,7 @@ open_reintegrate_source_and_target(svn_r
 
 /* The body of svn_client_merge_reintegrate(), which see for details. */
 static svn_error_t *
-merge_reintegrate_locked(conflict_report_t **conflict_report,
+merge_reintegrate_locked(svn_client__conflict_report_t **conflict_report,
                          const char *source_path_or_url,
                          const svn_opt_revision_t *source_peg_revision,
                          const char *target_abspath,
@@ -11771,7 +11776,7 @@ svn_client_merge_reintegrate(const char
                              apr_pool_t *pool)
 {
   const char *target_abspath, *lock_abspath;
-  conflict_report_t *conflict_report;
+  svn_client__conflict_report_t *conflict_report;
 
   SVN_ERR(get_target_and_lock_abspath(&target_abspath, &lock_abspath,
                                       target_wcpath, ctx, pool));
@@ -11791,7 +11796,7 @@ svn_client_merge_reintegrate(const char
                                      FALSE /*diff_ignore_ancestry*/,
                                      dry_run, merge_options, ctx, pool, pool));
 
-  SVN_ERR(make_merge_conflict_error(conflict_report, pool));
+  SVN_ERR(svn_client__make_merge_conflict_error(conflict_report, pool));
   return SVN_NO_ERROR;
 }
 
@@ -11801,7 +11806,7 @@ svn_client_merge_reintegrate(const char
  * IGNORE_MERGEINFO and DIFF_IGNORE_ANCESTRY are as in do_merge().
  */
 static svn_error_t *
-merge_peg_locked(conflict_report_t **conflict_report,
+merge_peg_locked(svn_client__conflict_report_t **conflict_report,
                  const char *source_path_or_url,
                  const svn_opt_revision_t *source_peg_revision,
                  const svn_rangelist_t *ranges_to_merge,
@@ -11853,6 +11858,21 @@ merge_peg_locked(conflict_report_t **con
 
   /* Do the real merge!  (We say with confidence that our merge
      sources are both ancestral and related.) */
+  if (getenv("SVN_ELEMENT_MERGE")
+      && same_repos
+      && (depth == svn_depth_infinity || depth == svn_depth_unknown)
+      && ignore_mergeinfo
+      && !record_only)
+    {
+      err = svn_client__merge_elements(&use_sleep,
+                                       merge_sources, target, ra_session,
+                                       diff_ignore_ancestry, force_delete,
+                                       dry_run, merge_options,
+                                       ctx, result_pool, scratch_pool);
+      /* ### Currently this merge just errors out on any conflicts */
+      *conflict_report = NULL;
+    }
+  else
   err = do_merge(NULL, NULL, conflict_report, &use_sleep,
                  merge_sources, target, ra_session,
                  TRUE /*sources_related*/, same_repos, ignore_mergeinfo,
@@ -11891,7 +11911,7 @@ client_find_automatic_merge(automatic_me
                             apr_pool_t *scratch_pool);
 
 static svn_error_t *
-do_automatic_merge_locked(conflict_report_t **conflict_report,
+do_automatic_merge_locked(svn_client__conflict_report_t **conflict_report,
                           const automatic_merge_t *merge,
                           const char *target_abspath,
                           svn_depth_t depth,
@@ -11921,7 +11941,7 @@ svn_client_merge_peg5(const char *source
                       apr_pool_t *pool)
 {
   const char *target_abspath, *lock_abspath;
-  conflict_report_t *conflict_report;
+  svn_client__conflict_report_t *conflict_report;
 
   /* No ranges to merge?  No problem. */
   if (ranges_to_merge != NULL && ranges_to_merge->nelts == 0)
@@ -11986,7 +12006,7 @@ svn_client_merge_peg5(const char *source
                        force_delete, record_only, dry_run,
                        allow_mixed_rev, merge_options, ctx, pool, pool));
 
-  SVN_ERR(make_merge_conflict_error(conflict_report, pool));
+  SVN_ERR(svn_client__make_merge_conflict_error(conflict_report, pool));
   return SVN_NO_ERROR;
 }
 
@@ -12666,7 +12686,7 @@ client_find_automatic_merge(automatic_me
  * eliminate already-cherry-picked revisions from the source.
  */
 static svn_error_t *
-do_automatic_merge_locked(conflict_report_t **conflict_report,
+do_automatic_merge_locked(svn_client__conflict_report_t **conflict_report,
                           const automatic_merge_t *merge,
                           const char *target_abspath,
                           svn_depth_t depth,

Modified: subversion/branches/ra-git/subversion/libsvn_client/mtcc.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_client/mtcc.c?rev=1764214&r1=1764213&r2=1764214&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_client/mtcc.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_client/mtcc.c Tue Oct 11 
09:11:50 2016
@@ -712,6 +712,7 @@ mtcc_prop_getter(const svn_string_t **mi
                 {
                   *mime_type = svn_string_dup(mod->value, pool);
                   mime_type = NULL;
+                  break;
                 }
             }
         }

Modified: subversion/branches/ra-git/subversion/libsvn_client/patch.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_client/patch.c?rev=1764214&r1=1764213&r2=1764214&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_client/patch.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_client/patch.c Tue Oct 11 
09:11:50 2016
@@ -67,7 +67,10 @@ typedef struct hunk_info_t {
 
   /* The fuzz factor used when matching this hunk, i.e. how many
    * lines of leading and trailing context to ignore during matching. */
-  svn_linenum_t fuzz;
+  svn_linenum_t match_fuzz;
+
+  /* match_fuzz + the penalty caused by bad patch files */
+  svn_linenum_t report_fuzz;
 } hunk_info_t;
 
 /* A struct carrying information related to the patched and unpatched
@@ -1038,7 +1041,6 @@ init_patch_target(patch_target_t **patch
   target->operation = patch->operation;
 
   if (patch->operation == svn_diff_op_added /* Allow replacing */
-      || patch->operation == svn_diff_op_added
       || patch->operation == svn_diff_op_moved)
     {
       follow_moves = FALSE;
@@ -1222,11 +1224,11 @@ init_patch_target(patch_target_t **patch
 
       /* Open a temporary file to write the patched result to. */
       SVN_ERR(svn_io_open_unique_file3(&target->patched_file,
-                                        &target->patched_path, NULL,
-                                        remove_tempfiles ?
-                                          svn_io_file_del_on_pool_cleanup :
-                                          svn_io_file_del_none,
-                                        result_pool, scratch_pool));
+                                       &target->patched_path, NULL,
+                                       remove_tempfiles ?
+                                         svn_io_file_del_on_pool_cleanup :
+                                         svn_io_file_del_none,
+                                       result_pool, scratch_pool));
 
       /* Put the write callback in place. */
       content->write = write_file;
@@ -1567,12 +1569,20 @@ match_hunk(svn_boolean_t *matched, targe
   svn_linenum_t hunk_length;
   svn_linenum_t leading_context;
   svn_linenum_t trailing_context;
+  svn_linenum_t fuzz_penalty;
 
   *matched = FALSE;
 
   if (content->eof)
     return SVN_NO_ERROR;
 
+  fuzz_penalty = svn_diff_hunk__get_fuzz_penalty(hunk);
+
+  if (fuzz_penalty > fuzz)
+    return SVN_NO_ERROR;
+  else
+    fuzz -= fuzz_penalty;
+
   saved_line = content->current_line;
   lines_read = 0;
   lines_matched = FALSE;
@@ -2079,7 +2089,8 @@ get_hunk_info(hunk_info_t **hi, patch_ta
   (*hi)->matched_line = matched_line;
   (*hi)->rejected = (matched_line == 0);
   (*hi)->already_applied = already_applied;
-  (*hi)->fuzz = fuzz;
+  (*hi)->report_fuzz = fuzz;
+  (*hi)->match_fuzz = fuzz - svn_diff_hunk__get_fuzz_penalty(hunk);
 
   return SVN_NO_ERROR;
 }
@@ -2201,6 +2212,7 @@ apply_hunk(patch_target_t *target, targe
   svn_linenum_t lines_read;
   svn_boolean_t eof;
   apr_pool_t *iterpool;
+  svn_linenum_t fuzz = hi->match_fuzz;
 
   /* ### Is there a cleaner way to describe if we have an existing target?
    */
@@ -2212,13 +2224,13 @@ apply_hunk(patch_target_t *target, targe
        * Also copy leading lines of context which matched with fuzz.
        * The target has changed on the fuzzy-matched lines,
        * so we should retain the target's version of those lines. */
-      SVN_ERR(copy_lines_to_target(content, hi->matched_line + hi->fuzz,
+      SVN_ERR(copy_lines_to_target(content, hi->matched_line + fuzz,
                                    pool));
 
       /* Skip the target's version of the hunk.
        * Don't skip trailing lines which matched with fuzz. */
       line = content->current_line +
-             svn_diff_hunk_get_original_length(hi->hunk) - (2 * hi->fuzz);
+             svn_diff_hunk_get_original_length(hi->hunk) - (2 * fuzz);
       SVN_ERR(seek_to_line(content, line, pool));
       if (content->current_line != line && ! content->eof)
         {
@@ -2245,8 +2257,8 @@ apply_hunk(patch_target_t *target, targe
                                                    &eol_str, &eof,
                                                    iterpool, iterpool));
       lines_read++;
-      if (lines_read > hi->fuzz &&
-          lines_read <= svn_diff_hunk_get_modified_length(hi->hunk) - hi->fuzz)
+      if (lines_read > fuzz &&
+          lines_read <= svn_diff_hunk_get_modified_length(hi->hunk) - fuzz)
         {
           apr_size_t len;
 
@@ -2315,7 +2327,7 @@ send_hunk_notification(const hunk_info_t
   notify->hunk_modified_length =
     svn_diff_hunk_get_modified_length(hi->hunk);
   notify->hunk_matched_line = hi->matched_line;
-  notify->hunk_fuzz = hi->fuzz;
+  notify->hunk_fuzz = hi->report_fuzz;
   notify->prop_name = prop_name;
 
   ctx->notify_func2(ctx->notify_baton2, notify, pool);
@@ -3292,6 +3304,7 @@ install_patched_target(patch_target_t *t
  */
 static svn_error_t *
 write_out_rejected_hunks(patch_target_t *target,
+                         const char *root_abspath,
                          svn_boolean_t dry_run,
                          apr_pool_t *scratch_pool)
 {
@@ -3299,17 +3312,33 @@ write_out_rejected_hunks(patch_target_t
     {
       /* Write out rejected hunks, if any. */
       apr_file_t *reject_file;
+      svn_error_t *err;
 
-      SVN_ERR(svn_io_open_uniquely_named(&reject_file, NULL,
-                                         svn_dirent_dirname(
-                                              target->local_abspath,
-                                              scratch_pool),
-                                         svn_dirent_basename(
-                                              target->local_abspath,
-                                              NULL),
-                                         ".svnpatch.rej",
-                                         svn_io_file_del_none,
-                                         scratch_pool, scratch_pool));
+      err = svn_io_open_uniquely_named(&reject_file, NULL,
+                                       
svn_dirent_dirname(target->local_abspath,
+                                                          scratch_pool),
+                                       svn_dirent_basename(
+                                         target->local_abspath,
+                                         NULL),
+                                       ".svnpatch.rej",
+                                       svn_io_file_del_none,
+                                       scratch_pool, scratch_pool);
+      if (err && APR_STATUS_IS_ENOENT(err->apr_err))
+        {
+          /* The hunk applies to a file in a directory which does not exist.
+           * Put the reject file into the working copy root instead. */
+          svn_error_clear(err);
+          SVN_ERR(svn_io_open_uniquely_named(&reject_file, NULL,
+                                             root_abspath,
+                                             svn_dirent_basename(
+                                               target->local_abspath,
+                                               NULL),
+                                             ".svnpatch.rej",
+                                             svn_io_file_del_none,
+                                             scratch_pool, scratch_pool));
+        }
+      else
+        SVN_ERR(err);
 
       SVN_ERR(svn_stream_reset(target->reject_stream));
 
@@ -3665,7 +3694,8 @@ apply_patches(/* The path to the patch f
                     SVN_ERR(install_patched_prop_targets(target, ctx,
                                                          dry_run, iterpool));
 
-                  SVN_ERR(write_out_rejected_hunks(target, dry_run, iterpool));
+                  SVN_ERR(write_out_rejected_hunks(target, root_abspath,
+                                                   dry_run, iterpool));
 
                   APR_ARRAY_PUSH(targets_info,
                                  patch_target_info_t *) = target_info;

Modified: subversion/branches/ra-git/subversion/libsvn_client/relocate.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_client/relocate.c?rev=1764214&r1=1764213&r2=1764214&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_client/relocate.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_client/relocate.c Tue Oct 11 
09:11:50 2016
@@ -141,6 +141,8 @@ svn_client_relocate2(const char *wcroot_
   apr_hash_index_t *hi;
   apr_pool_t *iterpool = NULL;
   const char *old_repos_root_url, *new_repos_root_url;
+  char *sig_from_prefix, *sig_to_prefix;
+  apr_size_t index_from, index_to;
 
   /* Populate our validator callback baton, and call the relocate code. */
   vb.ctx = ctx;
@@ -183,6 +185,21 @@ svn_client_relocate2(const char *wcroot_
   if (! apr_hash_count(externals_hash))
     return SVN_NO_ERROR;
 
+  /* A valid prefix for the main working copy may be too long to be
+     valid for an external.  Trim any common trailing characters to
+     leave the significant part that changes. */
+  sig_from_prefix = apr_pstrdup(pool, from_prefix);
+  sig_to_prefix = apr_pstrdup(pool, to_prefix);
+  index_from = strlen(sig_from_prefix);
+  index_to = strlen(sig_to_prefix);
+  while (index_from && index_to
+         && sig_from_prefix[index_from] == sig_to_prefix[index_to])
+    {
+      sig_from_prefix[index_from] = sig_to_prefix[index_to] = '\0';
+      --index_from;
+      --index_to;
+    }
+
   iterpool = svn_pool_create(pool);
 
   for (hi = apr_hash_first(pool, externals_hash);
@@ -218,7 +235,8 @@ svn_client_relocate2(const char *wcroot_
           SVN_ERR(err);
 
           if (strcmp(old_repos_root_url, this_repos_root_url) == 0)
-            SVN_ERR(svn_client_relocate2(this_abspath, from_prefix, to_prefix,
+            SVN_ERR(svn_client_relocate2(this_abspath,
+                                         sig_from_prefix, sig_to_prefix,
                                          FALSE /* ignore_externals */,
                                          ctx, iterpool));
         }

Modified: subversion/branches/ra-git/subversion/libsvn_client/resolved.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_client/resolved.c?rev=1764214&r1=1764213&r2=1764214&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_client/resolved.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_client/resolved.c Tue Oct 11 
09:11:50 2016
@@ -1,5 +1,5 @@
 /*
- * resolved.c:  wrapper around wc resolved functionality.
+ * resolved.c:  wrapper around Subversion <=1.9 wc resolved functionality
  *
  * ====================================================================
  *    Licensed to the Apache Software Foundation (ASF) under one
@@ -42,8 +42,6 @@
 
 #include "svn_private_config.h"
 
-#define ARRAY_LEN(ary) ((sizeof (ary)) / (sizeof ((ary)[0])))
-
 
 /*** Code. ***/
 
@@ -147,1040 +145,3 @@ svn_client_resolve(const char *path,
 
   return svn_error_trace(err);
 }
-
-
-/*** Dealing with conflicts. ***/
-
-struct svn_client_conflict_t
-{
-  const char *local_abspath;
-  svn_client_ctx_t *ctx;
-  apr_hash_t *prop_conflicts;
-
-  /* Indicate which options were chosen to resolve a text or tree conflict
-   * on the conflited node. */
-  svn_client_conflict_option_id_t resolution_text;
-  svn_client_conflict_option_id_t resolution_tree;
-
-  /* A mapping from const char* property name to pointers to
-   * svn_client_conflict_option_t for all properties which had their
-   * conflicts resolved. Indicates which options were chosen to resolve
-   * the property conflicts. */
-  apr_hash_t *resolved_props;
-
-  /* For backwards compat. */
-  const svn_wc_conflict_description2_t *legacy_text_conflict;
-  const svn_wc_conflict_description2_t *legacy_prop_conflict;
-  const svn_wc_conflict_description2_t *legacy_tree_conflict;
-};
-
-/* Resolves conflict to OPTION and sets CONFLICT->RESOLUTION accordingly. */
-typedef svn_error_t *(*conflict_option_resolve_func_t)(
-  svn_client_conflict_option_t *option,
-  svn_client_conflict_t *conflict,
-  apr_pool_t *scratch_pool);
-
-struct svn_client_conflict_option_t
-{
-  svn_client_conflict_option_id_t id;
-  const char *description;
-
-  svn_client_conflict_t *conflict;
-  conflict_option_resolve_func_t do_resolve_func;
-
-  /* Data which is specific to particular conflicts and options. */
-  union {
-    struct {
-      /* Indicates the property to resolve in case of a property conflict.
-       * If set to "", all properties are resolved to this option. */
-      const char *propname;
-
-      /* A merged property value, if supplied by the API user, else NULL. */
-      const svn_string_t *merged_propval;
-    } prop;
-  } type_data;
-
-};
-
-/*
- * Return a legacy conflict choice corresponding to OPTION_ID.
- * Return svn_wc_conflict_choose_undefined if no corresponding
- * legacy conflict choice exists.
- */
-static svn_wc_conflict_choice_t
-conflict_option_id_to_wc_conflict_choice(
-  svn_client_conflict_option_id_t option_id)
-{
-
-  switch (option_id)
-    {
-      case svn_client_conflict_option_undefined:
-        return svn_wc_conflict_choose_undefined;
-
-      case svn_client_conflict_option_postpone:
-        return svn_wc_conflict_choose_postpone;
-
-      case svn_client_conflict_option_base_text:
-        return svn_wc_conflict_choose_base;
-
-      case svn_client_conflict_option_incoming_text:
-        return svn_wc_conflict_choose_theirs_full;
-
-      case svn_client_conflict_option_working_text:
-        return svn_wc_conflict_choose_mine_full;
-
-      case svn_client_conflict_option_incoming_text_where_conflicted:
-        return svn_wc_conflict_choose_theirs_conflict;
-
-      case svn_client_conflict_option_working_text_where_conflicted:
-        return svn_wc_conflict_choose_mine_conflict;
-
-      case svn_client_conflict_option_merged_text:
-        return svn_wc_conflict_choose_merged;
-
-      case svn_client_conflict_option_unspecified:
-        return svn_wc_conflict_choose_unspecified;
-
-      default:
-        break;
-    }
-
-  return svn_wc_conflict_choose_undefined;
-}
-
-static void
-add_legacy_desc_to_conflict(const svn_wc_conflict_description2_t *desc,
-                            svn_client_conflict_t *conflict,
-                            apr_pool_t *result_pool)
-{
-  switch (desc->kind)
-    {
-      case svn_wc_conflict_kind_text:
-        conflict->legacy_text_conflict = desc;
-        break;
-
-      case svn_wc_conflict_kind_property:
-        conflict->legacy_prop_conflict = desc;
-        break;
-
-      case svn_wc_conflict_kind_tree:
-        conflict->legacy_tree_conflict = desc;
-        break;
-
-      default:
-        SVN_ERR_ASSERT_NO_RETURN(FALSE); /* unknown kind of conflict */
-    }
-}
-
-/* Set up a conflict object. If legacy conflict descriptor DESC is not NULL,
- * set up the conflict object for backwards compatibility. */
-static svn_error_t *
-conflict_get_internal(svn_client_conflict_t **conflict,
-                      const char *local_abspath,
-                      const svn_wc_conflict_description2_t *desc,
-                      svn_client_ctx_t *ctx,
-                      apr_pool_t *result_pool,
-                      apr_pool_t *scratch_pool)
-{
-  const apr_array_header_t *descs;
-  int i;
-
-  *conflict = apr_pcalloc(result_pool, sizeof(**conflict));
-
-  if (desc)
-    {
-      /* Add a single legacy conflict descriptor. */
-      (*conflict)->local_abspath = desc->local_abspath;
-      (*conflict)->resolution_text = svn_client_conflict_option_undefined;
-      (*conflict)->resolution_tree = svn_client_conflict_option_undefined;
-      (*conflict)->resolved_props = apr_hash_make(result_pool);
-      add_legacy_desc_to_conflict(desc, *conflict, result_pool);
-
-      return SVN_NO_ERROR;
-    }
-
-  (*conflict)->local_abspath = apr_pstrdup(result_pool, local_abspath);
-  (*conflict)->resolution_text = svn_client_conflict_option_undefined;
-  (*conflict)->resolution_tree = svn_client_conflict_option_undefined;
-  (*conflict)->resolved_props = apr_hash_make(result_pool);
-  (*conflict)->ctx = ctx;
-
-  /* Add all legacy conflict descriptors we can find. Eventually, this code
-   * path should stop relying on svn_wc_conflict_description2_t entirely. */
-  SVN_ERR(svn_wc__read_conflict_descriptions2_t(&descs, ctx->wc_ctx,
-                                                local_abspath,
-                                                result_pool, scratch_pool));
-  for (i = 0; i < descs->nelts; i++)
-    {
-      desc = APR_ARRAY_IDX(descs, i, const svn_wc_conflict_description2_t *);
-      if (desc->kind == svn_wc_conflict_kind_property)
-        {
-          if ((*conflict)->prop_conflicts == NULL)
-            (*conflict)->prop_conflicts = apr_hash_make(result_pool);
-          svn_hash_sets((*conflict)->prop_conflicts, desc->property_name, 
desc);
-        }
-      add_legacy_desc_to_conflict(desc, *conflict, result_pool);
-    }
-
-  return SVN_NO_ERROR;
-}
-
-svn_error_t *
-svn_client_conflict_get(svn_client_conflict_t **conflict,
-                        const char *local_abspath,
-                        svn_client_ctx_t *ctx,
-                        apr_pool_t *result_pool,
-                        apr_pool_t *scratch_pool)
-{
-  return svn_error_trace(conflict_get_internal(conflict, local_abspath, NULL,
-                                               ctx, result_pool, 
scratch_pool));
-}
-
-svn_error_t *
-svn_client_conflict_from_wc_description2_t(
-  svn_client_conflict_t **conflict,
-  const svn_wc_conflict_description2_t *desc,
-  apr_pool_t *result_pool,
-  apr_pool_t *scratch_pool)
-{
-  return svn_error_trace(conflict_get_internal(conflict, NULL, desc, NULL,
-                                               result_pool, scratch_pool));
-}
-
-void
-svn_client_conflict_option_set_merged_propval(
-  svn_client_conflict_option_t *option,
-  const svn_string_t *merged_propval)
-{
-  option->type_data.prop.merged_propval = merged_propval;
-}
-
-/* 
- * Resolve the conflict at LOCAL_ABSPATH. Currently only supports
- * an OPTION_ID which can be mapped to svn_wc_conflict_choice_t and
- * maps a single option_id to text, prop, and/or tree conflicts.
- */
-static svn_error_t *
-resolve_conflict(svn_client_conflict_option_id_t option_id,
-                 const char *local_abspath,
-                 svn_boolean_t resolve_text,
-                 const char * resolve_prop,
-                 svn_boolean_t resolve_tree,
-                 svn_client_ctx_t *ctx,
-                 apr_pool_t *scratch_pool)
-{
-  svn_wc_conflict_choice_t conflict_choice;
-  const char *lock_abspath;
-  svn_error_t *err;
-
-  conflict_choice = conflict_option_id_to_wc_conflict_choice(option_id);
-  SVN_ERR(svn_wc__acquire_write_lock_for_resolve(&lock_abspath, ctx->wc_ctx,
-                                                 local_abspath,
-                                                 scratch_pool, scratch_pool));
-  err = svn_wc__resolve_conflicts(ctx->wc_ctx, local_abspath,
-                                  svn_depth_empty,
-                                  resolve_text, resolve_prop, resolve_tree,
-                                  conflict_choice,
-                                  NULL, NULL, /* legacy conflict_func/baton */
-                                  ctx->cancel_func,
-                                  ctx->cancel_baton,
-                                  ctx->notify_func2,
-                                  ctx->notify_baton2,
-                                  scratch_pool);
-  err = svn_error_compose_create(err, svn_wc__release_write_lock(ctx->wc_ctx,
-                                                                 lock_abspath,
-                                                                 
scratch_pool));
-  svn_io_sleep_for_timestamps(local_abspath, scratch_pool);
-
-  return SVN_NO_ERROR;
-}
-
-/* Implements conflict_option_resolve_func_t. */
-static svn_error_t *
-resolve_text_conflict(svn_client_conflict_option_t *option,
-                      svn_client_conflict_t *conflict,
-                      apr_pool_t *scratch_pool)
-{
-  svn_client_conflict_option_id_t option_id;
-  const char *local_abspath;
-
-  option_id = svn_client_conflict_option_get_id(option);
-  local_abspath = svn_client_conflict_get_local_abspath(conflict);
-  SVN_ERR(resolve_conflict(option_id, local_abspath, TRUE, NULL, FALSE,
-                           conflict->ctx, scratch_pool));
-  conflict->resolution_text = option_id;
-
-  return SVN_NO_ERROR;
-}
-
-/* Implements conflict_option_resolve_func_t. */
-static svn_error_t *
-resolve_prop_conflict(svn_client_conflict_option_t *option,
-                      svn_client_conflict_t *conflict,
-                      apr_pool_t *scratch_pool)
-{
-  svn_client_conflict_option_id_t option_id;
-  const char *local_abspath;
-  const char *propname = option->type_data.prop.propname;
-
-  option_id = svn_client_conflict_option_get_id(option);
-  local_abspath = svn_client_conflict_get_local_abspath(conflict);
-  SVN_ERR(resolve_conflict(option_id, local_abspath,
-                           FALSE, propname, FALSE,
-                           conflict->ctx, scratch_pool));
-
-  if (propname[0] == '\0')
-    {
-      apr_hash_index_t *hi;
-
-      /* All properties have been resolved to the same option. */
-      for (hi = apr_hash_first(scratch_pool, conflict->prop_conflicts);
-           hi;
-           hi = apr_hash_next(hi))
-        {
-          const char *this_propname = apr_hash_this_key(hi);
-
-          svn_hash_sets(conflict->resolved_props,
-                        
apr_pstrdup(apr_hash_pool_get(conflict->resolved_props),
-                                    this_propname),
-                        option);
-          svn_hash_sets(conflict->prop_conflicts, this_propname, NULL);
-        }
-    }
-  else
-    {
-      svn_hash_sets(conflict->resolved_props,
-                    apr_pstrdup(apr_hash_pool_get(conflict->resolved_props),
-                                propname),
-                   option);
-      svn_hash_sets(conflict->prop_conflicts, propname, NULL);
-    }
-
-  return SVN_NO_ERROR;
-}
-
-static svn_error_t *
-/* Implements conflict_option_resolve_func_t. */
-resolve_tree_conflict(svn_client_conflict_option_t *option,
-                      svn_client_conflict_t *conflict,
-                      apr_pool_t *scratch_pool)
-{
-  svn_client_conflict_option_id_t option_id;
-  const char *local_abspath;
-
-  option_id = svn_client_conflict_option_get_id(option);
-  local_abspath = svn_client_conflict_get_local_abspath(conflict);
-  SVN_ERR(resolve_conflict(option_id, local_abspath, FALSE, NULL, TRUE,
-                           conflict->ctx, scratch_pool));
-  conflict->resolution_tree = option_id;
-
-  return SVN_NO_ERROR;
-}
-
-/* Resolver options for a text conflict */
-static const svn_client_conflict_option_t text_conflict_options[] =
-{
-  {
-    svn_client_conflict_option_postpone,
-    N_("mark the conflict to be resolved later"),
-    NULL,
-    resolve_text_conflict
-  },
-
-  {
-    svn_client_conflict_option_incoming_text,
-    N_("accept incoming version of entire file"),
-    NULL,
-    resolve_text_conflict
-  },
-
-  {
-    svn_client_conflict_option_working_text,
-    N_("accept working copy version of entire file"),
-    NULL,
-    resolve_text_conflict
-  },
-
-  {
-    svn_client_conflict_option_incoming_text_where_conflicted,
-    N_("accept incoming version of all text conflicts in file"),
-    NULL,
-    resolve_text_conflict
-  },
-
-  {
-    svn_client_conflict_option_working_text_where_conflicted,
-    N_("accept working copy version of all text conflicts in file"),
-    NULL,
-    resolve_text_conflict
-  },
-
-};
-
-/* Resolver options for a binary file conflict */
-static const svn_client_conflict_option_t binary_conflict_options[] =
-{
-  {
-    svn_client_conflict_option_postpone,
-    N_("mark the conflict to be resolved later"),
-    NULL,
-    resolve_text_conflict,
-  },
-
-  {
-    svn_client_conflict_option_incoming_text,
-    N_("accept incoming version of binary file"),
-    NULL,
-    resolve_text_conflict
-  },
-
-  {
-    svn_client_conflict_option_working_text,
-    N_("accept working copy version of binary file"),
-    NULL,
-    resolve_text_conflict
-  },
-
-};
-
-/* Resolver options for a property conflict */
-static const svn_client_conflict_option_t prop_conflict_options[] =
-{
-  {
-    svn_client_conflict_option_postpone,
-    N_("mark the conflict to be resolved later"),
-    NULL,
-    resolve_prop_conflict
-  },
-
-  {
-    svn_client_conflict_option_incoming_text,
-    N_("accept incoming version of entire property value"),
-    NULL,
-    resolve_prop_conflict
-  },
-
-  {
-    svn_client_conflict_option_working_text,
-    N_("accept working copy version of entire property value"),
-    NULL,
-    resolve_prop_conflict
-  },
-
-};
-
-/* Resolver options for a tree conflict */
-static const svn_client_conflict_option_t tree_conflict_options[] =
-{
-  {
-    svn_client_conflict_option_postpone,
-    N_("mark the conflict to be resolved later"),
-    NULL,
-    resolve_tree_conflict
-  },
-
-  {
-    /* ### Use 'working text' for now since libsvn_wc does not know another
-     * ### choice to resolve to working yet. */
-    svn_client_conflict_option_working_text,
-    N_("accept current working copy state"),
-    NULL,
-    resolve_tree_conflict
-  },
-
-};
-
-static svn_error_t *
-assert_text_conflict(svn_client_conflict_t *conflict, apr_pool_t *scratch_pool)
-{
-  svn_boolean_t text_conflicted;
-
-  SVN_ERR(svn_client_conflict_get_conflicted(&text_conflicted, NULL, NULL,
-                                             conflict, scratch_pool,
-                                             scratch_pool));
-
-  SVN_ERR_ASSERT(text_conflicted); /* ### return proper error? */
-
-  return SVN_NO_ERROR;
-}
-
-static svn_error_t *
-assert_prop_conflict(svn_client_conflict_t *conflict, apr_pool_t *scratch_pool)
-{
-  apr_array_header_t *props_conflicted;
-
-  SVN_ERR(svn_client_conflict_get_conflicted(NULL, &props_conflicted, NULL,
-                                             conflict, scratch_pool,
-                                             scratch_pool));
-
-  /* ### return proper error? */
-  SVN_ERR_ASSERT(props_conflicted && props_conflicted->nelts > 0);
-
-  return SVN_NO_ERROR;
-}
-
-static svn_error_t *
-assert_tree_conflict(svn_client_conflict_t *conflict, apr_pool_t *scratch_pool)
-{
-  svn_boolean_t tree_conflicted;
-
-  SVN_ERR(svn_client_conflict_get_conflicted(NULL, NULL, &tree_conflicted,
-                                             conflict, scratch_pool,
-                                             scratch_pool));
-
-  SVN_ERR_ASSERT(tree_conflicted); /* ### return proper error? */
-
-  return SVN_NO_ERROR;
-}
-
-svn_error_t *
-svn_client_conflict_text_get_resolution_options(apr_array_header_t **options,
-                                                svn_client_conflict_t 
*conflict,
-                                                apr_pool_t *result_pool,
-                                                apr_pool_t *scratch_pool)
-{
-  const char *mime_type;
-  int i;
-
-  SVN_ERR(assert_text_conflict(conflict, scratch_pool));
-
-  *options = apr_array_make(result_pool, ARRAY_LEN(text_conflict_options),
-                            sizeof(svn_client_conflict_option_t *));
-
-  mime_type = svn_client_conflict_text_get_mime_type(conflict);
-  if (mime_type && svn_mime_type_is_binary(mime_type))
-    {
-      for (i = 0; i < ARRAY_LEN(binary_conflict_options); i++)
-        {
-          APR_ARRAY_PUSH((*options), const svn_client_conflict_option_t *) =
-            &binary_conflict_options[i];
-        }
-    }
-  else
-    {
-      for (i = 0; i < ARRAY_LEN(text_conflict_options); i++)
-        {
-          APR_ARRAY_PUSH((*options), const svn_client_conflict_option_t *) =
-            &text_conflict_options[i];
-        }
-    }
-
-  return SVN_NO_ERROR;
-}
-
-svn_error_t *
-svn_client_conflict_prop_get_resolution_options(apr_array_header_t **options,
-                                                svn_client_conflict_t 
*conflict,
-                                                apr_pool_t *result_pool,
-                                                apr_pool_t *scratch_pool)
-{
-  int i;
-
-  SVN_ERR(assert_prop_conflict(conflict, scratch_pool));
-
-  *options = apr_array_make(result_pool, ARRAY_LEN(prop_conflict_options),
-                            sizeof(svn_client_conflict_option_t *));
-  for (i = 0; i < ARRAY_LEN(prop_conflict_options); i++)
-    {
-      APR_ARRAY_PUSH((*options), const svn_client_conflict_option_t *) =
-        &prop_conflict_options[i];
-    }
-
-  return SVN_NO_ERROR;
-}
-
-svn_error_t *
-svn_client_conflict_tree_get_resolution_options(apr_array_header_t **options,
-                                                svn_client_conflict_t 
*conflict,
-                                                apr_pool_t *result_pool,
-                                                apr_pool_t *scratch_pool)
-{
-  int i;
-
-  SVN_ERR(assert_tree_conflict(conflict, scratch_pool));
-
-  *options = apr_array_make(result_pool, ARRAY_LEN(tree_conflict_options),
-                            sizeof(svn_client_conflict_option_t *));
-  for (i = 0; i < ARRAY_LEN(tree_conflict_options); i++)
-    {
-      APR_ARRAY_PUSH((*options), const svn_client_conflict_option_t *) =
-        &tree_conflict_options[i];
-    }
-
-  return SVN_NO_ERROR;
-}
-
-svn_client_conflict_option_id_t
-svn_client_conflict_option_get_id(svn_client_conflict_option_t *option)
-{
-  return option->id;
-}
-
-svn_error_t *
-svn_client_conflict_option_describe(const char **description,
-                                    svn_client_conflict_option_t *option,
-                                    apr_pool_t *result_pool,
-                                    apr_pool_t *scratch_pool)
-{
-  *description = apr_pstrdup(result_pool, option->description);
-
-  return SVN_NO_ERROR;
-}
-
-svn_error_t *
-svn_client_conflict_text_resolve(svn_client_conflict_t *conflict,
-                                 svn_client_conflict_option_t *option,
-                                 apr_pool_t *scratch_pool)
-{
-  SVN_ERR(assert_text_conflict(conflict, scratch_pool));
-  SVN_ERR(option->do_resolve_func(option, conflict, scratch_pool));
-
-  return SVN_NO_ERROR;
-}
-
-svn_client_conflict_option_t *
-svn_client_conflict_option_find_by_id(apr_array_header_t *options,
-                                      svn_client_conflict_option_id_t 
option_id)
-{
-  int i;
-
-  for (i = 0; i < options->nelts; i++)
-    {
-      svn_client_conflict_option_t *this_option;
-      svn_client_conflict_option_id_t this_option_id;
-      
-      this_option = APR_ARRAY_IDX(options, i, svn_client_conflict_option_t *);
-      this_option_id = svn_client_conflict_option_get_id(this_option);
-
-      if (this_option_id == option_id)
-        return this_option;
-    }
-
-  return NULL;
-}
-
-svn_error_t *
-svn_client_conflict_text_resolve_by_id(
-  svn_client_conflict_t *conflict,
-  svn_client_conflict_option_id_t option_id,
-  apr_pool_t *scratch_pool)
-{
-  apr_array_header_t *resolution_options;
-  svn_client_conflict_option_t *option;
-
-  SVN_ERR(svn_client_conflict_text_get_resolution_options(
-            &resolution_options, conflict,
-            scratch_pool, scratch_pool));
-  option = svn_client_conflict_option_find_by_id(resolution_options,
-                                                 option_id);
-  if (option == NULL)
-    return svn_error_createf(SVN_ERR_WC_CONFLICT_RESOLVER_FAILURE, NULL,
-                               _("Inapplicable conflict resolution option "
-                                 "ID '%d' given for conflicted path '%s'"),
-                               option_id,
-                               svn_dirent_local_style(conflict->local_abspath,
-                                                      scratch_pool));
-  SVN_ERR(svn_client_conflict_text_resolve(conflict, option, scratch_pool));
-
-  return SVN_NO_ERROR;
-}
-
-svn_client_conflict_option_id_t
-svn_client_conflict_text_get_resolution(const svn_client_conflict_t *conflict)
-{
-  return conflict->resolution_text;
-}
-
-svn_error_t *
-svn_client_conflict_prop_resolve(svn_client_conflict_t *conflict,
-                                 const char *propname,
-                                 svn_client_conflict_option_t *option,
-                                 apr_pool_t *scratch_pool)
-{
-  SVN_ERR(assert_prop_conflict(conflict, scratch_pool));
-  option->type_data.prop.propname = propname;
-  SVN_ERR(option->do_resolve_func(option, conflict, scratch_pool));
-
-  return SVN_NO_ERROR;
-}
-
-svn_error_t *
-svn_client_conflict_prop_resolve_by_id(
-  svn_client_conflict_t *conflict,
-  const char *propname,
-  svn_client_conflict_option_id_t option_id,
-  apr_pool_t *scratch_pool)
-{
-  apr_array_header_t *resolution_options;
-  svn_client_conflict_option_t *option;
-
-  SVN_ERR(svn_client_conflict_prop_get_resolution_options(
-            &resolution_options, conflict,
-            scratch_pool, scratch_pool));
-  option = svn_client_conflict_option_find_by_id(resolution_options,
-                                                 option_id);
-  if (option == NULL)
-    return svn_error_createf(SVN_ERR_WC_CONFLICT_RESOLVER_FAILURE, NULL,
-                               _("Inapplicable conflict resolution option "
-                                 "ID '%d' given for conflicted path '%s'"),
-                               option_id,
-                               svn_dirent_local_style(conflict->local_abspath,
-                                                      scratch_pool));
-  SVN_ERR(svn_client_conflict_prop_resolve(conflict, propname, option,
-                                           scratch_pool));
-
-  return SVN_NO_ERROR;
-}
-
-svn_client_conflict_option_id_t
-svn_client_conflict_prop_get_resolution(const svn_client_conflict_t *conflict,
-                                        const char *propname)
-{
-  svn_client_conflict_option_t *option;
-
-  option = svn_hash_gets(conflict->resolved_props, propname);
-  if (option == NULL)
-    return svn_client_conflict_option_undefined;
-
-  return svn_client_conflict_option_get_id(option);
-}
-
-svn_error_t *
-svn_client_conflict_tree_resolve(svn_client_conflict_t *conflict,
-                                 svn_client_conflict_option_t *option,
-                                 apr_pool_t *scratch_pool)
-{
-  SVN_ERR(assert_tree_conflict(conflict, scratch_pool));
-  SVN_ERR(option->do_resolve_func(option, conflict, scratch_pool));
-
-  return SVN_NO_ERROR;
-}
-
-svn_error_t *
-svn_client_conflict_tree_resolve_by_id(
-  svn_client_conflict_t *conflict,
-  svn_client_conflict_option_id_t option_id,
-  apr_pool_t *scratch_pool)
-{
-  apr_array_header_t *resolution_options;
-  svn_client_conflict_option_t *option;
-
-  SVN_ERR(svn_client_conflict_tree_get_resolution_options(
-            &resolution_options, conflict,
-            scratch_pool, scratch_pool));
-  option = svn_client_conflict_option_find_by_id(resolution_options,
-                                                 option_id);
-  if (option == NULL)
-    return svn_error_createf(SVN_ERR_WC_CONFLICT_RESOLVER_FAILURE, NULL,
-                               _("Inapplicable conflict resolution option "
-                                 "ID '%d' given for conflicted path '%s'"),
-                               option_id,
-                               svn_dirent_local_style(conflict->local_abspath,
-                                                      scratch_pool));
-  SVN_ERR(svn_client_conflict_tree_resolve(conflict, option, scratch_pool));
-
-  return SVN_NO_ERROR;
-}
-
-svn_client_conflict_option_id_t
-svn_client_conflict_tree_get_resolution(const svn_client_conflict_t *conflict)
-{
-  return conflict->resolution_tree;
-}
-
-/* Return the legacy conflict descriptor which is wrapped by CONFLICT. */
-static const svn_wc_conflict_description2_t *
-get_conflict_desc2_t(const svn_client_conflict_t *conflict)
-{
-  if (conflict->legacy_text_conflict)
-    return conflict->legacy_text_conflict;
-
-  if (conflict->legacy_tree_conflict)
-    return conflict->legacy_tree_conflict;
-
-  if (conflict->legacy_prop_conflict)
-    return conflict->legacy_prop_conflict;
-
-  return NULL;
-}
-
-svn_wc_conflict_kind_t
-svn_client_conflict_get_kind(const svn_client_conflict_t *conflict)
-{
-  return get_conflict_desc2_t(conflict)->kind;
-}
-
-svn_error_t *
-svn_client_conflict_get_conflicted(svn_boolean_t *text_conflicted,
-                                   apr_array_header_t **props_conflicted,
-                                   svn_boolean_t *tree_conflicted,
-                                   svn_client_conflict_t *conflict,
-                                   apr_pool_t *result_pool,
-                                   apr_pool_t *scratch_pool)
-{
-  if (text_conflicted)
-    *text_conflicted = (conflict->legacy_text_conflict != NULL);
-
-  if (props_conflicted)
-    {
-      if (conflict->legacy_prop_conflict)
-        {
-          *props_conflicted = apr_array_make(result_pool, 1,
-                                             sizeof(const char*));
-          APR_ARRAY_PUSH((*props_conflicted), const char *) =
-            conflict->legacy_prop_conflict->property_name;
-        }
-      else if (conflict->prop_conflicts)
-        SVN_ERR(svn_hash_keys(props_conflicted, conflict->prop_conflicts,
-                              result_pool));
-      else
-        *props_conflicted = NULL;
-    }
-
-  if (tree_conflicted)
-    *tree_conflicted = (conflict->legacy_tree_conflict != NULL);
-
-  return SVN_NO_ERROR;
-}
-
-const char *
-svn_client_conflict_get_local_abspath(const svn_client_conflict_t *conflict)
-{
-  return conflict->local_abspath;
-}
-
-svn_wc_operation_t
-svn_client_conflict_get_operation(const svn_client_conflict_t *conflict)
-{
-  return get_conflict_desc2_t(conflict)->operation;
-}
-
-svn_wc_conflict_action_t
-svn_client_conflict_get_incoming_change(const svn_client_conflict_t *conflict)
-{
-  return get_conflict_desc2_t(conflict)->action;
-}
-
-svn_wc_conflict_reason_t
-svn_client_conflict_get_local_change(const svn_client_conflict_t *conflict)
-{
-  return get_conflict_desc2_t(conflict)->reason;
-}
-
-svn_error_t *
-svn_client_conflict_get_repos_info(const char **repos_root_url,
-                                   const char **repos_uuid,
-                                   const svn_client_conflict_t *conflict,
-                                   apr_pool_t *result_pool,
-                                   apr_pool_t *scratch_pool)
-{
-  if (repos_root_url)
-    {
-      if (get_conflict_desc2_t(conflict)->src_left_version)
-        *repos_root_url =
-          get_conflict_desc2_t(conflict)->src_left_version->repos_url;
-      else if (get_conflict_desc2_t(conflict)->src_right_version)
-        *repos_root_url =
-          get_conflict_desc2_t(conflict)->src_right_version->repos_url;
-      else
-        *repos_root_url = NULL;
-    }
-
-  if (repos_uuid)
-    {
-      if (get_conflict_desc2_t(conflict)->src_left_version)
-        *repos_uuid =
-          get_conflict_desc2_t(conflict)->src_left_version->repos_uuid;
-      else if (get_conflict_desc2_t(conflict)->src_right_version)
-        *repos_uuid =
-          get_conflict_desc2_t(conflict)->src_right_version->repos_uuid;
-      else
-        *repos_uuid = NULL;
-    }
-
-  return SVN_NO_ERROR;
-}
-
-svn_error_t *
-svn_client_conflict_get_incoming_old_repos_location(
-  const char **incoming_old_repos_relpath,
-  svn_revnum_t *incoming_old_pegrev,
-  svn_node_kind_t *incoming_old_node_kind,
-  const svn_client_conflict_t *conflict,
-  apr_pool_t *result_pool,
-  apr_pool_t *scratch_pool)
-{
-  if (incoming_old_repos_relpath)
-    {
-      if (get_conflict_desc2_t(conflict)->src_left_version)
-        *incoming_old_repos_relpath =
-          get_conflict_desc2_t(conflict)->src_left_version->path_in_repos;
-      else
-        *incoming_old_repos_relpath = NULL;
-    }
-
-  if (incoming_old_pegrev)
-    {
-      if (get_conflict_desc2_t(conflict)->src_left_version)
-        *incoming_old_pegrev =
-          get_conflict_desc2_t(conflict)->src_left_version->peg_rev;
-      else
-        *incoming_old_pegrev = SVN_INVALID_REVNUM;
-    }
-
-  if (incoming_old_node_kind)
-    {
-      if (get_conflict_desc2_t(conflict)->src_left_version)
-        *incoming_old_node_kind =
-          get_conflict_desc2_t(conflict)->src_left_version->node_kind;
-      else
-        *incoming_old_node_kind = svn_node_none;
-    }
-
-  return SVN_NO_ERROR;
-}
-
-svn_error_t *
-svn_client_conflict_get_incoming_new_repos_location(
-  const char **incoming_new_repos_relpath,
-  svn_revnum_t *incoming_new_pegrev,
-  svn_node_kind_t *incoming_new_node_kind,
-  const svn_client_conflict_t *conflict,
-  apr_pool_t *result_pool,
-  apr_pool_t *scratch_pool)
-{
-  if (incoming_new_repos_relpath)
-    {
-      if (get_conflict_desc2_t(conflict)->src_right_version)
-        *incoming_new_repos_relpath =
-          get_conflict_desc2_t(conflict)->src_right_version->path_in_repos;
-      else
-        *incoming_new_repos_relpath = NULL;
-    }
-
-  if (incoming_new_pegrev)
-    {
-      if (get_conflict_desc2_t(conflict)->src_right_version)
-        *incoming_new_pegrev =
-          get_conflict_desc2_t(conflict)->src_right_version->peg_rev;
-      else
-        *incoming_new_pegrev = SVN_INVALID_REVNUM;
-    }
-
-  if (incoming_new_node_kind)
-    {
-      if (get_conflict_desc2_t(conflict)->src_right_version)
-        *incoming_new_node_kind =
-          get_conflict_desc2_t(conflict)->src_right_version->node_kind;
-      else
-        *incoming_new_node_kind = svn_node_none;
-    }
-
-  return SVN_NO_ERROR;
-}
-
-svn_node_kind_t
-svn_client_conflict_tree_get_victim_node_kind(
-  const svn_client_conflict_t *conflict)
-{
-  SVN_ERR_ASSERT_NO_RETURN(svn_client_conflict_get_kind(conflict)
-      == svn_wc_conflict_kind_tree);
-
-  return get_conflict_desc2_t(conflict)->node_kind;
-}
-
-const char *
-svn_client_conflict_prop_get_propname(const svn_client_conflict_t *conflict)
-{
-  SVN_ERR_ASSERT_NO_RETURN(svn_client_conflict_get_kind(conflict)
-      == svn_wc_conflict_kind_property);
-
-  return get_conflict_desc2_t(conflict)->property_name;
-}
-
-svn_error_t *
-svn_client_conflict_prop_get_propvals(const svn_string_t **base_propval,
-                                      const svn_string_t **working_propval,
-                                      const svn_string_t 
**incoming_old_propval,
-                                      const svn_string_t 
**incoming_new_propval,
-                                      const svn_client_conflict_t *conflict,
-  apr_pool_t *result_pool)
-{
-  SVN_ERR_ASSERT(svn_client_conflict_get_kind(conflict) ==
-                 svn_wc_conflict_kind_property);
-
-  if (base_propval)
-    *base_propval =
-      svn_string_dup(get_conflict_desc2_t(conflict)->prop_value_base,
-                     result_pool);
-
-  if (working_propval)
-    *working_propval =
-      svn_string_dup(get_conflict_desc2_t(conflict)->prop_value_working,
-                     result_pool);
-
-  if (incoming_old_propval)
-    *incoming_old_propval =
-      svn_string_dup(get_conflict_desc2_t(conflict)->prop_value_incoming_old,
-                     result_pool);
-
-  if (incoming_new_propval)
-    *incoming_new_propval =
-      svn_string_dup(get_conflict_desc2_t(conflict)->prop_value_incoming_new,
-                     result_pool);
-
-  return SVN_NO_ERROR;
-}
-
-const char *
-svn_client_conflict_prop_get_reject_abspath(
-  const svn_client_conflict_t *conflict)
-{
-  SVN_ERR_ASSERT_NO_RETURN(svn_client_conflict_get_kind(conflict)
-      == svn_wc_conflict_kind_property);
-
-  /* svn_wc_conflict_description2_t stores this path in 'their_abspath' */
-  return get_conflict_desc2_t(conflict)->their_abspath;
-}
-
-const char *
-svn_client_conflict_text_get_mime_type(const svn_client_conflict_t *conflict)
-{
-  SVN_ERR_ASSERT_NO_RETURN(svn_client_conflict_get_kind(conflict)
-      == svn_wc_conflict_kind_text);
-
-  return get_conflict_desc2_t(conflict)->mime_type;
-}
-
-svn_error_t *
-svn_client_conflict_text_get_contents(const char **base_abspath,
-                                      const char **working_abspath,
-                                      const char **incoming_old_abspath,
-                                      const char **incoming_new_abspath,
-                                      const svn_client_conflict_t *conflict,
-                                      apr_pool_t *result_pool,
-                                      apr_pool_t *scratch_pool)
-{
-  SVN_ERR_ASSERT(svn_client_conflict_get_kind(conflict)
-      == svn_wc_conflict_kind_text);
-
-  if (base_abspath)
-    {
-      if (svn_client_conflict_get_operation(conflict) ==
-          svn_wc_operation_merge)
-        *base_abspath = NULL; /* ### WC base contents not available yet */
-      else /* update/switch */
-        *base_abspath = get_conflict_desc2_t(conflict)->base_abspath;
-    }
-
-  if (working_abspath)
-    *working_abspath = get_conflict_desc2_t(conflict)->my_abspath;
-
-  if (incoming_old_abspath)
-    *incoming_old_abspath = get_conflict_desc2_t(conflict)->base_abspath;
-
-  if (incoming_new_abspath)
-    *incoming_new_abspath = get_conflict_desc2_t(conflict)->their_abspath;
-
-  return SVN_NO_ERROR;
-}

Modified: subversion/branches/ra-git/subversion/libsvn_client/revisions.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_client/revisions.c?rev=1764214&r1=1764213&r2=1764214&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_client/revisions.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_client/revisions.c Tue Oct 11 
09:11:50 2016
@@ -89,7 +89,9 @@ svn_client__get_revision_number(svn_revn
         /* The BASE, COMMITTED, and PREV revision keywords do not
            apply to URLs. */
         if (svn_path_is_url(local_abspath))
-          goto invalid_rev_arg;
+          return svn_error_create(SVN_ERR_CLIENT_BAD_REVISION, NULL,
+                                  _("PREV, BASE, or COMMITTED revision "
+                                    "keywords are invalid for URL"));
 
         err = svn_wc__node_get_origin(NULL, revnum, NULL, NULL, NULL, NULL,
                                       NULL,
@@ -129,7 +131,9 @@ svn_client__get_revision_number(svn_revn
         /* The BASE, COMMITTED, and PREV revision keywords do not
            apply to URLs. */
         if (svn_path_is_url(local_abspath))
-          goto invalid_rev_arg;
+          return svn_error_create(SVN_ERR_CLIENT_BAD_REVISION, NULL,
+                                  _("PREV, BASE, or COMMITTED revision "
+                                    "keywords are invalid for URL"));
 
         SVN_ERR(svn_wc__node_get_changed_info(revnum, NULL, NULL,
                                               wc_ctx, local_abspath,
@@ -183,10 +187,4 @@ svn_client__get_revision_number(svn_revn
     *revnum = *youngest_rev;
 
   return SVN_NO_ERROR;
-
-  invalid_rev_arg:
-    return svn_error_create(
-      SVN_ERR_CLIENT_BAD_REVISION, NULL,
-      _("PREV, BASE, or COMMITTED revision keywords are invalid for URL"));
-
 }

Modified: subversion/branches/ra-git/subversion/libsvn_delta/branch.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_delta/branch.c?rev=1764214&r1=1764213&r2=1764214&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_delta/branch.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_delta/branch.c Tue Oct 11 
09:11:50 2016
@@ -145,36 +145,6 @@ branch_txn_get_branches(const svn_branch
 
 /* An #svn_branch__txn_t method. */
 static svn_error_t *
-branch_txn_add_branch(svn_branch__txn_t *txn,
-                      svn_branch__state_t *branch,
-                      apr_pool_t *scratch_pool)
-{
-  APR_ARRAY_PUSH(txn->priv->branches, void *) = branch;
-
-  return SVN_NO_ERROR;
-}
-
-/* An #svn_branch__txn_t method. */
-static svn_branch__state_t *
-branch_txn_add_new_branch(svn_branch__txn_t *txn,
-                          const char *bid,
-                          int root_eid,
-                          apr_pool_t *scratch_pool)
-{
-  svn_branch__state_t *new_branch;
-
-  SVN_ERR_ASSERT_NO_RETURN(root_eid != -1);
-
-  new_branch = branch_state_create(bid, root_eid, txn,
-                                   txn->priv->branches->pool);
-
-  APR_ARRAY_PUSH(txn->priv->branches, void *) = new_branch;
-
-  return new_branch;
-}
-
-/* An #svn_branch__txn_t method. */
-static svn_error_t *
 branch_txn_delete_branch(svn_branch__txn_t *txn,
                          const char *bid,
                          apr_pool_t *scratch_pool)
@@ -223,79 +193,63 @@ branch_txn_new_eid(svn_branch__txn_t *tx
 static svn_error_t *
 branch_txn_open_branch(svn_branch__txn_t *txn,
                        svn_branch__state_t **new_branch_p,
-                       const char *new_branch_id,
+                       const char *branch_id,
                        int root_eid,
+                       svn_branch__rev_bid_eid_t *tree_ref,
                        apr_pool_t *result_pool,
                        apr_pool_t *scratch_pool)
 {
   svn_branch__state_t *new_branch;
 
-  /* if the subbranch already exists, just return it */
+  /* if the branch already exists, just return it, else create it */
   new_branch
-    = svn_branch__txn_get_branch_by_id(txn, new_branch_id, scratch_pool);
+    = svn_branch__txn_get_branch_by_id(txn, branch_id, scratch_pool);
   if (new_branch)
     {
       SVN_ERR_ASSERT(root_eid == svn_branch__root_eid(new_branch));
     }
   else
     {
-      new_branch = svn_branch__txn_add_new_branch(txn,
-                                                  new_branch_id,
-                                                  root_eid, scratch_pool);
-    }
-
-  if (new_branch_p)
-    *new_branch_p = new_branch;
-  return SVN_NO_ERROR;
-}
+      SVN_ERR_ASSERT_NO_RETURN(root_eid != -1);
 
-/* An #svn_branch__txn_t method. */
-static svn_error_t *
-branch_txn_branch(svn_branch__txn_t *txn,
-                  svn_branch__state_t **new_branch_p,
-                  svn_branch__rev_bid_eid_t *from,
-                  const char *new_branch_id,
-                  apr_pool_t *result_pool,
-                  apr_pool_t *scratch_pool)
-{
-  svn_branch__state_t *new_branch;
-  svn_branch__state_t *from_branch;
-  svn_element__tree_t *from_subtree;
+      new_branch = branch_state_create(branch_id, root_eid, txn,
+                                       txn->priv->branches->pool);
+      APR_ARRAY_PUSH(txn->priv->branches, void *) = new_branch;
+    }
 
-  SVN_ERR(branch_in_rev_or_txn(&from_branch, from, txn, scratch_pool));
-  /* Source branch must exist */
-  if (! from_branch)
+  if (tree_ref)
     {
-      return svn_error_createf(SVN_BRANCH__ERR, NULL,
-                               _("Cannot branch from r%ld %s e%d: "
-                                 "branch does not exist"),
-                               from->rev, from->bid, from->eid);
-    }
+      svn_branch__state_t *from_branch;
+      svn_element__tree_t *tree;
 
-  SVN_ERR_ASSERT(from_branch->priv->is_flat);
+      SVN_ERR(branch_in_rev_or_txn(&from_branch, tree_ref, txn, scratch_pool));
+      /* Source branch must exist */
+      if (! from_branch)
+        {
+          return svn_error_createf(SVN_BRANCH__ERR, NULL,
+                                   _("Cannot branch from r%ld %s e%d: "
+                                     "branch does not exist"),
+                                   tree_ref->rev, tree_ref->bid, 
tree_ref->eid);
+        }
 
-  SVN_ERR(svn_branch__state_get_elements(from_branch, &from_subtree,
-                                         scratch_pool));
-  from_subtree = svn_element__tree_get_subtree_at_eid(from_subtree,
-                                                     from->eid,
-                                                     scratch_pool);
-  /* Source element must exist */
-  if (! from_subtree)
-    {
-      return svn_error_createf(SVN_BRANCH__ERR, NULL,
-                               _("Cannot branch from r%ld %s e%d: "
-                                 "element does not exist"),
-                               from->rev, from->bid, from->eid);
-    }
+      SVN_ERR_ASSERT(from_branch->priv->is_flat);
 
-  new_branch = svn_branch__txn_add_new_branch(txn,
-                                              new_branch_id,
-                                              from->eid, scratch_pool);
+      SVN_ERR(svn_branch__state_get_elements(from_branch, &tree,
+                                             scratch_pool));
+      tree = svn_element__tree_get_subtree_at_eid(tree, tree_ref->eid,
+                                                  scratch_pool);
+      /* Source element must exist */
+      if (! tree)
+        {
+          return svn_error_createf(SVN_BRANCH__ERR, NULL,
+                                   _("Cannot branch from r%ld %s e%d: "
+                                     "element does not exist"),
+                                   tree_ref->rev, tree_ref->bid, 
tree_ref->eid);
+        }
 
-  /* Populate the mapping from the 'from' source */
-  SVN_ERR(branch_instantiate_elements(new_branch, from_subtree,
-                                      scratch_pool));
-  new_branch->priv->is_flat = TRUE;
+      /* Populate the tree from the 'from' source */
+      SVN_ERR(branch_instantiate_elements(new_branch, tree, scratch_pool));
+    }
 
   if (new_branch_p)
     *new_branch_p = new_branch;
@@ -354,32 +308,6 @@ svn_branch__txn_get_branches(const svn_b
 }
 
 svn_error_t *
-svn_branch__txn_add_branch(svn_branch__txn_t *txn,
-                           svn_branch__state_t *branch,
-                           apr_pool_t *scratch_pool)
-{
-  SVN_ERR(txn->vtable->add_branch(txn,
-                                  branch,
-                                  scratch_pool));
-
-  return SVN_NO_ERROR;
-}
-
-svn_branch__state_t *
-svn_branch__txn_add_new_branch(svn_branch__txn_t *txn,
-                               const char *bid,
-                               int root_eid,
-                               apr_pool_t *scratch_pool)
-{
-  svn_branch__state_t *new_branch
-    = txn->vtable->add_new_branch(txn,
-                                  bid, root_eid,
-                                  scratch_pool);
-
-  return new_branch;
-}
-
-svn_error_t *
 svn_branch__txn_delete_branch(svn_branch__txn_t *txn,
                               const char *bid,
                               apr_pool_t *scratch_pool)
@@ -415,35 +343,21 @@ svn_branch__txn_new_eid(svn_branch__txn_
 svn_error_t *
 svn_branch__txn_open_branch(svn_branch__txn_t *txn,
                             svn_branch__state_t **new_branch_p,
-                            const char *new_branch_id,
+                            const char *branch_id,
                             int root_eid,
+                            svn_branch__rev_bid_eid_t *tree_ref,
                             apr_pool_t *result_pool,
                             apr_pool_t *scratch_pool)
 {
   SVN_ERR(txn->vtable->open_branch(txn,
                                    new_branch_p,
-                                   new_branch_id,
-                                   root_eid, result_pool,
+                                   branch_id,
+                                   root_eid, tree_ref, result_pool,
                                    scratch_pool));
   return SVN_NO_ERROR;
 }
 
 svn_error_t *
-svn_branch__txn_branch(svn_branch__txn_t *txn,
-                       svn_branch__state_t **new_branch_p,
-                       svn_branch__rev_bid_eid_t *from,
-                       const char *new_branch_id,
-                       apr_pool_t *result_pool,
-                       apr_pool_t *scratch_pool)
-{
-  SVN_ERR(txn->vtable->branch(txn,
-                              new_branch_p,
-                              from, new_branch_id, result_pool,
-                              scratch_pool));
-  return SVN_NO_ERROR;
-}
-
-svn_error_t *
 svn_branch__txn_finalize_eids(svn_branch__txn_t *txn,
                               apr_pool_t *scratch_pool)
 {
@@ -680,13 +594,10 @@ branch_txn_create(svn_branch__repos_t *r
   static const svn_branch__txn_vtable_t vtable = {
     {0},
     branch_txn_get_branches,
-    branch_txn_add_branch,
-    branch_txn_add_new_branch,
     branch_txn_delete_branch,
     branch_txn_get_num_new_eids,
     branch_txn_new_eid,
     branch_txn_open_branch,
-    branch_txn_branch,
     branch_txn_finalize_eids,
     branch_txn_serialize,
     branch_txn_sequence_point,
@@ -1701,7 +1612,7 @@ svn_branch__txn_parse(svn_branch__txn_t
 
       SVN_ERR(svn_branch__state_parse(&branch, txn, stream,
                                       result_pool, scratch_pool));
-      SVN_ERR(svn_branch__txn_add_branch(txn, branch, scratch_pool));
+      APR_ARRAY_PUSH(txn->priv->branches, void *) = branch;
     }
 
   *txn_p = txn;

Modified: subversion/branches/ra-git/subversion/libsvn_delta/branch_compat.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_delta/branch_compat.c?rev=1764214&r1=1764213&r2=1764214&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_delta/branch_compat.c 
(original)
+++ subversion/branches/ra-git/subversion/libsvn_delta/branch_compat.c Tue Oct 
11 09:11:50 2016
@@ -1763,35 +1763,6 @@ compat_branch_txn_get_branches(const svn
 
 /* An #svn_branch__txn_t method. */
 static svn_error_t *
-compat_branch_txn_add_branch(svn_branch__txn_t *txn,
-                             svn_branch__state_t *branch,
-                             apr_pool_t *scratch_pool)
-{
-  /* Just forwarding: nothing more is needed. */
-  SVN_ERR(svn_branch__txn_add_branch(txn->priv->txn,
-                                     branch,
-                                     scratch_pool));
-  return SVN_NO_ERROR;
-}
-
-/* An #svn_branch__txn_t method. */
-static svn_branch__state_t *
-compat_branch_txn_add_new_branch(svn_branch__txn_t *txn,
-                                 const char *bid,
-                                 int root_eid,
-                                 apr_pool_t *scratch_pool)
-{
-  /* Just forwarding: nothing more is needed. */
-  svn_branch__state_t *new_branch
-    = svn_branch__txn_add_new_branch(txn->priv->txn,
-                                     bid, root_eid,
-                                     scratch_pool);
-
-  return new_branch;
-}
-
-/* An #svn_branch__txn_t method. */
-static svn_error_t *
 compat_branch_txn_delete_branch(svn_branch__txn_t *txn,
                                 const char *bid,
                                 apr_pool_t *scratch_pool)
@@ -1846,13 +1817,14 @@ compat_branch_txn_open_branch(svn_branch
                               svn_branch__state_t **new_branch_p,
                               const char *new_branch_id,
                               int root_eid,
+                              svn_branch__rev_bid_eid_t *tree_ref,
                               apr_pool_t *result_pool,
                               apr_pool_t *scratch_pool)
 {
   /* Just forwarding: nothing more is needed. */
   SVN_ERR(svn_branch__txn_open_branch(txn->priv->txn,
                                       new_branch_p,
-                                      new_branch_id, root_eid,
+                                      new_branch_id, root_eid, tree_ref,
                                       result_pool,
                                       scratch_pool));
   return SVN_NO_ERROR;
@@ -1860,29 +1832,6 @@ compat_branch_txn_open_branch(svn_branch
 
 /* An #svn_branch__txn_t method. */
 static svn_error_t *
-compat_branch_txn_branch(svn_branch__txn_t *txn,
-                         svn_branch__state_t **new_branch_p,
-                         svn_branch__rev_bid_eid_t *from,
-                         const char *new_branch_id,
-                         apr_pool_t *result_pool,
-                         apr_pool_t *scratch_pool)
-{
-  svn_branch__state_t *new_branch;
-
-  /* Just forwarding: nothing more is needed. */
-  SVN_ERR(svn_branch__txn_branch(txn->priv->txn,
-                                 &new_branch, from,
-                                 new_branch_id,
-                                 result_pool,
-                                 scratch_pool));
-
-  if (new_branch_p)
-    *new_branch_p = new_branch;
-  return SVN_NO_ERROR;
-}
-
-/* An #svn_branch__txn_t method. */
-static svn_error_t *
 compat_branch_txn_serialize(svn_branch__txn_t *txn,
                             svn_stream_t *stream,
                             apr_pool_t *scratch_pool)
@@ -2012,13 +1961,10 @@ svn_branch__compat_txn_from_delta_for_co
   static const svn_branch__txn_vtable_t vtable = {
     {0},
     compat_branch_txn_get_branches,
-    compat_branch_txn_add_branch,
-    compat_branch_txn_add_new_branch,
     compat_branch_txn_delete_branch,
     compat_branch_txn_get_num_new_eids,
     compat_branch_txn_new_eid,
     compat_branch_txn_open_branch,
-    compat_branch_txn_branch,
     compat_branch_txn_finalize_eids,
     compat_branch_txn_serialize,
     compat_branch_txn_sequence_point,

Modified: subversion/branches/ra-git/subversion/libsvn_delta/branch_nested.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_delta/branch_nested.c?rev=1764214&r1=1764213&r2=1764214&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_delta/branch_nested.c 
(original)
+++ subversion/branches/ra-git/subversion/libsvn_delta/branch_nested.c Tue Oct 
11 09:11:50 2016
@@ -295,14 +295,18 @@ svn_branch__instantiate_elements_r(svn_b
         svn_branch__subtree_t *this_subtree = apr_hash_this_val(hi);
         const char *new_branch_id;
         svn_branch__state_t *new_branch;
+        /*### svn_branch__history_t *history;*/
 
         /* branch this subbranch into NEW_BRANCH (recursing) */
         new_branch_id = svn_branch__id_nest(to_branch->bid, this_outer_eid,
                                             scratch_pool);
-        new_branch = svn_branch__txn_add_new_branch(to_branch->txn,
-                                                    new_branch_id,
-                                                    
this_subtree->tree->root_eid,
-                                                    scratch_pool);
+        SVN_ERR(svn_branch__txn_open_branch(to_branch->txn, &new_branch,
+                                            new_branch_id,
+                                            this_subtree->tree->root_eid,
+                                            NULL /*tree_ref*/,
+                                            scratch_pool, scratch_pool));
+        /*### SVN_ERR(svn_branch__state_set_history(new_branch, history,
+                                              scratch_pool));*/
 
         SVN_ERR(svn_branch__instantiate_elements_r(new_branch, *this_subtree,
                                                    scratch_pool));
@@ -462,35 +466,6 @@ nested_branch_txn_get_branches(const svn
 
 /* An #svn_branch__txn_t method. */
 static svn_error_t *
-nested_branch_txn_add_branch(svn_branch__txn_t *txn,
-                             svn_branch__state_t *branch,
-                             apr_pool_t *scratch_pool)
-{
-  /* Just forwarding: nothing more is needed. */
-  SVN_ERR(svn_branch__txn_add_branch(txn->priv->wrapped_txn,
-                                     branch,
-                                     scratch_pool));
-  return SVN_NO_ERROR;
-}
-
-/* An #svn_branch__txn_t method. */
-static svn_branch__state_t *
-nested_branch_txn_add_new_branch(svn_branch__txn_t *txn,
-                                 const char *bid,
-                                 int root_eid,
-                                 apr_pool_t *scratch_pool)
-{
-  /* Just forwarding: nothing more is needed. */
-  svn_branch__state_t *new_branch
-    = svn_branch__txn_add_new_branch(txn->priv->wrapped_txn,
-                                     bid, root_eid,
-                                     scratch_pool);
-
-  return new_branch;
-}
-
-/* An #svn_branch__txn_t method. */
-static svn_error_t *
 nested_branch_txn_delete_branch(svn_branch__txn_t *txn,
                                 const char *bid,
                                 apr_pool_t *scratch_pool)
@@ -537,47 +512,33 @@ nested_branch_txn_open_branch(svn_branch
                               svn_branch__state_t **new_branch_p,
                               const char *new_branch_id,
                               int root_eid,
+                              svn_branch__rev_bid_eid_t *tree_ref,
                               apr_pool_t *result_pool,
                               apr_pool_t *scratch_pool)
 {
-  /* Just forwarding: nothing more is needed. */
+  svn_branch__state_t *new_branch;
+
   SVN_ERR(svn_branch__txn_open_branch(txn->priv->wrapped_txn,
-                                      new_branch_p,
-                                      new_branch_id, root_eid,
+                                      &new_branch,
+                                      new_branch_id, root_eid, tree_ref,
                                       result_pool,
                                       scratch_pool));
-  return SVN_NO_ERROR;
-}
-
-/* Implements nested branching.
- * An #svn_branch__txn_t method. */
-static svn_error_t *
-nested_branch_txn_branch(svn_branch__txn_t *txn,
-                         svn_branch__state_t **new_branch_p,
-                         svn_branch__rev_bid_eid_t *from,
-                         const char *new_branch_id,
-                         apr_pool_t *result_pool,
-                         apr_pool_t *scratch_pool)
-{
-  svn_branch__state_t *new_branch;
-  svn_branch__state_t *from_branch;
-  svn_branch__subtree_t *from_subtree;
-
-  SVN_ERR(svn_branch__txn_branch(txn->priv->wrapped_txn,
-                                 &new_branch, from,
-                                 new_branch_id,
-                                 result_pool,
-                                 scratch_pool));
 
   /* Recursively branch any nested branches */
-  /* (The way we're doing it here also redundantly re-instantiates all the
-     elements in NEW_BRANCH.) */
-  SVN_ERR(branch_in_rev_or_txn(&from_branch, from, txn->priv->wrapped_txn,
-                               scratch_pool));
-  SVN_ERR(svn_branch__get_subtree(from_branch, &from_subtree, from->eid,
-                                  scratch_pool));
-  SVN_ERR(svn_branch__instantiate_elements_r(new_branch, *from_subtree,
-                                             scratch_pool));
+  if (tree_ref)
+    {
+      svn_branch__state_t *from_branch;
+      svn_branch__subtree_t *from_subtree;
+
+      /* (The way we're doing it here also redundantly re-instantiates all the
+         elements in NEW_BRANCH.) */
+      SVN_ERR(branch_in_rev_or_txn(&from_branch, tree_ref,
+                                   txn->priv->wrapped_txn, scratch_pool));
+      SVN_ERR(svn_branch__get_subtree(from_branch, &from_subtree,
+                                      tree_ref->eid, scratch_pool));
+      SVN_ERR(svn_branch__instantiate_elements_r(new_branch, *from_subtree,
+                                                 scratch_pool));
+    }
 
   if (new_branch_p)
     *new_branch_p = new_branch;
@@ -676,13 +637,10 @@ svn_branch__nested_txn_create(svn_branch
   static const svn_branch__txn_vtable_t vtable = {
     {0},
     nested_branch_txn_get_branches,
-    nested_branch_txn_add_branch,
-    nested_branch_txn_add_new_branch,
     nested_branch_txn_delete_branch,
     nested_branch_txn_get_num_new_eids,
     nested_branch_txn_new_eid,
     nested_branch_txn_open_branch,
-    nested_branch_txn_branch,
     nested_branch_txn_finalize_eids,
     nested_branch_txn_serialize,
     nested_branch_txn_sequence_point,

Modified: subversion/branches/ra-git/subversion/libsvn_diff/binary_diff.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_diff/binary_diff.c?rev=1764214&r1=1764213&r2=1764214&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_diff/binary_diff.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_diff/binary_diff.c Tue Oct 11 
09:11:50 2016
@@ -103,7 +103,9 @@ base85_value(int *value, char c)
     return svn_error_create(SVN_ERR_DIFF_UNEXPECTED_DATA, NULL,
                             _("Invalid base85 value"));
 
-  *value = (p - b85str);
+  /* It's safe to cast the ptrdiff_t value of the pointer difference
+     to int because the value will always be in the range [0..84]. */
+  *value = (int)(p - b85str);
   return SVN_NO_ERROR;
 }
 



Reply via email to