On Sun, 2005-07-31 at 18:52 +0100, Julian Foad wrote:
> > + svn_xml_make_close_tag (&sb, pool, "info");
> > + return svn_cl__error_checked_fputs (sb->data, stdout);
> > +}
> > +
> > +/* Return string representation of KIND */
> > +static const char *
> > +kind_str (svn_node_kind_t kind)
> > +{
> > + switch (kind)
> > + {
> > + case svn_node_dir:
> > + return "directory";
> > + case svn_node_file:
> > + return "file";
> > + default:
> > + return "";
> > + }
> > +}
>
> This is a duplicate of a function in ls-cmd.c. Don't duplicate code, share it.
> Move it into "cl.h" and "util.c", named something like "svn_cl__node_kind_str".
>
Created svn_cl__node_kind_str() in util.c and added prototype in cl.h.
Changes to be made in ls-cmd.c to use this new function will be posted
as another patch.
>
> The existing plain-text "svn info" function, print_info(), should also use this
> function, unless we want an unlocalised version for XML and a localised version
> for plain text ... which I suppose we do. And print_info() currently also
> printfs "none" and "unknown" which is really rather silly, so we'd have to make
> a decision on what it really ought to be doing if it somehow encounters those
> node kinds. OK, forget about print_info() for now.
>
I too feel same with "none" and "unknown". So I changing the code
fragment as below.
SVN_ERR (svn_cmdline_printf (pool, _("Node Kind: %s\n"),
svn_cl__node_kind_str (info->kind)));
> > +/* prints svn info in xml mode to standard out */
> > +static svn_error_t *
> > +print_info_xml (const char *target,
> > + const svn_info_t *info,
> > + apr_pool_t *pool)
> > +{
> > + const char *str_kind;
> > + svn_stringbuf_t *sb = svn_stringbuf_create ("", pool);
> > + const char *rev_str = (SVN_IS_VALID_REVNUM(info->rev)) ?
> > + apr_psprintf (pool, "%ld", info->rev) :
> > + NULL;
> > +
> > + /* If REV_STR is NULL, assume WC is corrupt. */
> > + if (!rev_str)
>
> The only way rev_str can be null is if your conditional assignment above set it
> to null, so just move that assignment after this "if" statement and make it
> unconditional, to save having two different tests for the same thing. I know
> that would mean the variable would not be initialised at its point of
> declaration, but that's the norm in C for non-trivial initialisations.
>
> > + return svn_error_createf (SVN_ERR_WC_CORRUPT, NULL,
> > + _("'%s' has invalid revision"),
> > + svn_path_local_style (target, pool));
> > +
I changed with a single condition check.
> > + make_tagged_cdata (&sb, pool, svn_xml_protect_pcdata,
> > + "copied-from-rev", apr_psprintf (pool,
> > + "%" APR_OFF_T_FMT, info->copyfrom_rev));
>
> info-cmd.c:217: warning: long long int format, different type arg (arg 3)
>
> APR_OFF_T_FMT is not the format of a revision number. "%ld" is.
>
Sorry I don't get this warning. I am taking this macro from apr.h where
APR_OFF_T_FMT is defined for "ld". :(
> > + }
> > +
> > + /* "<date> xx </date>" */
> > + make_tagged_cdata (&sb, pool, svn_xml_protect_pcdata,
> > + "date", svn_time_to_cstring
> > + (info->last_changed_date, pool));
>
> (I wonder if there are any cases in which last-changed info is being printed
> but last_changed_date is absent (zero), which would result in
> "1970-01-01T00:00:00.000000Z" being printed.)
>
All svn xml (blame --xml, status --xml ...) date output is printed in
ISO format. I am adding a check on last_changed_date to resolve this
absent condition.
Regards
-Alexander Thomas (AT)
Patch to add XML output for 'svn info'.
* subversion/clients/cmdline/cl.h
(svn_cl__node_kind_str): New prototype.
* subversion/clients/cmdline/util.c
(svn_cl__node_kind_str): New function, return string kind.
* subversion/clients/cmdline/main.c
(svn_cl__cmd_table[]): Added --xml and --incremental options
for svn info.
* subversion/clients/cmdline/dtd/info.dtd
New dtd for info --xml.
* subversion/clients/cmdline/info-cmd.c
(print_header_xml): New function.
(print_footer_xml): New function.
(schedule_str): New function.
(make_tagged_cdata): New function.
(print_info_xml): New function.
(print_info): Modified to use svn_cl__node_kind_str.
(info_receiver): Edited existing callback to print xml or
traditional output depending on cmdline option.
(svn_cl__info): Modified for XML output.
* tools/client-side/bash_completion
(_svn): Added "--incremental" and "--xml" options to "info"
for auto-completion.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Mon Aug 1 16:31:45 2005