3

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!

4 Answers 4

6

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

0

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

Comments

0
svn revert -R $releaseDirectory

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.