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

[PATCH]merge-tracking svn diff pretty output for svn:mergeinfo diffs

From: Kamesh Jayachandran <kamesh_at_collab.net>
Date: 2006-07-07 09:05:49 CEST

Hi All,
As proposed by Garrett at
http://subversion.tigris.org/servlets/ReadMsg?list=dev&msgNo=117410
Find the attached patch.
This patch makes the svn diff output to be human friendly to read
something like the following,

<snip>
Property changes on: .
___________________________________________________________________
Name: svn:mergeinfo
   Reverted /branches/b1:r157
   Merged /branches/b1:r89-95
   Merged /branches/b2:r159

Index: test4.c
===================================================================
--- test4.c (revision 158)
+++ test4.c (working copy)
@@ -1 +0,0 @@
-hellow.

</snip>

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

Showing a diff of 'svn:mergeinfo' property like other property diffs
will be very difficult to understand especially when the wc target has
undergone large number of previous committed merges and many uncommitted
local merges.
* subversion/libsvn_client/diff.c
  (display_mergeinfo_diff):
   New function that shows a 'svn:mergeinfo' prop diff in a easily readable
   form.
  (display_prop_diffs): Calls display_mergeinfo_diff.
]]]

Index: subversion/libsvn_client/diff.c
===================================================================
--- subversion/libsvn_client/diff.c (revision 20444)
+++ subversion/libsvn_client/diff.c (working copy)
@@ -83,6 +83,50 @@
 }
 
 
+static svn_error_t *
+display_mergeinfo_diff(const char *orig_mergeinfo_val,
+ const char *new_mergeinfo_val,
+ const char *encoding,
+ apr_file_t *file,
+ apr_pool_t *pool)
+{
+ apr_hash_t *orig_mergeinfo_hash, *new_mergeinfo_hash, *added, *deleted;
+ apr_hash_index_t *hi;
+ const void *from_path;
+ apr_array_header_t *merge_revarray;
+ svn_stringbuf_t *merge_revstr;
+ if (orig_mergeinfo_val)
+ SVN_ERR(svn_mergeinfo_parse(orig_mergeinfo_val,
+ &orig_mergeinfo_hash, pool));
+ else
+ orig_mergeinfo_hash = apr_hash_make(pool);
+ if (new_mergeinfo_val)
+ SVN_ERR(svn_mergeinfo_parse(new_mergeinfo_val, &new_mergeinfo_hash, pool));
+ else
+ new_mergeinfo_hash = apr_hash_make(pool);
+ SVN_ERR(svn_mergeinfo_diff(&deleted, &added, orig_mergeinfo_hash,
+ new_mergeinfo_hash, pool));
+ for (hi = apr_hash_first(pool, deleted);
+ hi; hi = apr_hash_next(hi))
+ {
+ apr_hash_this(hi, &from_path, NULL, &merge_revarray);
+ svn_rangelist_to_string(&merge_revstr, merge_revarray, pool);
+
+ SVN_ERR(file_printf_from_utf8
+ (file, encoding,
+ " Reverted %s:r%s" APR_EOL_STR, from_path, merge_revstr->data));
+ }
+ for (hi = apr_hash_first(pool, added);
+ hi; hi = apr_hash_next(hi))
+ {
+ apr_hash_this(hi, &from_path, NULL, &merge_revarray);
+ svn_rangelist_to_string(&merge_revstr, merge_revarray, pool);
+ SVN_ERR(file_printf_from_utf8
+ (file, encoding,
+ " Merged %s:r%s" APR_EOL_STR, from_path, merge_revstr->data));
+ }
+ return SVN_NO_ERROR;
+}
 /* A helper func that writes out verbal descriptions of property diffs
    to FILE. Of course, the apr_file_t will probably be the 'outfile'
    passed to svn_client_diff3, which is probably stdout. */
@@ -128,6 +172,14 @@
       SVN_ERR(file_printf_from_utf8(file, encoding, _("Name: %s%s"),
                                     propchange->name, APR_EOL_STR));
 
+ if (strcmp(propchange->name, SVN_PROP_MERGE_INFO) == 0)
+ {
+ SVN_ERR(display_mergeinfo_diff(original_value->data,
+ propchange->value->data, encoding, file,
+ pool));
+ continue;
+ }
+
       /* For now, we have a rather simple heuristic: if this is an
          "svn:" property, then assume the value is UTF-8 and must
          therefore be converted before printing. Otherwise, just

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri Jul 7 09:06:45 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.