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

[PATCH] Single file merge tracking implementation. /merge-tracking/subversion/libsvn_client/diff.c

From: Kamesh Jayachandran <kamesh_at_collab.net>
Date: 2006-06-28 17:34:29 CEST

Hi All,
Find the patch attached.

With regards
Kamesh Jayachandran
[[[
Patch by: Kamesh Jayachandran <kamesh@collab.net>

Single file merge tracking implementation.

* subversion/libsvn_client/diff.c
  (do_single_file_merge):
   Added 'svn_boolean_t dry_run' and 'svn_client_ctx_t *ctx' as args.
   Implemented merge tracking for single file merges the same way as
   directory merges.
   Remove the FIXME docstring for merge-tracking.
  (svn_client_merge2):
   calling do_single_file_merge with the new set of args.
  (svn_client_merge_peg2):
   calling do_single_file_merge with the new set of args.
]]]

Index: subversion/libsvn_client/diff.c
===================================================================
--- subversion/libsvn_client/diff.c (revision 20275)
+++ subversion/libsvn_client/diff.c (working copy)
@@ -1961,7 +1961,6 @@
                             
 
 /* The single-file, simplified version of do_merge. */
-/* ### FIXME: To handle merge tracking, follow pattern from do_merge(). */
 static svn_error_t *
 do_single_file_merge(const char *initial_URL1,
                      const char *initial_path1,
@@ -1972,7 +1971,9 @@
                      const svn_opt_revision_t *peg_revision,
                      const char *target_wcpath,
                      svn_wc_adm_access_t *adm_access,
+ svn_boolean_t dry_run,
                      struct merge_cmd_baton *merge_b,
+ svn_client_ctx_t *ctx,
                      apr_pool_t *pool)
 {
   apr_hash_t *props1, *props2;
@@ -1983,10 +1984,24 @@
   apr_array_header_t *propchanges;
   svn_wc_notify_state_t prop_state = svn_wc_notify_state_unknown;
   svn_wc_notify_state_t text_state = svn_wc_notify_state_unknown;
- const char *URL1, *path1, *URL2, *path2;
+ const char *URL1, *path1, *URL2, *path2, *rel_path;
   svn_opt_revision_t *revision1, *revision2;
   svn_error_t *err;
+ svn_merge_range_t range;
+ svn_ra_session_t *ra_session;
+ svn_boolean_t is_revert;
+ apr_hash_t *target_mergeinfo;
+ apr_array_header_t *remaining_ranges;
 
+ /* Sanity check -- ensure that we have valid revisions to look at. */
+ if ((initial_revision1->kind == svn_opt_revision_unspecified)
+ || (initial_revision2->kind == svn_opt_revision_unspecified))
+ {
+ return svn_error_create
+ (SVN_ERR_CLIENT_BAD_REVISION, NULL,
+ _("Not all required revisions are specified"));
+ }
+
   /* If we are performing a pegged merge, we need to find out what our
      actual URLs will be. */
   if (peg_revision->kind != svn_opt_revision_unspecified)
@@ -2018,6 +2033,30 @@
       *revision2 = *initial_revision2;
     }
   
+ /* Establish first RA session to URL1. */
+ SVN_ERR(svn_client__open_ra_session_internal(&ra_session, URL1, NULL,
+ NULL, NULL, FALSE, TRUE,
+ ctx, pool));
+
+ /* Resolve the revision numbers, and store them as a merge range.
+ Note that the "start" of a merge range is inclusive. */
+ SVN_ERR(svn_client__get_revision_number
+ (&range.start, ra_session, revision1, path1, pool));
+ range.start += 1;
+ SVN_ERR(svn_client__get_revision_number
+ (&range.end, ra_session, revision2, path2, pool));
+ is_revert = (range.start > range.end);
+
+ /* Look at the merge info prop of the WC target to see what's
+ already been merged into it. */
+ SVN_ERR(parse_merge_info(&target_mergeinfo, target_wcpath, adm_access, ctx,
+ pool));
+
+ SVN_ERR(svn_client__path_relative_to_root(&rel_path, URL1, NULL,
+ ra_session, adm_access, pool));
+ SVN_ERR(calculate_merge_ranges(&remaining_ranges, rel_path, target_mergeinfo,
+ &range, is_revert, pool));
+
   /* ### heh, funny. we could be fetching two fulltexts from two
      *totally* different repositories here. :-) */
   SVN_ERR(single_file_merge_get_file(&tmpfile1, &props1, &rev1,
@@ -2071,6 +2110,10 @@
                                     pool);
     }
 
+ if (!dry_run)
+ SVN_ERR(update_wc_merge_info(target_wcpath, target_mergeinfo, rel_path,
+ remaining_ranges, is_revert, adm_access,
+ pool));
   return SVN_NO_ERROR;
 }
 
@@ -2921,7 +2964,9 @@
                                    &peg_revision,
                                    target_wcpath,
                                    adm_access,
+ dry_run,
                                    &merge_cmd_baton,
+ ctx,
                                    pool));
     }
 
@@ -3050,7 +3095,9 @@
                                    peg_revision,
                                    target_wcpath,
                                    adm_access,
+ dry_run,
                                    &merge_cmd_baton,
+ ctx,
                                    pool));
     }
 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed Jun 28 17:34:49 2006

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

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.