Home > Uncategorized > SVN Tips

SVN Tips

How can I make svn diff show me just the names of the changed files, not their contents?

svn diff doesn’t have an option to do this, but

  • If you only are interested in the diffs between, say, revision 10 and the revision just before it,

svn log -vq -r10

does exactly what you want;

  • otherwise, if you’re using Unix, this works for any range of revisions:

svn log -vq -r123:456 | egrep ‘^ {3}[ADMR] ‘ | cut -c6- | sort | uniq

How can I use wildcards or globbing to move many files at once?

You want to do something like

svn mv svn://server/trunk/stuff/* svn://server/trunk/some-other-dir

but it fails with

svn: Path 'svn://server/trunk/stuff/*' does not exist in revision 123

… or some other inscrutable error message.

Subversion doesn’t expand wildcards like "*" in URL arguments. (Technically speaking, Subversion does not expand wildcards in local paths either, but on most operating systems the shell expands wildcards in local paths in the command line before passing the resulting list to Subversion.)

You have to generate the list of source URLs yourself. You could do it like this (in Bash):

 s=svn://server/trunk/stuff
 items=$(svn ls "$s")
 urls=$(for item in $items; do echo $s/$item; done)
 svn mv $urls svn://server/trunk/some-other-dir -m "Moved all at once"

In any case, you can always accumulate a list of the names of the source files, and then run "svn mv" on each item in that list, like this:

 s=svn://server/trunk/stuff
 svn ls "$s" | \
 while read f
 do svn mv "$s/$f" svn://server/trunk/some-other-dir -m "Moved just one file"
 done

Note, however, that this will generate one commit per source file; that’s in contrast to the above method (using a working copy) which generates just one commit total.

How do I deal with spaces in the editor path? Also, how can I define command line options for the editor?

The Subversion command line client will invoke the editor defined in the environment variable SVN_EDITOR. This environment variable is passed directly to the operating system along with the name of a temporary file used to enter/edit the log message.

Due to the fact that the SVN_EDITOR string is passed as-is to the system’s command shell, spaces in the editor name, or in the path name to the editor, will not work unless the editor name is in quotes.

For example, on Windows if your editor is in C:\Program Files\Posix Tools\bin\vi you would want to set the variable as follows:

 set SVN_EDITOR="C:\Program Files\Posix Tools\bin\vi"

Note that there is no need to escape the quotes in the Windows shell as they are not part of the syntax for the set command.

On UNIX systems you would need to follow your shell’s specific methods for setting the variable. For example, in a bash shell, the following should work:

 SVN_EDITOR='"/usr/local/more editors/bin/xemacs"'
 export SVN_EDITOR

In case a command line option would be needed for the invocation of the editor, just add that after the editor name in the SVN_EDITOR environment variable just like you would us on the command line. For example, if the options -nx -r would be wanted for the above editors, the following will provide those options:

For Windows:

 set SVN_EDITOR="C:\Program Files\Posix Tools\bin\vi" -nx -r

For UNIX/bash:

 SVN_EDITOR='"/usr/local/more editors/bin/xemacs" -nx -r'
 export SVN_EDITOR

Note that SVN_EDITOR is the Subversion specific environment variable setting for the editor selection. Subversion also supports using the more generic EDITOR variable but if you need special behaviors with Subversion it is best to use the SVN_EDITOR variable.

Advertisement
Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.