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

[PATCH, svnmerge] Allow mixing options and commands in command line

From: Giovanni Bajo <rasky_at_develer.com>
Date: 2006-01-07 17:47:26 CET

Hello,

as discussed with Blair Zajac on the svnmerge mailing list:

=================================================
I just ran into this:

$ svnmerge -s -v -r 92481 merge
svnmerge: option -r not recognized
Type 'svnmerge help' for usage

I finally figured out that I had to use

$ svnmerge -s -v merge -r 92481

I think one of the large issues that Subversion learned from CVS was that
positional command line options are a pain to use and that svn takes special
care to not care where in the command line a particular command line option
appears.

Can we get this changed?
=================================================

Currently, svnmerge has two groups of options: globals, and per-command.
Global options (like -v/--verbose) are allowed before and after the command
name. Command-specific optoin are allowed only *after* the command name.

This patch modifies this behaviour, so that command-specific options are
allowed even *before* the command name. svnmerge now runs getopt() twice: in
the first round, we allow all the options used by all the commands, so that
getopt can fully parse the command line and extract the command name (eg.
'merge'). After that, we rerun getopt() with only the options allowed by the
specified command, to catch invalid options.

To be picky, this does not allow conflicts in semantic between
command-specific options. For instance, we can't have anymore a "-K" option
for cmd A without arguments, and a "-K nnn" option for cmd B. I don't think
this is a problem. In fact, it could be argued that all the options should
be different among commands to not confuse the user.

Committed as r18013.

[[[
Allow command line options to be specified in any order, even before the
command name. Eg. we now allow "svnmerge -r123 merge" which was forbidden
before.

* contrib/client-side/svnmerge.py:
  (CommandOpts._fancy_getopt): Split out functionalities into...
  (CommandOpts._compute_flags): New.
  (CommandOpts._extract_command): New.
  (CommandOpts.parse): First extract command name, then validate the
options.
  Rename "opts" to "state" for improved readability.
]]]

-- 
Giovanni Bajo


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Received on Sat Jan 7 17:48:09 2006

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