从windows上当前提交visual svn服务器上的visual svn导出更改的文件(powershell脚本)

从windows上当前提交visual svn服务器上的visual svn导出更改的文件(powershell脚本),windows,svn,powershell,visualsvn-server,Windows,Svn,Powershell,Visualsvn Server,需要从windows上当前提交visual svn服务器上的visual svn导出更改的文件 我尝试在提交后使用windows power shell脚本和bat文件来实现这一点 我是poswershell脚本的新手 我得到了导出当前版本的代码。具体如下 # Store hook arguments into variables with mnemonic names $repos = $args[0] $rev = $args[1] # Build path to svn.exe $s

需要从windows上当前提交visual svn服务器上的visual svn导出更改的文件

我尝试在提交后使用windows power shell脚本和bat文件来实现这一点

我是poswershell脚本的新手

我得到了导出当前版本的代码。具体如下

# Store hook arguments into variables with mnemonic names
$repos = $args[0]
$rev   = $args[1]

# Build path to svn.exe
$svn = "$env:VISUALSVN_SERVER\bin\svn.exe"

# Build url to repository
$urepos = $repos -replace "\\", "/"
$urepos
$url = "file:///$urepos/"

# Export repository revision $rev to the C:\test folder
&"$svn" export -r $rev --force "$url" F:\test_live
它将导出提交$rev到F:\test\u live的revison上的文件

但我只需要导出已更改的文件。 他们有什么办法吗

我认为我们可以通过使用SVN diff、SVN log命令来实现thsi

我使用的bat文件是

@echo off

set PWSH=%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe
%PWSH% -command $input ^| %1\hooks\post-commit.ps1 %1 %2  
if errorlevel 1 exit %errorlevel%
已知错误:

带有空格的文件夹/文件名无法正常工作 不包括删除功能。
为什么只想导出已更改的文件?@Dangph感谢somuch检查我的问题,因为文件越来越多,提交过程变得太慢,因为它需要导出所有文件。所以我认为最好只导出更改过的文件。@Dangph我看过Bash脚本,但不知道如何将其转换为powershell脚本:为什么你不能在F:\test\u live上签出,然后在每次提交后在那里进行svn更新?是的,谢谢你,我以前试过这个。但它将成为一个工作副本:。我正在尝试制作这个而不是作为工作副本。
$repos = "C:\Repositories\siterepo"
$rev = $args[1]
$prev_rev = $rev
$prev_rev -= 1

# Build path to svn.exe
$svn = "$env:VISUALSVN_SERVER\bin\svn.exe"

# Build url to repository
$urepos = $repos -replace "\\", "/"
$urepos
$url = "file:///$urepos/"
$url

$diff_var = &"$svn" diff --summarize -r $rev:$prev_rev $url
$dif_var
$check = "System.String".CompareTo($diff_var.GetType().FullName)
if ($check -eq 0)
{
    #"single file"
    $source_file = $diff_var.Substring(8)
    $source_file
    $destination_file = "C:\mywebroot\"+$diff_var.Remove(0,41)
    $destination_file
    #check directory
    $dir_path = Split-Path $destination_file
    $dir_path
    if ((Test-Path $dir_path) -eq 0)
    {
        #"folder_not exist"
        New-Item -Path $dir_path -Force -ItemType Directory
    }
    else
    {
        #"folder exist"
    }
    &"$svn" export --force $source_file $destination_file
}
else
{
    #"multiple files"
    $num_files = $diff_var.Length
    #"loop"
    for ($i=0; $i -lt $num_files; $i++)
    {

        $source_file = $diff_var[$i].Substring(8)
        $source_file
        $destination_file = "C:\mywebroot\"+$diff_var[$i].Remove(0,41)
        $destination_file
        #check directory
        $dir_path = Split-Path $destination_file
        $dir_path
        if ((Test-Path $dir_path) -eq 0)
        {
            #"folder_not exist"
            New-Item -Path $dir_path -Force -ItemType Directory
        }
        else
        {
            #"folder exist"
        }
        &"$svn" export --force $source_file $destination_file

    }
}