質問

I'm trying to write a build script to checkout code using Powershell. I need to be able to replace any modifications which were made to the working copy with the appropriate changes from the SVN repo. That also includes deleting any files which were deleted in the repo but not deleted in the working copy.

Unfortunately I cannot do a clean checkout, since it would be to inefficient to check out all 10GB of code every time the build script is run. How would I do this?

I've been trying something along these lines:

&$SVN_EXE revert $workingPath
&$SVN_EXE update $workingPath
$x = &$SVN_EXE status $localPath --no-ignore |  where {$_ -match "^[\?I]"} | %{$_ -replace "^[\?I]",""} # get the status, get any items with a ? and strip them out
$x | %{$_ -replace "[`n]",", "} # Replace newlines with commas
Remove-Item $x # Remove all the unversioned items

I cannot seem to store the output of line #3 into $x, and I'm not quite sure if the rest of it is the way to do it.

I'm not sure if this is the proper way to go, but if it is, I cannot seem to store and parse the output from SVN status.

Does anyone have any suggestions? Thanks!

役に立ちましたか?

解決

If you want to remove untracked and ignored files from your working directory, try something like this:

svn st --no-ignore | %{ if($_ -match '^[?I]\s+(.+)'){ $matches[1]} } | rm -whatif

Remove the -whatif once you have confirmed that it is doing what you want it to do.

他のヒント

I used the following:

&$SVN_EXE revert $workingPath
&$SVN_EXE update $workingPath
&$SVN_EXE status $localPath --no-ignore |
                Select-String '^[?I]' |
                ForEach-Object {
                    [Regex]::Match($_.Line, '^[^\s]*\s+(.*)$').Groups[1].Value
                } |
                Remove-Item -Recurse -Force -ErrorAction SilentlyContinue

cd $PATH

 svn status --no-ignore | Select-String '^[?I]' | ForEach-Object 
 {[Regex]::Match($_.Line, '^[^\s]*\s+(.*)$').Groups[1].Value} | Remove-Item - 
 Recurse -Force -ErrorAction SilentlyContinue

Please refer Source

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top