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

Re: svn commit: r12837 - in trunk: doc/book/book subversion/clients/cmdline tools/client-side

From: Peter N. Lundblad <peter_at_famlundblad.se>
Date: 2005-01-25 20:12:44 CET

On Mon, 24 Jan 2005 julianfoad@tigris.org wrote:

> Author: julianfoad
> Date: Mon Jan 24 16:34:29 2005
> New Revision: 12837
>
> --- trunk/subversion/clients/cmdline/ls-cmd.c (original)
> +++ trunk/subversion/clients/cmdline/ls-cmd.c Mon Jan 24 16:34:29 2005
> @@ -114,6 +116,109 @@
> +static svn_error_t *
> +print_dirents_xml (apr_hash_t *dirents,
> + const char *path,
> + svn_client_ctx_t *ctx,
> + apr_pool_t *pool)
> +{
> + /* Collate whole list into sb before printing. */
> + svn_stringbuf_t *sb = svn_stringbuf_create ("", pool);
> +
> + apr_array_header_t *array;
> + int i;
> +
> + array = svn_sort__hash (dirents, svn_sort_compare_items_as_paths, pool);
> +
> + /* "<list path=...>" */
> + svn_xml_make_open_tag (&sb, pool, svn_xml_normal, "list",
> + "path", path[0] == '\0' ? "." : path,
> + NULL);
> +
> + for (i = 0; i < array->nelts; ++i)
> + {
> + const char *utf8_entryname;
> + svn_dirent_t *dirent;
> + svn_sort__item_t *item;
> +
> + if (ctx->cancel_func)
> + SVN_ERR (ctx->cancel_func (ctx->cancel_baton));
> +
> + item = &APR_ARRAY_IDX (array, i, svn_sort__item_t);
> +
> + utf8_entryname = item->key;
> +
> + dirent = apr_hash_get (dirents, utf8_entryname, item->klen);
> +
> + /* "<entry ...>" */
> + svn_xml_make_open_tag (&sb, pool, svn_xml_protect_pcdata, "entry",
> + "kind", kind_str (dirent->kind),
> + NULL);
> +
> + /* "<name>xxx</name> */
> + svn_xml_make_open_tag (&sb, pool, svn_xml_protect_pcdata, "name", NULL);
> + svn_xml_escape_cdata_cstring (&sb, utf8_entryname, pool);
> + svn_xml_make_close_tag (&sb, pool, "name");
> +
> + /* "<size>xxx</size>" */
> + if (dirent->kind == svn_node_file)
> + {
> + svn_xml_make_open_tag (&sb, pool, svn_xml_protect_pcdata, "size",
> + NULL);
> + svn_xml_escape_cdata_cstring
> + (&sb, apr_psprintf (pool, "%" SVN_FILESIZE_T_FMT, dirent->size),
> + pool);
> + svn_xml_make_close_tag (&sb, pool, "size");
> + }
> +
> + /* "<commit revision=...>" */
> + svn_xml_make_open_tag (&sb, pool, svn_xml_protect_pcdata, "commit",
> + "revision",
> + apr_psprintf (pool, "%" SVN_REVNUM_T_FMT,

We use %ld everywhere else, so why not here?

> + dirent->created_rev),
> + NULL);
> + if (dirent->last_author)
> + {
> + /* "<author>xxx</author>" */
> + svn_xml_make_open_tag (&sb, pool, svn_xml_protect_pcdata, "author",
> + NULL);
> + svn_xml_escape_cdata_cstring (&sb, dirent->last_author, pool);
> + svn_xml_make_close_tag (&sb, pool, "author");
> + }
> + /* "<date>xxx</date>" */
> + svn_xml_make_open_tag (&sb, pool, svn_xml_protect_pcdata, "date", NULL);
> + svn_xml_escape_cdata_cstring
> + (&sb, svn_time_to_cstring (dirent->time, pool), pool);
> + svn_xml_make_close_tag (&sb, pool, "date");
> + /* "</commit>" */
> + svn_xml_make_close_tag (&sb, pool, "commit");
> +
> + /* "</entry>" */
> + svn_xml_make_close_tag (&sb, pool, "entry");
> + }
> +

This loop allocates memory, so it needs an iteration pool.

> + /* "</list>" */
> + svn_xml_make_close_tag (&sb, pool, "list");
> +
> + return svn_cmdline_printf (pool, "%s", sb->data);

This will convert UTF8->console encoding, which we don't want in this
case. See error_checked_fputs in log-cmd.c.

> @@ -132,6 +237,38 @@
> /* Add "." if user passed 0 arguments */
> svn_opt_push_implicit_dot_target (targets, pool);
>
> + if (opt_state->xml)
> + {
> + /* The XML output contains all the information, so "--verbose"
> + does not apply. */
> + if (opt_state->verbose)
> + return svn_error_create (SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
> + _("'verbose' option invalid in XML mode"));
> +
> + /* If output is not incremental, output the XML header and wrap
> + everything in a top-level element. This makes the output in
> + its entirety a well-formed XML document. */
> + if (! opt_state->incremental)
> + {
> + svn_stringbuf_t *sb = svn_stringbuf_create ("", pool);
> +
> + /* <?xml version="1.0" encoding="utf-8"?> */
> + svn_xml_make_header (&sb, pool);

This is why we want "raw" UTF8 output.

> +
> + /* "<lists>" */
> + svn_xml_make_open_tag (&sb, pool, svn_xml_normal, "lists", NULL);
> +
> + SVN_ERR (svn_cmdline_printf (pool, "%s", sb->data));
> + }
> + }
...

> +
> + if (opt_state->xml)
> + {
> + if (! opt_state->incremental)
> + {
> + svn_stringbuf_t *sb = svn_stringbuf_create ("", pool);
> + /* "</lists>" */
> + svn_xml_make_close_tag (&sb, pool, "lists");
> + SVN_ERR (svn_cmdline_printf (pool, "%s", sb->data));
> + }
> }
>
Same about svn_cmdline_printf here.

Regards,
//Peter

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Tue Jan 25 20:13:18 2005

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.