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

Re: Julian, side effect of r32015?

From: Senthil Kumaran S <senthil_at_collab.net>
Date: Wed, 09 Jul 2008 03:11:31 +0530

Karl Fogel wrote:
> Daniel Shahaf <d.s_at_daniel.shahaf.co.il> writes:
>> I think this is the side effect that David predicted here:
>>
>> http://thread.gmane.org/gmane.comp.version-control.subversion.svn/28621/focus=102169
>>
>> And I agree with him that svnlook shouldn't depend on libsvn_ra.
>
> I suspect you're right.
>
> Julian, maybe r32015/r32018/r32021 should be redone to put this code in
> libsvn_subr and svn_xml_private.h instead? I know you didn't want to
> put property-specific code in the 'svn_xml__' namespace, but that would
> appear to be by far the lesser evil here... Thoughts?

How about the attached patch.

[[[
Follow up to r32015, r32018, r32021, r32022.

Move XML-printing function from libsvn_client to libsvn_subr.

* build.conf
   (svnlook): Remove libsvn_client dependency.
   (libsvn_client): Remove svn_client_private.h from msvc-export.

* subversion/libsvn_subr/cmdline.c
   (): Include svn_string.h, svn_xml.h, svn_config.h
   (svn_cmdline__print_xml_prop): New function.

* subversion/svn/props.c
   (): Remove svn_client_private.h
   (svn_cl__print_xml_prop_hash): Use svn_cmdline__print_xml_prop instead of
    svn_client__print_xml_prop.

* subversion/svn/propget-cmd.c
   (): Remove svn_client_private.h
   (print_properties_xml): Use svn_cmdline__print_xml_prop instead of
    svn_client__print_xml_prop.
   (svn_cl__propget): Same as above.

* subversion/include/svn_cmdline.h
   (svn_cmdline__print_xml_prop): New API.

* subversion/include/private/svn_client_private.h
   Removed.

* subversion/svnlook/main.c
   (): Removed svn_client_private.h
   (do_plist): Use svn_cmdline__print_xml_prop instead of
    svn_client__print_xml_prop.

* subversion/libsvn_client/xml.c
   Removed.

Patch by: stylesen
Suggested by: dglasser
]]]

Thank You.

-- 
Senthil Kumaran S
http://www.stylesen.org/

Index: build.conf
===================================================================
--- build.conf (revision 32037)
+++ build.conf (working copy)
@@ -174,7 +174,7 @@
 path = subversion/svnlook
 install = bin
 manpages = subversion/svnlook/svnlook.1
-libs = libsvn_client libsvn_repos libsvn_fs libsvn_delta libsvn_diff libsvn_subr apriconv apr
+libs = libsvn_repos libsvn_fs libsvn_delta libsvn_diff libsvn_subr apriconv apr
 
 [svnserve]
 description = Subversion Server
@@ -226,7 +226,7 @@
 path = subversion/libsvn_client
 libs = libsvn_wc libsvn_ra libsvn_delta libsvn_diff libsvn_subr apriconv apr
 install = lib
-msvc-export = svn_client.h private\svn_client_private.h
+msvc-export = svn_client.h
 
 # Routines for binary diffing and tree-deltas
 [libsvn_delta]
Index: subversion/libsvn_subr/cmdline.c
===================================================================
--- subversion/libsvn_subr/cmdline.c (revision 32037)
+++ subversion/libsvn_subr/cmdline.c (working copy)
@@ -43,6 +43,9 @@
 #include "svn_auth.h"
 #include "svn_version.h"
 #include "utf_impl.h"
+#include "svn_string.h"
+#include "svn_xml.h"
+#include "svn_base64.h"
 #include "svn_config.h"
 
 #include "svn_private_config.h"
@@ -683,4 +686,42 @@
 }
 
 
