3

I have a list of files in my current working copy that have been modified locally. There are about 50 files that have been changed.

I am using the following command to copy files that have been modified in subversion to a folder called /backup. Is there a way to do this but maintain the directories they are in? So it would do something similar to exporting a SVN diff of files. For example if I changed a file called /usr/lib/SPL/RFC.php then it would copy the usr/lib/SPL directory to backup also.

cp `svn st | ack '^M' | cut -b 8-` backup
crmpicco
  • 16,605
  • 26
  • 134
  • 210

2 Answers2

7

It looks strange, but it is really easy to copy files with tar. E.g.

tar -cf - $( svn st | ack '^M' | cut -b 8- ) |
tar -C /backup -xf -
nosid
  • 48,932
  • 13
  • 112
  • 139
  • That's _exactly_ what I was looking for, many thanks. I guess for files I have added I will just have to re-run by changing the argument passed to ack to `'^A'` – crmpicco May 28 '12 at 13:29
  • 1
    To check for modified _and_ added files I am now doing this: `tar -cf - $( svn st | ack '^M|^A' | cut -b 8- ) | tar -C /backup -xf -` – crmpicco May 31 '12 at 16:13
  • 2
    And to do this on Windows from cygwin, swapping backslashes for forward-slashes: `tar -cf - $( svn st | grep "^[MA]" | cut -b 8- | sed -e "s/\\\/\\//g" ) | tar -C ./backup -xf -` – Matt Winckler Dec 14 '12 at 22:28
1

Why not create a patch of your changes? That way you have one file containing all of your changes which you can timestamp in the name - something like 2012-05-28-17-30-00-UnitTestChanges.patch, one per day.

Then you can roll up your changes to a fresh checkout once you're ready, and then commit them.

FYI: Subversion 1.8 should have checkpointing / shelving (which is what you seem to want to do), but that's a long way off, and might only be added in Subversion 1.9.

Sameer Singh
  • 1,358
  • 1
  • 19
  • 47