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

Re: [PATCH] Add verbose support to blame

From: Ben Gollmer <ben_at_jatosoft.com>
Date: 2004-02-18 09:04:08 CET

On Tue, 17 Feb 2004 14:20:08 -0600, Ben Reser <ben@reser.org> wrote:
> FYI to everyone. Ben Gollmer sent me an updated patch last night
> offlist. I reviewed it and made some corrections. I figure he'll be
> posting a new patch soon...
>
> So if anyone is thinking about working on this don't. It's done.

Yes, and here is the patch. Thanks to Ben Reser for judicious application
of the cluebat. Since no function signatures have changed, this should be applicable for 1.0.1.

[[[
Add verbose option to blame.

The attack of the Bens!

Patch by: Ben Gollmer
Reviewed and minor fixes from: Ben Reser

* subversion/clients/cmdline/cl.h
  Add svn_cl_blame_baton_t struct

* subversion/clients/cmdline/blame-cmd.c
  (blame_receiver): Also output the date if verbose option is set.
  (svn_cl__blame): Use svn_cl_blame_baton_t struct for the baton, to
    pass the opt_state through to the receiver.

* subversion/clients/cmdline/main.c
  (svn_cl__cmd_table): Add a verbose option to blame.

]]]

Index: subversion/clients/cmdline/cl.h
===================================================================
--- subversion/clients/cmdline/cl.h (revision 8661)
+++ subversion/clients/cmdline/cl.h (working copy)
@@ -139,6 +139,13 @@
 } svn_cl__cmd_baton_t;
 
 
+typedef struct
+{
+ svn_cl__opt_state_t *opt_state;
+ svn_stream_t *out;
+} svn_cl__blame_baton_t;
+
+
 /* Declare all the command procedures */
 svn_opt_subcommand_t
   svn_cl__add,
Index: subversion/clients/cmdline/blame-cmd.c
===================================================================
--- subversion/clients/cmdline/blame-cmd.c (revision 8661)
+++ subversion/clients/cmdline/blame-cmd.c (working copy)
@@ -22,6 +22,7 @@
 #include "svn_error.h"
 #include "svn_pools.h"
 #include "svn_cmdline.h"
+#include "svn_time.h"
 #include "cl.h"
 
 
@@ -35,12 +36,30 @@
                 const char *line,
                 apr_pool_t *pool)
 {
- svn_stream_t *out = baton;
+ svn_cl__opt_state_t *opt_state =
+ ((svn_cl__blame_baton_t *) baton)->opt_state;
+ svn_stream_t *out = ((svn_cl__blame_baton_t *)baton)->out;
+ apr_time_t atime;
+ const char *time_utf8;
+ const char *time_stdout;
   const char *rev_str = SVN_IS_VALID_REVNUM (revision)
                         ? apr_psprintf (pool, "%6" SVN_REVNUM_T_FMT, revision)
                         : " -";
- return svn_stream_printf (out, pool, "%s %10s %s\n", rev_str,
- author ? author : " -", line);
+
+ if (opt_state->verbose)
+ {
+ SVN_ERR (svn_time_from_cstring (&atime, date, pool));
+ time_utf8 = svn_time_to_human_cstring (atime, pool);
+ SVN_ERR (svn_cmdline_cstring_from_utf8 (&time_stdout, time_utf8, pool));
+ return svn_stream_printf (out, pool, "%s %10s %s %s\n", rev_str,
+ author ? author : " -",
+ time_stdout , line);
+ }
+ else
+ {
+ return svn_stream_printf (out, pool, "%s %10s %s\n", rev_str,
+ author ? author : " -", line);
+ }
 }
  
 
@@ -55,6 +74,7 @@
   apr_pool_t *subpool;
   apr_array_header_t *targets;
   svn_stream_t *out;
+ svn_cl__blame_baton_t bl;
   int i;
 
   SVN_ERR (svn_opt_args_to_target_array (&targets, os,
@@ -89,7 +109,9 @@
     }
 
   SVN_ERR (svn_stream_for_stdout (&out, pool));
-
+ bl.opt_state = opt_state;
+ bl.out = out;
+
   subpool = svn_pool_create (pool);
 
   for (i = 0; i < targets->nelts; i++)
@@ -101,7 +123,7 @@
                               &opt_state->start_revision,
                               &opt_state->end_revision,
                               blame_receiver,
- out,
+ &bl,
                               ctx,
                               subpool);
       if (err)
Index: subversion/clients/cmdline/main.c
===================================================================
--- subversion/clients/cmdline/main.c (revision 8661)
+++ subversion/clients/cmdline/main.c (working copy)
@@ -161,7 +161,7 @@
     "Output the content of specified files or\n"
     "URLs with revision and author information in-line.\n"
     "usage: blame TARGET...\n",
- {'r', SVN_CL__AUTH_OPTIONS, svn_cl__config_dir_opt} },
+ {'r', 'v', SVN_CL__AUTH_OPTIONS, svn_cl__config_dir_opt} },
 
   { "cat", svn_cl__cat, {0},
     "Output the content of specified files or URLs.\n"

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed Feb 18 09:04:41 2004

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.