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

Re: svn commit: r1135635 - /subversion/trunk/subversion/libsvn_wc/props.c

From: Daniel Shahaf <danielsh_at_elego.de>
Date: Wed, 15 Jun 2011 06:55:19 +0300

Daniel Shahaf wrote on Wed, Jun 15, 2011 at 06:33:46 +0300:
> stsp_at_apache.org wrote on Tue, Jun 14, 2011 at 15:10:50 -0000:
> > + svn_stringbuf_appendcstr(buf, _("Local property value:\n"));
> > + if (mine_is_binary)
> > + svn_stringbuf_appendcstr(buf, _("Cannot display: property value is "
> > + "binary data\n"));
>
> Could we just print a hex dump of the value?

Concretely:

[[[
but the property has already been locally changed to a different value.
Local property value:
mine
Incoming property value:
0x7E454B4602010100000000000000000002003D0001000000A01440000000000040000000000000
]]]

Patch to produce that:

[[[
Index: subversion/libsvn_wc/props.c
===================================================================
--- subversion/libsvn_wc/props.c (revision 1135910)
+++ subversion/libsvn_wc/props.c (working copy)
@@ -545,6 +545,16 @@ maybe_prop_value(const svn_skel_t *skel,
 }
 
 
+/** Store printf("%x", c) into BUF and return the latter. */
+static APR_INLINE const char *
+hex_of(char *buf, const unsigned char c)
+{
+ buf[0] = "01234567890ABCDEF"[(c >> 4)];
+ buf[1] = "01234567890ABCDEF"[c & 0xf];
+ buf[2] = '\0';
+ return buf;
+}
+
 /* Parse a property conflict description from the provided SKEL.
    The result includes a descriptive message (see generate_conflict_message)
    and maybe a diff of property values containing conflict markers.
@@ -647,8 +657,14 @@ prop_conflict_from_skel(const svn_string_t **confl
     {
       svn_stringbuf_appendcstr(buf, _("Local property value:\n"));
       if (mine_is_binary)
- svn_stringbuf_appendcstr(buf, _("Cannot display: property value is "
- "binary data\n"));
+ {
+ char hex[3] = {0};
+ svn_string_t mine2 = *mine;
+
+ svn_stringbuf_appendcstr(buf, "0x");
+ while (mine2.len--)
+ svn_stringbuf_appendbytes(buf, hex_of(hex, *mine2.data++), 2);
+ }
       else
         svn_stringbuf_appendbytes(buf, mine->data, mine->len);
       svn_stringbuf_appendcstr(buf, "\n");
@@ -658,8 +674,14 @@ prop_conflict_from_skel(const svn_string_t **confl
     {
       svn_stringbuf_appendcstr(buf, _("Incoming property value:\n"));
       if (incoming_is_binary)
- svn_stringbuf_appendcstr(buf, _("Cannot display: property value is "
- "binary data\n"));
+ {
+ char hex[3] = {0};
+ svn_string_t incoming2 = *incoming;
+
+ svn_stringbuf_appendcstr(buf, "0x");
+ while (incoming2.len--)
+ svn_stringbuf_appendbytes(buf, hex_of(hex, *incoming2.data++), 2);
+ }
       else
         svn_stringbuf_appendbytes(buf, incoming->data, incoming->len);
       svn_stringbuf_appendcstr(buf, "\n");
]]]

If the general idea is plausible I'll clean up the patch, fix tests,
commit, etc.
Received on 2011-06-15 05:56:16 CEST

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.