9

When I right click my local working copy and select show log. TortoiseSVN shows me the full path of each file changed for that revision. From the tortoiseSVN interface what I would like to do is the following.

when I right click the revision number and choose export. I would like it to export the files, while keeping them in their directories.

Is this possible?

To put it another way, I want to export only the files I changed in the last commit, into a folder on my harddrive (that is not my working copy ) but I don't want them to be all lumped in the parent directory. I want them to be copied including their relative path.

Doug Chamberlain
  • 11,192
  • 9
  • 51
  • 91

5 Answers5

9

I realize this is a very old question, but answering here will help people searching on google like myself:

svn status | grep '^[ADMR]' | cut -b 8- | xargs -I '{}' cp --parents {} /temporary/destination/dir
Druid
  • 6,423
  • 4
  • 41
  • 56
Joe
  • 91
  • 1
  • 1
3

As this is one of the first results on Google for exporting only changed files with SVN, I've made a batch version for Windows. Not very sophisticated, as I rarely need to do something in batch, but it should do the job. You do need the svn.exe in your path for this to work. Also take care to include the trailing back slashes in the directory variables.

@echo off
set maindir=C:\path\to\project\root\
set exportdir=C:\path\to\project\export\

:: Delete the export dir and create it again to get rid of the old files
rd %exportdir% /S /Q
md %exportdir%

:: Go to the svn directory
cd %maindir%

:: Go through all "svn status" results
FOR /f "tokens=*" %%G IN ('svn status') DO (call :copyfile "%%G")
GOTO :eof

:: Copy the files to the export directory
:copyfile
    :: We can't directly substr the file name, so we need to buffer it
    set line=%1

    :: substr the correct file name (character 9 to one before the end of the string)
    set filepath=%line:~9,-1%

    :: Copy the file (the asterisk means that it won't ask if directory or file)
    xcopy %maindir%%filepath% %exportdir%%filepath%* /H
    GOTO :eof

The Linux command is a bit shorter. Either use the one as seen in Joe's answer, or this even shorter one (found here):

svn status | cut -c9-99999 | cpio -pvdmu /path/to/export
sp00n
  • 1,026
  • 1
  • 8
  • 12
1

BASH

Let's say you have a dev server, with SVN, but on your production server you have no SVN. So you dev, and SVN export, and upload the exported site to production.

Now you make changes, but you don't want to rsync/upload entire export - just the changes.

On Dev server:

( assuming you checked out dev site with svn checkout https://svn.server.com/web/sitename/trunk /path/to/sitename and assuming dev site files are at HEAD )

cd /path/to/sitename/
zip /path/to/diff.zip $(svn diff --summarize -r 123:HEAD https://svn.server.com/web/sitename/trunk | awk '{ print $2 }' |  sed -e 's{https://svn.server.com/web/sitename/trunk/{{')

This will create a ZIP file with the changed file[s] - in an intact directory structure - from revision 123:HEAD.

If for some reason you don't want HEAD, then :

cd /path/to/sitename/
svn up -r:124
zip /path/to/diff.zip $(svn diff --summarize -r 123:124 https://svn.server.com/web/sitename/trunk | awk '{ print $2 }' |  sed -e 's{https://svn.server.com/web/sitename/trunk/{{')
svn up

( this sets the DEV to desired revision, grabs file[s], then ups back to HEAD )

AnOldMan
  • 76
  • 3
  • How this works: `svn diff --summarize -r 123:124 https://svn.server.com/web/sitename/trunk | awk '{ print $2 }' | sed -e 's{https://svn.server.com/web/sitename/trunk/{{'` grabs a list of changes i.e.`somedir/somefile.ext` and passes it to zip. Since path will be relative, you must be in site's dev directory. You can run the svn diff command stand-alone to see what file[s] will be included. – AnOldMan Dec 07 '13 at 15:33
1

I did not write this answer and have added it as the previous high-rated answer was deleted as the link was dead. I have extracted the post from a dead link which was archived at WebCite.

As such, I have set my answer as community wiki.

In Windows Explorer, right-click in the right pane (where the files and folders are) and select TortoiseSVN and then the Repo-Browser option as shown in the first screenshot below.

selecting the repository browser with tortoisesvn

This will open a dialog window where you need to enter the URL to the repository as shown in the second screenshot below. Enter it and then click the OK button.

enter the address for the repository

Once the TortoiseSVN Repository Browser has opened, right click in the files/folders area and select the "Show Log" option. This is highlighted with the red arrow in the screenshot below.

select the show log option

Select the two revisions that you want to export all the changed files between. In the example below I have selected revision 68 and revision 73. This means all the files that have been changed between these two revisions will be exported (i.e. all the files changed in revisions 69, 70, 71, 72 and 73). Now right-click and select the "Compare Revisions" option.

select the revisions and compare

Now a list of all the changed files will be displayed as shown in the final screenshot below. Click in the files list area and select all (Ctrl+A), right click and select the "Export selection to..." option as highlighted in the screenshot with the red arrow.

showing changed files

Once the option is clicked you will be prompted for the location to export the changed files to. Follow through the process and all the files that have been modified between the two versions will be exported to the path specified.

Dan Atkinson
  • 11,391
  • 14
  • 81
  • 114
-3

No, it is not possible. You can either export the entire repository at that revision, or just the changed files with the path flattened.

sylvanaar
  • 8,096
  • 37
  • 59