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

Re: Patch to add a --verbose option.

From: Mo DeJong <supermo_at_bayarea.net>
Date: 2001-09-14 21:38:00 CEST

On 14 Sep 2001 13:07:35 -0500
cmpilato@collab.net wrote:

> Hey, Mo, you recently submitted a couple of patches to the list here:
>
> (1) Patch to add a --verbose option.
> (2) New files need to appear in diff output by default
>
> Could you possibly re-submit those as plaintext diffs (with log
> messages per the policies in HACKING) instead of binary archives?
> Pretty-please?
>
> Thanks.

My most sincere apologies. I switched to a new GUI email
client and it seems to be doing some base 64 encoding
of a plain text attachment behind my back. I may
have to hack this email client to get it working
properly with the text/plain mime type.

Here are the patches just pasted in, does that work for you?

2001-09-12 Mo DeJong <supermo@bayarea.net>

        * subversion/clients/cmdline/README:
        * subversion/clients/cmdline/checkout-cmd.c:
        * subversion/clients/cmdline/cl.h:
        * subversion/clients/cmdline/commit-cmd.c:
        * subversion/clients/cmdline/import-cmd.c:
        * subversion/clients/cmdline/main.c:
        * subversion/clients/cmdline/propdel-cmd.c:
        * subversion/clients/cmdline/propset-cmd.c:
        Implement --verbose option to complement the existing
        --quiet option. Replace "quiet" member of the
        svn_cl__opt_state_t struct with a more generic
        "verbosity" member, it is set via the --verbose
        or --quiet options.

Index: subversion/clients/cmdline/cl.h
===================================================================
--- subversion/clients/cmdline/SVN/text-base/cl.h Wed Sep 12 23:02:28 2001
+++ subversion/clients/cmdline/cl.h Thu Sep 13 00:27:22 2001
@@ -48,6 +48,15 @@
   svn_cl__auth_password_opt,
 } svn_cl__longopt_t;
 
+/* Client verbosity */
+typedef enum {
+ svn_cl__verbosity_quiet_opt,
+ svn_cl__verbosity_progress_opt,
+ svn_cl__verbosity_verbose_opt,
+ svn_cl__verbosity_trace_opt,
+} svn_cl__verbosity_t;
+
+
 
 /*** Command dispatch. ***/
 
@@ -67,8 +76,8 @@
      set either of these flags, but will be recursive anyway */
   svn_boolean_t recursive;
   svn_boolean_t nonrecursive;
- svn_boolean_t quiet;
   svn_boolean_t version;
+ svn_cl__verbosity_t verbosity;
   svn_boolean_t modified;
   apr_array_header_t *args;
   /* TODO fixme. This still doesn't handle binary data from a file! */
Index: subversion/clients/cmdline/propdel-cmd.c
===================================================================
--- subversion/clients/cmdline/SVN/text-base/propdel-cmd.c Mon Sep 10 09:51:09 2001
+++ subversion/clients/cmdline/propdel-cmd.c Wed Sep 12 23:53:47 2001
@@ -58,7 +58,7 @@
     {
       svn_stringbuf_t *target = ((svn_stringbuf_t **) (targets->elts))[i];
       SVN_ERR (svn_wc_prop_set (pname, NULL, target, pool));
- if (! opt_state->quiet)
+ if (opt_state->verbosity != svn_cl__verbosity_quiet_opt)
         printf ("property `%s' deleted from %s.\n", pname->data, target->data);
     }
 
