Exporting Only changed files from subversion maintaining directory structure

前端 未结 5 544
轮回少年
轮回少年 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: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
    

提交回复
热议问题