+void
+svn_cmdline__print_xml_prop(svn_stringbuf_t **outstr,
+ const char* propname,
+ svn_string_t *propval,
+ apr_pool_t *pool)
+{
+ const char *xml_safe;
+ const char *encoding = NULL;
 
+ if (*outstr == NULL)
+ *outstr = svn_stringbuf_create("", pool);
+
+ if (svn_xml_is_xml_safe(propval->data, propval->len))
+ {
+ svn_stringbuf_t *xml_esc = NULL;
+ svn_xml_escape_cdata_string(&xml_esc, propval, pool);
+ xml_safe = xml_esc->data;
+ }
+ else
+ {
+ const svn_string_t *base64ed = svn_base64_encode_string(propval, pool);
+ encoding = "base64";
+ xml_safe = base64ed->data;
+ }
+
+ if (encoding)
+ svn_xml_make_open_tag(outstr, pool, svn_xml_protect_pcdata,
+ "property", "name", propname,
+ "encoding", encoding, NULL);
+ else
+ svn_xml_make_open_tag(outstr, pool, svn_xml_protect_pcdata,
+ "property", "name", propname, NULL);
+
+ svn_stringbuf_appendcstr(*outstr, xml_safe);
+
+ svn_xml_make_close_tag(outstr, pool, "property");
+}
+
+
Index: subversion/svn/props.c
===================================================================
--- subversion/svn/props.c (revision 32037)
+++ subversion/svn/props.c (working copy)
@@ -34,8 +34,6 @@
 #include "svn_base64.h"
 #include "cl.h"
 
-#include "private/svn_client_private.h"
-
 #include "svn_private_config.h"
 
 
@@ -149,7 +147,7 @@
 
           SVN_ERR(svn_cmdline_cstring_from_utf8(&pname_out, pname, pool));
 
- svn_client__print_xml_prop(outstr, pname_out, propval, pool);
+ svn_cmdline__print_xml_prop(outstr, pname_out, propval, pool);
         }
     }
 
Index: subversion/svn/propget-cmd.c
===================================================================
--- subversion/svn/propget-cmd.c (revision 32037)
+++ subversion/svn/propget-cmd.c (working copy)
@@ -35,8 +35,6 @@
 #include "svn_xml.h"
 #include "cl.h"
 
-#include "private/svn_client_private.h"
-
 #include "svn_private_config.h"
 
 
@@ -83,7 +81,7 @@
 
       svn_xml_make_open_tag(&sb, iterpool, svn_xml_normal, "target",
                         "path", filename, NULL);
- svn_client__print_xml_prop(&sb, pname, propval, iterpool);
+ svn_cmdline__print_xml_prop(&sb, pname, propval, iterpool);
       svn_xml_make_close_tag(&sb, iterpool, "target");
 
       SVN_ERR(svn_cl__error_checked_fputs(sb->data, stdout));
@@ -219,7 +217,7 @@
                                     "revprops",
                                     "rev", revstr, NULL);
 
- svn_client__print_xml_prop(&sb, pname_utf8, propval, pool);
+ svn_cmdline__print_xml_prop(&sb, pname_utf8, propval, pool);
 
               svn_xml_make_close_tag(&sb, pool, "revprops");
 
Index: subversion/include/svn_cmdline.h
===================================================================
--- subversion/include/svn_cmdline.h (revision 32037)
+++ subversion/include/svn_cmdline.h (working copy)
@@ -344,6 +344,22 @@
                          const char *argv[],
                          apr_pool_t *pool);
 
+/** Write a property as an XML element into @a *outstr.
+ *
+ * If @a outstr is NULL, allocate @a *outstr in @a pool; else append to
+ * @a *outstr, allocating in @a outstr's pool
+ *
+ * @a propname is the property name. @a propval is the property value, which
+ * will be encoded if it contains unsafe bytes.
+ *
+ * @since New in 1.6.
+ */
+void
+svn_cmdline__print_xml_prop(svn_stringbuf_t **outstr,
+ const char *propname,
+ svn_string_t *propval,
+ apr_pool_t *pool);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
Index: subversion/include/private/svn_client_private.h
===================================================================
--- subversion/include/private/svn_client_private.h (revision 32037)
+++ subversion/include/private/svn_client_private.h (working copy)
@@ -1,49 +0,0 @@
-/**
- * @copyright
- * ====================================================================
- * Copyright (c) 2008 CollabNet. All rights reserved.
- *
- * This software is licensed as described in the file COPYING, which
- * you should have received as part of this distribution. The terms
- * are also available at http://subversion.tigris.org/license-1.html.
- * If newer versions of this license are posted there, you may use a
- * newer version instead, at your option.
- *
- * This software consists of voluntary contributions made by many
- * individuals. For exact contribution history, see the revision
- * history and logs, available at http://subversion.tigris.org/.
- * ====================================================================
- * @endcopyright
- *
- * @file svn_client_private.h
- * @brief Private functions at the Subversion client layer.
- */
-
-#ifndef SVN_CLIENT_PRIVATE_H
-#define SVN_CLIENT_PRIVATE_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-/** Write a property as an XML element into @a *outstr.
- *
- * If @a outstr is NULL, allocate @a *outstr in @a pool; else append to
- * @a *outstr, allocating in @a outstr's pool
- *
- * @a propname is the property name. @a propval is the property value, which
- * will be encoded if it contains unsafe bytes.
- *
- * @since New in 1.6.
- */
-void
-svn_client__print_xml_prop(svn_stringbuf_t **outstr,
- const char *propname,
- svn_string_t *propval,
- apr_pool_t *pool);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* SVN_CLIENT_PRIVATE_H */
Index: subversion/svnlook/main.c
===================================================================
--- subversion/svnlook/main.c (revision 32037)
+++ subversion/svnlook/main.c (working copy)
@@ -45,10 +45,8 @@
 #include "svn_diff.h"
 #include "svn_xml.h"
 
-#include "private/svn_client_private.h"
-
 #include "svn_private_config.h"
-
+
 
 /*** Some convenience macros and types. ***/
 
@@ -1651,7 +1649,7 @@
           const char *pname_stdout;
           SVN_ERR(svn_cmdline_cstring_from_utf8(&pname_stdout, pname, pool));
           if (xml)
- svn_client__print_xml_prop(&sb, pname_stdout, propval, pool);
+ svn_cmdline__print_xml_prop(&sb, pname_stdout, propval, pool);
           else
             printf(" %s : %s\n", pname_stdout, propval->data);
         }
Index: subversion/libsvn_client/xml.c
===================================================================
--- subversion/libsvn_client/xml.c (revision 32037)
+++ subversion/libsvn_client/xml.c (working copy)
@@ -1,70 +0,0 @@
-/*
- * xml.c: XML output of Subversion data
- *
- * ====================================================================
- * Copyright (c) 2008 CollabNet. All rights reserved.
- *
- * This software is licensed as described in the file COPYING, which
- * you should have received as part of this distribution. The terms
- * are also available at http://subversion.tigris.org/license-1.html.
- * If newer versions of this license are posted there, you may use a
- * newer version instead, at your option.
- *
- * This software consists of voluntary contributions made by many
- * individuals. For exact contribution history, see the revision
- * history and logs, available at http://subversion.tigris.org/.
- * ====================================================================
- */
-
-/* ==================================================================== */
-
-
-/*** Includes. ***/
-#include "svn_string.h"
-#include "svn_xml.h"
-#include "svn_base64.h"
-
-#include "private/svn_client_private.h"
-
-#include "svn_private_config.h"
-
-
-/*** Code. ***/
-
-void
-svn_client__print_xml_prop(svn_stringbuf_t **outstr,
- const char* propname,
- svn_string_t *propval,
- apr_pool_t *pool)
-{
- const char *xml_safe;
- const char *encoding = NULL;
-
- if (*outstr == NULL)
- *outstr = svn_stringbuf_create("", pool);
-
- if (svn_xml_is_xml_safe(propval->data, propval->len))
- {
- svn_stringbuf_t *xml_esc = NULL;
- svn_xml_escape_cdata_string(&xml_esc, propval, pool);
- xml_safe = xml_esc->data;
- }
- else
- {
- const svn_string_t *base64ed = svn_base64_encode_string(propval, pool);
- encoding = "base64";
- xml_safe = base64ed->data;
- }
-
- if (encoding)
- svn_xml_make_open_tag(outstr, pool, svn_xml_protect_pcdata,
- "property", "name", propname,
- "encoding", encoding, NULL);
- else
- svn_xml_make_open_tag(outstr, pool, svn_xml_protect_pcdata,
- "property", "name", propname, NULL);
-
- svn_stringbuf_appendcstr(*outstr, xml_safe);
-
- svn_xml_make_close_tag(outstr, pool, "property");
-}

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: dev-help_at_subversion.tigris.org
Received on 2008-07-08 23:42:14 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.