I'm trying to use SharpSvn to get the contents of a file at a particular revision. I have the following code:
var svnClient = new SvnClient();
var revisionInfo = new SvnFileVersionsArgs
{
Start = 80088,
End = 80093
};
Collection<SvnFileVersionEventArgs> fileVersions;
svnClient.GetFileVersions(
new SvnUriTarget("https://DbDiff.svn.codeplex.com/svn/DbDiffCommon/DataAccess/SqlCommand11.xml"),
revisionInfo,
out fileVersions);
var stream = fileVersions[0].GetContentStream();
However on the last line I'm getting the following exception:
System.InvalidOperationException was unhandled
Message=This method can only be invoked from the eventhandler handling this eventargs instance
Source=SharpSvn
StackTrace:
at SharpSvn.SvnFileVersionEventArgs.GetContentStream(SvnFileVersionWriteArgs args) in g:\dist\src\sharpsvn\commands\fileversions.cpp:line 545
at SharpSvn.SvnFileVersionEventArgs.GetContentStream() in g:\dist\src\sharpsvn\commands\fileversions.cpp:line 534
at SharpSvnFileVersions.Program.Main(String[] args) in c:\temp\SharpSvnFileVersions\Program.cs:line 29
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
How should I go about getting the contents of the file at each revision?
Looks like I can use SvnClient.Write()
to grab the file contents:
SvnClient svnClient = new SvnClient();
SvnUriTarget target = new SvnUriTarget("https://DbDiff.svn.codeplex.com/svn/DbDiffCommon/DataAccess/SqlCommand11.xml", 80088);
Stream stream = new MemoryStream();
svnClient.Write(target, stream);