zeal
zeal

Reputation: 740

SVN Exporting multi revision of a single file for comparing

I need to track the historical changes of a homepage in SVN.

Each check-in we changed a tracking code on the homepage. I am trying to grab the tracking code along with the date it was checked in.

The homepage has 100+ revisions, so I dont want to do this manually.

The trick I am trying to figure out is if I can export each revision of the file in a way that corresponds to its check in data.

So getting the files exported something like this

/1-1-2011/home.htm

/1-4-2011/home.htm

Or

/1-1-2011_home.htm

/1-4-2011_home.htm

I use tortoiseSVN client.

edit: The code I am looking for is in the actual home.htm not in the log messages. I will be writing a parser to grab the code once I get the file revisions exported.

Upvotes: 0

Views: 323

Answers (1)

DaveShaw
DaveShaw

Reputation: 52788

I don't think this can be done in TSVN. If you use the svn command line you can get a perform run svn log home.htm --xml to get the revisions in XML format. Then create a quick C# app to parse the xml and get the date and revision and date and create a batch file.

Here's something I knocked up in Linqpad:

var doc = XDocument.Load(@"C:\Temp\SOLog.xml");

var bat =
    String.Join(Environment.NewLine,
    doc
    .Root
    .Elements("logentry")
    .Select(xe =>
        new
        {
            Revision = xe.Attribute("revision").Value,
            Date = DateTime.Parse(xe.Element("date").Value).ToString("dd-MM-yyyy"),         })
    .Select(a => String.Format("svn export -r {0} Home.htm C:\\Temp\\{1}", a.Revision, a.Date)));

bat.Dump(); //View Contents

using(System.IO.StreamWriter sw = new System.IO.StreamWriter(@"C:\Temp\SOExport.bat", true))
    sw.WriteLine(bat);

It's probably not perfect, but it should be a start.

Upvotes: 1

Related Questions