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

[PATCH][MERGE-TRACKING] Step 3 of recording copyfrom mergeinfo during repos to repos copy

From: Madan U Sreenivasan <madan_at_collab.net>
Date: 2006-10-25 01:36:20 CEST

Hi,

    Please find attached step 3 in recording copyfrom mergeinfo during a
repos to repos copy. whats pending?

    - Python tests for the same

Regards,
Madan.

Step 3 of recording copyfrom history as mergeinfo on repos to repos copy.
This step
 - obtains the existing merge info on the source path
 - Merges it with the already obtained copyfrom information

On the merge-tracking branch:

* subversion/libsvn_client/copy.c
  (includes): svn_mergeinfo.h
  (get_src_merge_info): New. Obtains the existing mergeinfo hash for the
   given path.
  (calculate_target_merge_info): Modfied to use get_src_merge_info(), and
   merge the result with the already available copyfrom information.

--- subversion/libsvn_client/copy.c.bu4diff 2006-10-24 04:21:03.000000000 +0530
+++ subversion/libsvn_client/copy.c 2006-10-25 04:57:26.000000000 +0530
@@ -31,6 +31,7 @@
 #include "svn_opt.h"
 #include "svn_time.h"
 #include "svn_props.h"
+#include "svn_mergeinfo.h"
 
 #include "client.h"
 
@@ -239,6 +240,33 @@
   return SVN_NO_ERROR;
 }
 
+/* Obtain the mergeinfo hash of the given path in SRC_MERGEINFO.
+ If theres no merge info available, SRC_MERGEINFO will be NULL */
+static svn_error_t *
+get_src_merge_info(svn_ra_session_t *ra_session,
+ apr_hash_t **src_mergeinfo,
+ const char *src_path,
+ svn_revnum_t src_rev,
+ apr_pool_t *pool)
+{
+ apr_hash_t *merge_info;
+ apr_array_header_t *rel_paths = apr_array_make(pool, 1,
+ sizeof(src_path));
+
+ APR_ARRAY_PUSH(rel_paths, const char *) = src_path;
+
+ SVN_ERR(svn_ra_get_merge_info(ra_session, &merge_info, rel_paths,
+ src_rev, TRUE, pool));
+
+ /* Dereference to obtain only the merge info of the src_path provided */
+ if (merge_info)
+ *src_mergeinfo = apr_hash_get(merge_info, src_path, APR_HASH_KEY_STRING);
+ else
+ *src_mergeinfo = NULL;
+
+ return SVN_NO_ERROR;
+}
+
 /* Obtain the copyfrom merge info and the existing merge info of
    the source path, merge them and set as a svn_string_t in
    TARGET_MERGEINFO. */
@@ -252,7 +280,7 @@
 {
   const char *repos_root;
   const char *copyfrom_path = copyfrom_url;
- apr_hash_t *copyfrom_mergeinfo;
+ apr_hash_t *copyfrom_mergeinfo, *src_mergeinfo;
   svn_stringbuf_t *mergeinfo;
 
   /* Find src path relative to the repos root */
@@ -260,14 +288,19 @@
   while (*copyfrom_path++ == *repos_root++);
   copyfrom_path--;
 
+ /* Obtain copyfrom information of the source */
   SVN_ERR(get_copyfrom_merge_info(ra_session, &copyfrom_mergeinfo,
                                   src_rel_path, copyfrom_path,
                                   src_revnum, pool));
 
- /* TODO: Obtain existing mergeinfo via svn_ra_get_merge_info() */
- /* TODO: Merge copyfrom and existing mergeinfo to fill target_mergeinfo
- using svn_mergeinfo_merge() */
- /* For now, stringify copyfrom_mergeinfo and return */
+ /* Obtain existing mergeinfo of the source */
+ SVN_ERR(get_src_merge_info(ra_session, &src_mergeinfo,
+ copyfrom_path, src_revnum, pool));
+
+ /* Merge copyfrom and existing mergeinfo to fill target_mergeinfo */
+ if (src_mergeinfo)
+ SVN_ERR(svn_mergeinfo_merge(&copyfrom_mergeinfo, src_mergeinfo,
+ copyfrom_mergeinfo, pool));
   SVN_ERR(svn_mergeinfo_to_string(&mergeinfo, copyfrom_mergeinfo, pool));
   *target_mergeinfo = svn_string_create_from_buf(mergeinfo, pool);
 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed Oct 25 01:07:02 2006

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