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

Re: [PATCH] issue #2069 - "svn status" in xml mode - v3

From: Peter N. Lundblad <peter_at_famlundblad.se>
Date: 2005-05-11 22:46:41 CEST

On Mon, 9 May 2005 alexander@collab.net wrote:

Here we go:

> Index: subversion/include/svn_wc.h
> ===================================================================
> --- subversion/include/svn_wc.h (revision 13821)
> +++ subversion/include/svn_wc.h (working copy)
> @@ -543,7 +543,9 @@
> svn_wc_notify_failed_lock,
>
> /** @since New in 1.2. Failed to unlock a path. */
> - svn_wc_notify_failed_unlock
> + svn_wc_notify_failed_unlock,
> +
> + svn_wc_notify_status_xml_completed

You don't need this. (See below)

> } svn_wc_notify_action_t;
>
>
> Index: subversion/include/svn_client.h
> ===================================================================
> --- subversion/include/svn_client.h (revision 13821)
> +++ subversion/include/svn_client.h (working copy)
> @@ -329,6 +329,7 @@
> void *baton,
> apr_pool_t *pool);
>
> +
> /** Callback type used by svn_client_blame() to notify the caller
> * that line @a line_no of the blamed file was last changed in
> * @a revision by @a author on @a date, and that the contents were
> @@ -825,6 +826,20 @@
> apr_pool_t *pool);
>
>

> +svn_error_t *
> +svn_client_status3 (svn_revnum_t *result_rev,
> + const char *path,
> + svn_opt_revision_t *revision,
> + svn_wc_status_func2_t status_func,
> + void *status_baton,
> + svn_boolean_t recurse,
> + svn_boolean_t get_all,
> + svn_boolean_t update,
> + svn_boolean_t no_ignore,
> + svn_boolean_t ignore_externals,
> + svn_boolean_t xml,
> + svn_client_ctx_t *ctx,
> + apr_pool_t *pool);

This lacks documentation. But, you don't need this either. The
libsvn_client shouldn't know about the output format. Instead of using
the notification system to get the revision, make use of the
result_rev argument.

> /**
> * @deprecated Provided for backward compatibility with the 1.1 API.
> *
> Index: subversion/libsvn_client/delete.c
> ===================================================================
> --- subversion/libsvn_client/delete.c (revision 13821)
> +++ subversion/libsvn_client/delete.c (working copy)
> @@ -89,8 +89,8 @@
> revision.kind = svn_opt_revision_unspecified;
> sb.err = SVN_NO_ERROR;
> sb.pool = pool;
> - SVN_ERR (svn_client_status2 (NULL, path, &revision, find_undeletables, &sb,
> - TRUE, FALSE, FALSE, FALSE, FALSE, ctx, pool));
> + SVN_ERR (svn_client_status3 (NULL, path, &revision, find_undeletables, &sb,
> + TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, ctx, pool));

So, this goes away, like in other places.

> return sb.err;
> }
>
> Index: subversion/clients/cmdline/cl.h
> ===================================================================
> --- subversion/clients/cmdline/cl.h (revision 13821)
> +++ subversion/clients/cmdline/cl.h (working copy)
> @@ -249,6 +249,7 @@
> as broken WC locks. */
> svn_error_t *svn_cl__print_status (const char *path,
> svn_wc_status2_t *status,
> + svn_boolean_t xml_mode,
> svn_boolean_t detailed,
> svn_boolean_t show_last_committed,
> svn_boolean_t skip_unrecognized,

Or maybe a new function to not mix things up.

> Index: subversion/clients/cmdline/status.c
> ===================================================================
> --- subversion/clients/cmdline/status.c (revision 13821)
> +++ subversion/clients/cmdline/status.c (working copy)
> @@ -24,6 +24,7 @@
> #include "svn_cmdline.h"
> #include "svn_wc.h"
> #include "svn_path.h"
> +#include "svn_xml.h"
> #include "cl.h"
>
>
> @@ -51,10 +52,135 @@
> }
> }
>
> +
> +
> +/* Print status in XML format to standard console */

Standard out:-)

> +static svn_error_t *
> +print_statents_xml (apr_pool_t *pool,
> + char item_stat,
> + char prop_stat,
> + char locked,
> + char copied,
> + char switched,
> + char reposlock,
> + char ood_stat,
> + const char *working_rev,
> + const char *commit_rev,
> + const char *commit_author,
> + const char *path)
> +{

Below, I'm suggesting a new DTD, so I don't go into detail about the
output machinary here.

...
> Index: subversion/clients/cmdline/notify.c
> ===================================================================
> --- subversion/clients/cmdline/notify.c (revision 13821)
> +++ subversion/clients/cmdline/notify.c (working copy)
> @@ -29,6 +29,7 @@
> #include "svn_cmdline.h"
> #include "svn_pools.h"
> #include "svn_path.h"
> +#include "svn_xml.h"
> #include "cl.h"
>
> #include "svn_private_config.h"
> @@ -363,7 +364,23 @@
> case svn_wc_notify_failed_unlock:
> svn_handle_error (n->err, stderr, FALSE);
> break;
> + case svn_wc_notify_status_xml_completed:
> + if (SVN_IS_VALID_REVNUM (n->revision))
> + {
> + const char *staton_rev;
> + svn_stringbuf_t *sb = svn_stringbuf_create ("", pool);
> + staton_rev = apr_psprintf (pool, "%ld", n->revision);
> + /* "<status-against ...>" */
> + svn_xml_make_open_tag (&sb, pool, svn_xml_normal,
> + "status-against", "rev", staton_rev, NULL);
>
> + /* "</status-against>" */
> + svn_xml_make_close_tag (&sb, pool, "status-against");
> +
> + svn_cl__error_checked_fputs (sb->data, stdout);
> + }
> + break;
> +
> default:
> break;
> }
This moves.

> Index: subversion/clients/cmdline/main.c
> ===================================================================
> --- subversion/clients/cmdline/main.c (revision 13821)
> +++ subversion/clients/cmdline/main.c (working copy)
> @@ -672,7 +672,8 @@
> " 965 687 joe wc/zig.c\n"
> " Head revision: 981\n"),
> { 'u', 'v', 'N', 'q', svn_cl__no_ignore_opt, SVN_CL__AUTH_OPTIONS,
> - svn_cl__config_dir_opt, svn_cl__ignore_externals_opt} },
> + svn_cl__config_dir_opt, svn_cl__ignore_externals_opt, svn_cl__xml_opt,
> + svn_cl__incremental_opt} },
>
Most commands have the config and authn options last. Check where I
> put the new options in the blame commit.

> { "switch", svn_cl__switch, {"sw"},
> N_("Update the working copy to a different URL.\n"
> @@ -1174,6 +1175,11 @@
> }
> }
>
> + /* If we're running the `status' subcommand with xml option, then
> + verbose or detailed mode is activated */
> + if ((opt_state.xml) && subcommand->cmd_func == svn_cl__status)
> + opt_state.verbose = TRUE;
> +
Why do you need to set this here?