Index: subversion/clients/cmdline/checkout-cmd.c
===================================================================
--- subversion/clients/cmdline/SVN/text-base/checkout-cmd.c Mon Sep 10 09:51:09 2001
+++ subversion/clients/cmdline/checkout-cmd.c Wed Sep 12 23:56:01 2001
@@ -117,8 +117,12 @@
         return err;
       
       err = svn_client_checkout (NULL, NULL,
- opt_state->quiet ? NULL : trace_editor,
- opt_state->quiet ? NULL : trace_edit_baton,
+ (opt_state->verbosity ==
+ svn_cl__verbosity_quiet_opt)
+ ? NULL : trace_editor,
+ (opt_state->verbosity ==
+ svn_cl__verbosity_quiet_opt)
+ ? NULL : trace_edit_baton,
                                  auth_obj,
                                  repos_url,
                                  local_dir,
Index: subversion/clients/cmdline/import-cmd.c
===================================================================
--- subversion/clients/cmdline/SVN/text-base/import-cmd.c Mon Sep 10 09:51:08 2001
+++ subversion/clients/cmdline/import-cmd.c Thu Sep 13 00:00:50 2001
@@ -130,8 +130,12 @@
                                             pool));
 
   SVN_ERR (svn_client_import (NULL, NULL,
- opt_state->quiet ? NULL : trace_editor,
- opt_state->quiet ? NULL : trace_edit_baton,
+ (opt_state->verbosity ==
+ svn_cl__verbosity_quiet_opt)
+ ? NULL : trace_editor,
+ (opt_state->verbosity ==
+ svn_cl__verbosity_quiet_opt)
+ ? NULL : trace_edit_baton,
                               auth_obj,
                               path,
                               url,
Index: subversion/clients/cmdline/README
===================================================================
--- subversion/clients/cmdline/SVN/text-base/README Mon Sep 10 09:51:14 2001
+++ subversion/clients/cmdline/README Thu Sep 13 01:24:49 2001
@@ -98,11 +98,6 @@
   client.
 
   -? -h -H --help Help.
-
- -V --verbose [ KEY ] [quiet|progress|verbose|trace]
- Determines the level of spewage that the
- client gives (progress is the default,
- --verbose without arg defaults to verbose)
 
   -D --date DATESPEC Like "cvs cmd -D DATESPEC"
 
@@ -140,11 +135,16 @@
 
   -L --line-conversion GLOB Do line-end conversion for files matching GLOB.
 
+ -q --quiet Spew as little information as possible
+ while processing a subcommand.
+
+ -V --verbose Spew a more verbose description
+ while processing a subcommand.
+
      -- End of option processing
 
 * Aliases (shorthand for commonly used options and option combinations)
 
- -q --quiet alias for --verbose=quiet
   -T --text-defaults GLOB alias for '-L GLOB -K GLOB'
 
 
Index: subversion/clients/cmdline/main.c
===================================================================
--- subversion/clients/cmdline/SVN/text-base/main.c Wed Sep 12 23:02:57 2001
+++ subversion/clients/cmdline/main.c Thu Sep 13 01:23:02 2001
@@ -181,6 +181,7 @@
     {"help", 'h', 0},
     {"message", 'm', 1},
     {"quiet", 'q', 0},
+ {"verbose", 'V', 0},
     {"recursive", svn_cl__recursive_opt, 0},
     {"nonrecursive", 'n', 0},
     {"revision", 'r', 1},
@@ -216,6 +217,7 @@
   svn_cl__init_feedback_vtable (pool);
   memset (&opt_state, 0, sizeof (opt_state));
   opt_state.revision = SVN_INVALID_REVNUM;
+ opt_state.verbosity = svn_cl__verbosity_progress_opt;
 
   /* No args? Show usage. */
   if (argc <= 1)
@@ -259,12 +261,16 @@
         break;
       case 'v':
         opt_state.version = TRUE;
+ /* fall through and print version info in help subcommand */
       case 'h':
       case '?':
         opt_state.help = TRUE;
         break;
       case 'q':
- opt_state.quiet = TRUE;
+ opt_state.verbosity = svn_cl__verbosity_quiet_opt;
+ break;
+ case 'V':
+ opt_state.verbosity = svn_cl__verbosity_verbose_opt;
         break;
       case svn_cl__xml_file_opt:
         opt_state.xml_file = svn_stringbuf_create (opt_arg, pool);
Index: subversion/clients/cmdline/commit-cmd.c
===================================================================
--- subversion/clients/cmdline/SVN/text-base/commit-cmd.c Mon Sep 10 09:51:11 2001
+++ subversion/clients/cmdline/commit-cmd.c Wed Sep 12 23:59:22 2001
@@ -105,8 +105,12 @@
 
   /* Commit. */
   SVN_ERR (svn_client_commit (NULL, NULL,
- opt_state->quiet ? NULL : trace_editor,
- opt_state->quiet ? NULL : trace_edit_baton,
+ (opt_state->verbosity ==
+ svn_cl__verbosity_quiet_opt)
+ ? NULL : trace_editor,
+ (opt_state->verbosity ==
+ svn_cl__verbosity_quiet_opt)
+ ? NULL : trace_edit_baton,
                               auth_obj,
                               targets,
                               message,
Index: subversion/clients/cmdline/propset-cmd.c
===================================================================
--- subversion/clients/cmdline/SVN/text-base/propset-cmd.c Mon Sep 10 09:51:10 2001
+++ subversion/clients/cmdline/propset-cmd.c Wed Sep 12 23:54:19 2001
@@ -68,7 +68,7 @@
       svn_stringbuf_t *target = ((svn_stringbuf_t **) (targets->elts))[i];
       SVN_ERR (svn_wc_prop_set (propname, propval, target, pool));
 
- if (! opt_state->quiet)
+ if (opt_state->verbosity != svn_cl__verbosity_quiet_opt)
         printf ("property `%s' set on %s.\n", propname->data, target->data);
     }
 

(Note: There is a missing call to apr_file_close in
 case the first open worked. I figured I would just
 send that fix later)

2001-09-12 Mo DeJong <supermo@bayarea.net>

        * subversion/clients/cmdline/diff.c:
        Include a newly added file in the diff output
        by creating an empty file in the SVN dir before
        exec'ing diff.

Index: ./subversion/clients/cmdline/diff.c
===================================================================
--- ./subversion/clients/cmdline/SVN/text-base/diff.c Mon Sep 10 09:51:09 2001
+++ ./subversion/clients/cmdline/diff.c Thu Sep 13 02:53:00 2001
@@ -108,6 +108,7 @@
   svn_stringbuf_t *pristine_copy_path;
   svn_boolean_t text_is_modified = FALSE;
   const char **args;
+ svn_boolean_t pristine_existed;
   int i = 0;
 
   apr_file_t *outhandle = NULL;
@@ -126,6 +127,26 @@
   /* Get a PRISTINE_COPY_PATH to compare against. */
   SVN_ERR (svn_client_file_diff (path, &pristine_copy_path, pool));
 
+ /* If the PRISTINE_COPY_PATH file does not exist the diff will fail.
+ Create an empty file so the generated patch will add the new file */
+
+ status = apr_file_open (&outhandle, pristine_copy_path->data, APR_READ,
+ APR_OS_DEFAULT, pool);
+ if (!status)
+ pristine_existed = TRUE;
+ else
+ {
+ pristine_existed = FALSE;
+ status = apr_file_open (&outhandle, pristine_copy_path->data,
+ APR_READ | APR_CREATE,
+ APR_OS_DEFAULT, pool);
+ if (status)
+ return svn_error_create (status, 0, NULL, pool,
+ "error: can't touch pristine copy");
+ else
+ apr_file_close (outhandle);
+ }
+
   /* Get an apr_file_t representing stdout, which is where we'll have
      the diff program print to. */
   status = apr_file_open_stdout (&outhandle, pool);
@@ -171,6 +192,14 @@
      makes use of the two paths, instead of just blindly running
      SVN_CLIENT_DIFF.
   */
+
+ if (!pristine_existed)
+ {
+ apr_file_remove (pristine_copy_path->data, pool);
+ if (status)
+ return svn_error_create (status, 0, NULL, pool,
+ "error: can't delete tmp pristine copy");
+ }
 
   return SVN_NO_ERROR;
 }

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Oct 21 14:36:41 2006

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.