How can a get a list of files in an SVN changelist with NO information except the file list?
I want a listing of files in a changelist in a format that I can use in Bash's $(). I start with svn st --cl 3011
, which lists the files but with a lot of extra junk:
Performing status on external item at 'foo'
? foo/bar
Performating status on external item at 'foo/bar'
--- Changelist '3011':
开发者_JAVA技巧M src/math/math.cc
A src/math/determinant.cc
A src/math/determinant.h
M src/math/matrix.h
That's a lot of info to try and get sed or awk to parse through, and I'm worried I'll mess it up and end up missing a file in the changelist or adding stuff that's not in the changelist. -q doesn't help much.
Is there any way get svn to just give me src/math/math.cc src/math/determinant.cc src/math/determinant.h src/math/matrix.h
?
Thanks, Ian
This will do:
svn st --changelist 3011 | grep -v Changelist | cut -b 3-
svn st --changelist
will print the name of the changelist plus the status of the files and the file names:
--- Changelist 'cl_name':
M file1
A file2
Now you edit this by first deleting the first line with a "grep -v Changelist", which deletes the line with the word Changelist. Then do a "cut -b 3-" to delete the first few characters of each line.
With the full command, you get:
file1
file2
Use --ignore-externals and --cl!
You don't need to use any external tools like grep
or awk
. This is actually pretty simple!
The command --ignore-externals
removes all the extra junk from the svn status
call, and you can easily merge that with --cl
parameter too:
svn st --ignore-externals --cl "Changelist Name"
That will ignore all externals, and then give you just the files in the changelist you ask for.
If you don't mind going one directory at a time you can do per directory:
svn status lib | awk '{print $2}'
Where you swap out lib for the dir in question.
As for as I know there is no direct way (only with svn arguments) to do what you want. However, you can rely on output of svn stat -v, and on that path starts from 41 position. For only immidiates the following perl one-liner do the task:
perl -e "@st=`svn stat -v -N`;foreach $l (@st){print substr($l,41);}"
For recursive status just remove -N from svn arguments.
In addition to printing out all contents of the directoty you may want to separate modified files, files not under svn, by revision, etc. In this case you can easily modify my above script using the substr(0,1) - first char of each output. For example, the following one-liner will output list of only modified files:
perl -e "@st=`svn stat -v -N`;foreach $l (@st){print substr($l,41) if substr($l,0,1) eq "M";}"
svn log -r <revision_number> -v
精彩评论