Skip to content

Instantly share code, notes, and snippets.

@constructor-igor
Created December 16, 2014 12:23
Show Gist options
  • Save constructor-igor/b3bd862bf6e582f0b467 to your computer and use it in GitHub Desktop.
Save constructor-igor/b3bd862bf6e582f0b467 to your computer and use it in GitHub Desktop.
How to get changes files from SVN between two revisions with PowerShell
#
# from http://hmemcpy.com/2014/12/how-to-get-changes-files-from-svn-between-two-revisions-with-powershell/
#
function Export-SvnDiff($repo, $fromRevision, $toRevision, $outputDirectory)
{
$xpath = "/diff/paths/path[@kind='file' and (@item='added' or @item='modified')]"
[xml]$output = & svn diff -r $("{0}:{1}" -f $fromRevision, $toRevision) $repo --summarize --xml
$output | Select-Xml -XPath $xpath | % { $_.node."#text" } | % {
$targetFile = Resolve-FullPath (Join-Path $outputDirectory ($_ -replace $repo))
$targetDir = $targetFile | Split-Path
New-Item -Force -ItemType directory -Path $targetDir | Out-Null
& svn export -r $toRevision -q --force $_ $targetFile
Write-Host ("$_ -> $targetFile")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment