Exporting Only changed files from subversion maintaining directory structure

前端 未结 5 533
轮回少年
轮回少年 2020-12-16 03:26

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

相关标签:
5条回答
  • 2020-12-16 04:08

    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
    
    0 讨论(0)
  • 2020-12-16 04:20

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

    0 讨论(0)
  • 2020-12-16 04:25

    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 )

    0 讨论(0)
  • 2020-12-16 04:28

    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.

    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.

    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 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.

    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.

    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.

    0 讨论(0)
  • 2020-12-16 04:29

    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
    
    0 讨论(0)
提交回复
热议问题