#region ======================== Namespaces using System; using System.IO; using System.Text; using System.Xml; #endregion namespace mxd.ChangelogMaker { class Program { #region ======================== Constants private const string SEPARATOR = "--------------------------------------------------------------------------------"; #endregion #region ======================== Main static int Main(string[] args) { Console.WriteLine("Changelog Maker v01 by MaxED"); if(args.Length != 3) { return Fail("USAGE: ChangelogMaker.exe input output author\n" + "input: xml file generated by 'svn log --xml' command\n" + "output: directory to store Changelog.txt in\n" + "author: commit author", 1); } string input = args[0]; string output = args[1]; string author = args[2]; if(!File.Exists(input)) return Fail("Input file '" + input + "' does not exist.", 2); if(!Directory.Exists(output)) return Fail("Output folder '" + output + "' does not exist.", 3); //Read XML StringBuilder result = new StringBuilder(1000); XmlDocument log = new XmlDocument(); log.Load(input); foreach(XmlNode node in log.ChildNodes) { if(node.ChildNodes.Count == 0) continue; foreach (XmlNode logentry in node.ChildNodes) { string revision = (logentry.Attributes != null ? "R" + logentry.Attributes.GetNamedItem("revision").Value : "unknown"); DateTime date = DateTime.Now; string message = string.Empty; bool skip = false; foreach(XmlNode value in logentry.ChildNodes) { switch(value.Name) { case "author": if(value.InnerText != author) skip = true; break; case "date": date = Convert.ToDateTime(value.InnerText); break; case "msg": message = value.InnerText; break; } } if(!skip) { result.Append(revision) .Append(" | ") .Append(date.ToShortDateString()) .Append(", ") .Append(date.ToShortTimeString()) .Append(Environment.NewLine) .AppendLine(SEPARATOR) .Append(message) .Append(Environment.NewLine) .Append(Environment.NewLine) .Append(Environment.NewLine); } } break; } //Save result string outputpath = Path.Combine(output, "Changelog.txt"); File.WriteAllText(outputpath, result.ToString()); Console.WriteLine("Saved '" + outputpath + "'"); //All done return 0; } #endregion private static int Fail(string message, int exitcode) { Console.WriteLine(message + "\nPress any key to quit"); Console.ReadKey(); return exitcode; } } }