How can I export changed files in SVN that have changed between two revisions. I need a solution either via command line or by using any scripts (with proper folder structure). In addition, I need windows based solution.
e.g. sth like:
export {svn diff --summarize -r 50:HEAD}
I want a directory tree with a copy of the files that where changed in any revision from 50 on
As far as I know, svn does not provide such a feature. But you may write a simple c# program using SharpSVN to do it. Here is a sample that you can use. In this sample, I am getting the whole changed file from revision 100 to 200.
using SharpSvn;
using System.IO;
using System.Collections.ObjectModel;
using Microsoft.VisualBasic;
namespace SvnDiffExporter
{
class Program
{
static void Main(string[] args)
{
SvnClient client = new SvnClient();
SvnRevisionRange range = new SvnRevisionRange(100, 200);
MemoryStream result = new MemoryStream();
Collection<SvnLogEventArgs> items;
SvnLogArgs logargs = new SvnLogArgs(range);
client.GetLog(@"e:\Artifacts", logargs, out items);
int i = 0;
string [] path = new string[255];
foreach (SvnLogEventArgs ar in items)
{
foreach (SvnChangeItem changeitem in ar.ChangedPaths)
{
if (changeitem.Action != SvnChangeAction.Delete)
{
path[i] = changeitem.Path;
i++;
}
}
}
string localpath = @"c:\data";
foreach (string str in path)
client.Export(str, localpath);
}
}
}
I created a batch file that will work to export the files changed between revisions.
@echo off
FOR /F "tokens=1,2" %%I IN ('svn diff --summarize -r %1') DO (
IF NOT %%I == D (
IF NOT EXIST %2\%%J\.. mkdir %2\%%J\..
svn export --depth empty -q --force %%J %2\%%J
echo %2\%%J
)
)
To use it you just specify the revision or revision range on the command line and a destination for exported files.
C:\YourRepository>svnexport.bat 1:10 C:\Export
Here is a great step by step tutorial which do this with TortoiseSVN's Compare revisions and Export selection to... functions:
http://www.electrictoolbox.com/tortoisesvn-exporting-changed-files/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With