Hi,

In my previous patch, I just tweaked svnrdump to display the "help"
documentation properly.

This patch would solve the problems that I mentioned in my earlier
patch, such as

1. displaying a better header for "svnrdump --vresion"

2. "svnrdump --version" should *not* accept junk values, like "svnrdump
--version --junk".

I have the patch and the log message attached with this mail.
Please review and comment.



Thanks and regards
Prabhu
[[[
Make svnrdump display the help manual correctly.

* subversion/svnrdump/svnrdump.c
  (help_cmd): Now "svnrdump help" would display a better header.
  (main)    : "svnrdump --version" would *not* accept junk inputs anymore.  

Patch by: Prabhu Gnana Sundar <prabh...@collab.net>
Suggested by: Kamesh Jayachandran <kam...@collab.net>
]]]
Index: subversion/svnrdump/svnrdump.c
===================================================================
--- subversion/svnrdump/svnrdump.c	(revision 1049818)
+++ subversion/svnrdump/svnrdump.c	(working copy)
@@ -159,6 +159,7 @@
   svn_ra_session_t *session;
   const char *url;
   svn_boolean_t help;
+  svn_boolean_t version;
   svn_opt_revision_t start_revision;
   svn_opt_revision_t end_revision;
   svn_boolean_t quiet;
@@ -547,6 +548,7 @@
   const char *header =
     _("general usage: svnrdump SUBCOMMAND URL [-r LOWER[:UPPER]]\n"
       "Type 'svnrdump help <subcommand>' for help on a specific subcommand.\n"
+      "Type 'svn --version' to see the program version and RA modules. \n"
       "\n"
       "Available subcommands:\n");
 
@@ -747,8 +749,7 @@
           config_dir = opt_arg;
           break;
         case opt_version:
-          SVNRDUMP_ERR(version(argv[0], pool));
-          exit(EXIT_SUCCESS);
+          opt_baton->version = TRUE;
           break;
         case 'h':
           opt_baton->help = TRUE;
@@ -785,16 +786,29 @@
       subcommand = svn_opt_get_canonical_subcommand2(svnrdump__cmd_table,
                                                      "help");
     }
-  else
+  if (subcommand == NULL)
     {
       if (os->ind >= os->argc)
         {
-          svn_error_clear(
-              svn_cmdline_fprintf(stderr, pool,
-                                  _("Subcommand argument required\n")));
-          SVNRDUMP_ERR(help_cmd(NULL, NULL, pool));
-          svn_pool_destroy(pool);
-          exit(EXIT_FAILURE);
+          if (opt_baton->version)
+            {
+              /* Use the "help" subcommand to handle the "--version" option. */
+              static const svn_opt_subcommand_desc2_t pseudo_cmd =
+                { "--version", help_cmd, {0}, "",
+                  {opt_version,  /* must accept its own option */
+                  } };
+              subcommand = &pseudo_cmd;
+            }
+
+          else
+            { 
+              svn_error_clear(
+                  svn_cmdline_fprintf(stderr, pool,
+                                      _("Subcommand argument required\n")));
+              SVNRDUMP_ERR(help_cmd(NULL, NULL, pool));
+              svn_pool_destroy(pool);
+              exit(EXIT_FAILURE);
+            }
         }
       else
         {
@@ -856,6 +870,12 @@
       svn_pool_destroy(pool);
       exit(EXIT_SUCCESS);
     }
+  if (subcommand && strcmp(subcommand->name, "--version") == 0)
+    {
+      SVNRDUMP_ERR(version(argv[0], pool));
+      svn_pool_destroy(pool);
+      exit(EXIT_SUCCESS);
+    }
 
   /* Only continue if the only not option argument is a url */
   if ((os->ind != os->argc-1)

Reply via email to