Created
December 16, 2014 11:29
-
-
Save hmemcpy/3ff5b99bc7886042fa4a to your computer and use it in GitHub Desktop.
Export-SvnDiff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
I have a remark about the used
Resolve-FullPath
(I was wondering about it). I think it may get a wrong result for paths like\xyz*
. In this caseIsPathRooted
getstrue
and the function just callsGetFullPath
in order to convert\xyz*
. Example (note that the secondGetFullPath
still getsC:\
though in PS the current drive isD:\
):