0

At times we'd like to only pull a small set of files (all from a commit) into our workspace with all the other files being from HEAD. I see how to get this list with the "svn log", but I'm not sure how to best actually get SVN to swap in just these files.

It looks like doing an "svn update" on the revision of the commit rolls the entire repo back to that point in time, which is not what we want. We only want the set of files changed in the commit.

"svn update" looks like it can also take a list of files, so I've read some posts of people recommending writing a script that takes the output of "svn log" and using it in the "svn update" command. That's the solution I was going to try unless there is a better way?? If not, can anyone point me to a completed version of a script that does just that?

medloh
  • 941
  • 12
  • 33

2 Answers2

0

Unfortunately, Subversion cannot directly achieve what you are looking for (not sure what version you are using, but at least 1.7 does not support this directly). So, your best bet would be to use svn log -qv to only get the list of files for your revision. If you are on a (modern) Unix environment something like this does the trick (note that svn log returns the repository path):

svn log -qv -r <your rev> | \
grep -v -e '\--' -e '^r' -e 'Changed paths' | \
awk '{print $2;}' | \
sed -e 's,^<your repo prefix>,,'

You have to supply the bits between <> brackets. The first line gets the log with affected files (and without the commit message). The three subsequent grep lines remove all unnecessary cruft from the svn log output. The awk only gives the file name back (removes the status indication) and the sed line removes the repository prefix from the file names (you have to check the svn log output to see what that value is for your repository).

If you run this from the root of your working directory you should get all files for a commit. This only uses utilities that are usually available on Unix/Linux systems. This script may use some tweaking in case the status indication contains unexpected things or if your commit contains moved or copied files (because some svn versions add the origin to the svn log output and you will need to remove this also).

Edit: Note that you will still need to feed the result from the "script" above (the list of files) to svn up -r <your rev>.

Atafar
  • 697
  • 7
  • 10
  • We're stuck on windows, maybe I can use your script thru cygwin or gitbash, I'll give it a whirl in the next day or two. Thanks for the info! I was hoping there was some way to do it without scripting or doing each file individually, but I guess not. – medloh May 21 '15 at 18:22
  • If you are using Windows, [Gnu on Windows](http://freecode.com/projects/gow) works great. MingW or other will also work of course. – Atafar May 21 '15 at 18:26
0

I see some (possible) native alternatives for grep-BDSM

Hand-work and changelist

If "...a small set of files..." is really small, you can

  • get this log-output into file, remove unwanted noise from file-list in order to get space-separated list of needed files
  • Use this list in svn cl CLNAME... command with --targets options
  • Use created changelist in svn up --cl CLNAME

Mercurial, HGSubversion and templating

Mercurial can (with some tricks) read SVN-repositories, it's log output is a lot more flexible, it's exist as native Windows-application (TortoiseHG as GUI and hg in console), SVN's log can be easy translated into Mercurial's and with templating changed as you want. I.e. - you can to get ready to use svn st FILE1 FILE2 ... FILEN command as result of hg log -T

It will require more work and attention, but Mercurial's branching|merging can also save a lot of time and health in the future, when|if SVN will fail

Community
  • 1
  • 1
Lazy Badger
  • 94,711
  • 9
  • 78
  • 110