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

Re: "svn cl" input from "svn st"

From: Stefan Sperling <stsp_at_elego.de>
Date: Thu, 26 Apr 2012 10:39:23 +0200

On Thu, Apr 26, 2012 at 09:09:49AM +0100, Gary wrote:
> > From: Stefan Sperling
> >
> > On Thu, Apr 26, 2012 at 09:02:17AM +0100, Gary wrote:
> > > I'm just wondernig if it's possible to pipe or otherwise use the output from "svn st" into the "svn cl XYZ" command (for the file paths / names, obviously). I can't even see any
> > > option to "svn st" that gives *only* file names/paths :( The -q option seems to give the same output as "svn st" without it.
> > >
> >
> > Which operating system are you using?
> Let's assume it's something *n*x like :)

Great, that makes it easier for me to answer :)

So you definitely have 'sed' available and could do something like:

$ svn status
M alpha
M epsilon/zeta
$ svn status | grep '^[A-Z]' | sed 's/^. \(.*\)$/\1/'

(I bet there are people on this list who can suggest a better regex to use).

The 'grep' bit ensures that no unrelated lines printed by svn status
are considered (e.g. the lines saying "--- Changelist 'foo'" if you already
have changelists defined). The 'sed' part trims the status letter and
leading whitespace from the line, leaving the filename.

You can write this output to a file and then use svn changelist with
the --targets option:

$ tempfile="`mktemp`"
$ svn status | grep '^[A-Z]' | sed 's/^. \(.*\)$/\1/' >> "$tempfile"
$ svn changelist --targets "$tempfile" new-changelist
A [new-changelist] alpha
A [new-changelist] epsilon/zeta
$ rm "$tempfile"

You can put these commands into a shell script to automate the task.

Of course, it would be nicer if 'svn' had its own way of adding a
select subset of files in the working copy to a changelist based on
some criteria. But no such feature currently exists as far as I know.
Received on 2012-04-26 10:40:02 CEST

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