> @@ -119,17 +167,26 @@
> sb.show_last_committed = opt_state->verbose;
> sb.skip_unrecognized = opt_state->quiet;
> sb.repos_locks = opt_state->update;
> + sb.xml_mode = opt_state->xml;
> sb.pool = subpool;
> - SVN_ERR (svn_client_status2 (NULL, target, &rev, print_status, &sb,
> +
> + SVN_ERR (svn_client_status3 (NULL, target, &rev, print_status, &sb,

Here, you can get the HEAD revision of the repository through the
first argument.

...

> Index: subversion/clients/cmdline/dtd/status.dtd
> ===================================================================
> --- subversion/clients/cmdline/dtd/status.dtd (revision 0)
> +++ subversion/clients/cmdline/dtd/status.dtd (revision 0)
> @@ -0,0 +1,19 @@
> +<!-- XML DTD for Subversion command-line client output. -->
> +
> +<!-- For "svn status" -->
> +<!ELEMENT status (entry*, status-against?)>

With multiple targets, you'll get multiple status-against elements.

> + <!ELEMENT entry (item-status, prop-status, locked, scheduled, switched, repos-lock, out-of-date?, revision?, rev-last-commit?, author-last-commit?)>
> + <!ATTLIST entry file CDATA #REQUIRED> <!-- file: character -->
> + <!ELEMENT item-status (#PCDATA)> <!-- one character status of file or dir -->
> + <!ELEMENT prop-status (#PCDATA)> <!-- one character status of file or dir property -->
> + <!ELEMENT locked (#PCDATA)> <!-- one character item locked -->
> + <!ELEMENT scheduled (#PCDATA)> <!-- one character scheduled for commit -->
> + <!ELEMENT switched (#PCDATA)> <!-- one character switched from the original path -->
> + <!ELEMENT repos-lock (#PCDATA)> <!-- one character repository lock tocken -->
> + <!ELEMENT out-of-date (#PCDATA)> <!-- one character out-of-date -->
> + <!ELEMENT revision (#PCDATA)> <!-- working revision -->
> + <!ELEMENT rev-last-commit (#PCDATA)> <!-- last committed revision -->
> + <!ELEMENT author-last-commit (#PCDATA)> <!-- last committed author -->
> +
> + <!ELEMENT status-against EMPTY>
> + <!ATTLIST status-against rev CDATA #IMPLIED> <!-- status runned against revision -->

I think this doesn't give all information that it could. NOte that the
XML doesn't need to be as terse as the traditional output. For
example, the complete lock information is avaliable.
I'm sketching another structure below. Feel free to critisize it.

<!ENTITY % BOOL "(true | false) false">

<!ELEMENT status (target*)>

<!ELEMENT target (entry*, against?>>
<!ATTLIST target
  path CDATA #REQRURED> <!-- target path -->

<!ELEMENT entry (wc-status, repos-status?, wc-lock?, repos-lock?)>

<!ELEMENT wc-status (lock?)>
<!ATTLIST wc-status
  item (added | conflicted | deleted | merged | ignored | modified |
  replaced | external | unversioned | incomplete | obstructed)
  #IMPLIED <!-- Item status: no value means unmodified. -->
  props (conflicted | modified) #IMPLIED <!-- Prop status: no value
    means unmodified. -->
  wc-locked %BOOL; <!-- WC dir locked? -->
  copied %BOOL; <!-- Add with history? -->
  switched %BOOL; <!-- Item switched -->
>

<!ELEMENT repos-status (lock?)>
<!ATTLIST repos-status
  item (added | deleted | modified | replaced) #IMPLIED
    <!-- NO value means no modifications. -->
  props (modified) #IMPLIED
    <!-- No value means ... -->

<!-- Lock info stored in WC or repos. -->
<!ELEMENT lock (token, owner, comment?, created, expires?)>

<!ELEMENT token (#PCDATA)> <!-- Lock token URI. -->
<!ELEMENT owner (#PCDATA)> <!-- Lock owner. -->
<!ELEMENT comment (#PCDATA)> <!-- Lock Comment. -->
<!ELEMENT created (#PCDATE)> <!-- Creation date in ISO format. -->
<!ELEMENT expires (#PCDATA)> <!-- Expiration date in ISO format. -->

<!ELEMENT against EMPTY>
<!ATTLIST against revision CDATA #REQUIRED>

This is not tested or anything, so it might contain errors, but yoiu
get the idea. Do you like it?

> Index: subversion/tests/clients/cmdline/stat_tests.py

Let's get the rest sorted out first:-)

Regards,
//Peter

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Thu May 12 00:23:16 2005

This is an archived mail posted to the Subversion Dev mailing list.