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

RFC: svn aliases proposal

From: David Mankin <mankin_at_ants.com>
Date: 2002-11-25 18:41:09 CET

Synopsis: I would like to propose an svn alias facility. With this,
people will be able to specify svn command-line client aliases in their
~/.subversion/config file.

Motivation: After having used command-line CVS for several years and
command-line SVN for several months, I have discovered an acute need
for an alias structure. There are three primary use-cases for this:

1) Many of the not-core subversion functionality (and similarly for
CVS) has not been included in the svn command. The typical response on
the mailing list to requests for a little extra functionality has been:
that would be easy for you to write in a little script that calls svn.
I have done this several times for CVS myself. However, this leads to
command-line usage inconsistency. To update, I run "cvs up", however
to commit I run "cvsci" to call my script to prepare the commit.
Remembering which commands are built-in CVS commands and which are
wrapped is annoying for me and nearly impossible for my co-workers who
didn't write the wrapper scripts. Without an alias functionality, the
only solution is to write "cvsup" et. al. to wrap all the non-wrapped
CVS commands.

2) Some people are used to using different short cvs commands than the
ones that have been chosen for Subversion. For example, a user on the
mailing list wanted to add "svn dif" as a shortcut to "svn diff". He
(or she, sorry I don't remember) even sent in a patch to use the
already available internal aliasing facility to add the command
shortcut. His patch was rejected, however, with the claim "we don't
want any more aliases. Deal.". Clearly the poster did want another
alias for diff.

3) I want (hypothetically) my diffs to output in context diff format.
In CVS I could add "diff -c5" to my ~/.cvsrc file. There is no such
facility in Subversion yet.

Simply using shell aliases works (for UNIX shells at least) to solve
these problems for many programs, but not Subversion (or CVS) because
of the monolithic-command-with-subcommands structure. No shell I'm
aware of allows aliasing "svn diff" to "svn diff -c5".

Proposal:
1) add a --no-aliases (or similar) flag to subversion. This way
scripts which wrap subversion won't be surprised by aliased
subcommands. (This was a problem for me recently in CVS. I had "diff
-uNbw" in my .cvsrc file, and then a gui program could no longer
provide me diffs because it didn't understand unified format.) Also it
can be used so that aliases aren't executed recursively.

2) Add a [aliases] section to the config file. Here is what I have in
my config file now, as an example and starting point for discussion.
### Section for configuring subversion commandline client aliases.
### For each command in the [aliases] section, the right-hand side
### will be executed when svn is called with a command argument
### equal to the one on the left.
###
### Some special 'variables' exist for use in the right-hand side:
### $SVN the path to the svn executable that is running
### $SVN! the path to the svn executable that is running,
### and don't do further alias expansion
### $REPOS_URL The URL the current wc was checked out of.
### Errors if the current directory is not a wc one.
### $-* All the option arguments on the command line.
### $* All the non-option arguments on the command line.
### $** ALL the arguments, both option and non-option
### $1 $2 ... The individual non-option arguments
### (The ${SVN}, ${REPOS_URL}, etc. syntax is allowed to
### disambiguate variable names.)
###
### The command and special variables will be expanded and then
### the command will be passed to your shell for execution.
### Therefore, any non-special variables will be handled by your
### shell.
[aliases]
tag = $SVN! cp $-* ${REPOS_URL}/trunk ${REPOS_URL}/tags/$1
branch = $SVN! cp $-* ${REPOS_URL}/trunk ${REPOS_URL}/branches/$1
help tag = echo "Usage: svn tag -m 'message' tag_name";
               echo " or: svn tag -F log_message_file tag_name"
help branch = echo "Usage: svn branch -m 'message' branch_name";
               echo " or: svn branch -F log_message_file branch_name"
commit = svnci --svn_path="$SVN" $**
dif = $SVN diff $**
diff = $SVN! diff -x'-c5' $**
diffu = $SVN! diff -x'-uN' $**

Comments, anyone? (Beyond "CollabNet people don't have time to
implement this pre 1.0" -- if people are interested, I'll see about
trying to code it. I haven't looked at the implementation, but I don't
imagine it will be *too* hard.)

-David Mankin

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Mon Nov 25 18:42:33 2002

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.