Пример #1
0
        private void GetPaths(XmlNode childNode, ChangelogEntry cle)
        {
            foreach (XmlNode node in childNode.ChildNodes)
            {
                if (node.Name == "path")
                {
                    SvnPath path = new SvnPath();
                    path.Name = node.InnerText;

                    foreach (XmlAttribute attr in node.Attributes)
                    {
                        switch (attr.Name)
                        {
                        case "kind":
                            path.Kind = attr.Value;
                            break;

                        case "action":
                            path.Actions.Add(attr.Value);
                            break;

                        case "copyfrom-path":
                            path.FromPath = attr.Value;
                            break;

                        case "copyfrom-rev":
                            path.FromRevision = attr.Value;
                            break;
                        }
                    }

                    if (!cle.Paths.Contains(path))
                    {
                        cle.Paths.Add(path);
                    }
                    else
                    {
                        int index = cle.Paths.IndexOf(path);
                        if (!cle.Paths[index].Actions.Contains(path.Actions[0]))
                        {
                            cle.Paths[index].Actions.AddRange(path.Actions);
                        }
                    }
                }
            }
        }
Пример #2
0
        private void PopulateChangeLogEntry(XmlNode node, ChangelogEntry cle, int revision)
        {
            cle.Revisions.Add(revision);

            foreach (XmlNode childNode in node.ChildNodes)
            {
                string nodeName  = childNode.Name;
                string innerText = childNode.InnerText;

                switch (nodeName)
                {
                case "author":
                    if (!cle.Authors.Contains(innerText))
                    {
                        cle.Authors.Add(innerText);
                    }
                    break;

                case "date":
                    string dateString = ConvertDate(innerText);
                    if (!cle.Dates.Contains(dateString))
                    {
                        cle.Dates.Add(dateString);
                    }
                    break;

                case "msg":
                    List <string> msg = FormatMessage(innerText);
                    if (msg.Count > 0)
                    {
                        cle.Msg.Add(msg);
                    }
                    break;

                case "paths":
                    GetPaths(childNode, cle);
                    break;
                }
            }
        }
Пример #3
0
        private static List <ChangelogEntry> GetChangeLogEntries(string token, string version)
        {
            // Get Range
            string[]              ranges       = token.Split(',');
            string[]              versions     = version.Split(',');
            List <string>         versionsList = new List <string>(versions);
            List <ChangelogEntry> entries      = new List <ChangelogEntry>();
            int addver = 0;

            for (int i = 0; i < ranges.Length; i++)
            {
                string[]       subTokens = ranges[i].Split('-');
                ChangelogEntry cle       = new ChangelogEntry();

                int start;
                int.TryParse(subTokens[0], out start);
                cle.StartRevision = Math.Abs(start);
                if (subTokens.Length > 1)
                {
                    int end;
                    int.TryParse(subTokens[1], out end);
                    cle.EndRevision = end;
                }
                else if (subTokens[0] == "all" || subTokens[0] == "...")
                {
                    cle.StartRevision = -1;
                }

                // Get Version
                if (i < versionsList.Count)
                {
                    string[] ver = versionsList[i].Split('.');

                    for (int j = 0; j < ver.Length; j++)
                    {
                        if (ver[j].Contains("*"))
                        {
                            // incrementing version number
                            if (ver[j].Length > 1)
                            {
                                // get version number to start with
                                ver[j] = ver[j].Replace("*", "");
                                ver[j] = ver[j].Trim();

                                int sv;
                                int.TryParse(ver[j], out sv);
                                sv = sv + addver;
                                addver++;
                                ver[j] = sv.ToString();
                            }
                            else
                            {
                                ver[j] = (0 + addver).ToString();
                                addver++;
                            }

                            versionsList.Add(versionsList[i]);
                        }
                    }

                    cle.Version.AddRange(ver);
                }

                entries.Add(cle);
            }

            return(entries);
        }
Пример #4
0
        public string GenerateChangeLog(XmlDocument log, Dictionary <ArgumentManager.Args, object> arguments)
        {
            XmlNodeList           logEntries = log.GetElementsByTagName("logentry");
            List <ChangelogEntry> clEntries;

            m_Arguments = arguments;

            if (arguments.ContainsKey(ArgumentManager.Args.ranges))
            {
                clEntries = (List <ChangelogEntry>)arguments[ArgumentManager.Args.ranges];
            }
            else
            {
                clEntries = new List <ChangelogEntry>();
            }

            foreach (XmlNode node in logEntries)
            {
                string revisionString = node.Attributes.GetNamedItem("revision").Value;
                int    revision;
                int.TryParse(revisionString, out revision);

                if (arguments.ContainsKey(ArgumentManager.Args.ranges))
                {
                    foreach (ChangelogEntry cle in clEntries)
                    {
                        if ((revision >= cle.StartRevision && revision <= cle.EndRevision) || cle.StartRevision == -1)
                        {
                            PopulateChangeLogEntry(node, cle, revision);
                            break;
                        }
                    }
                }
                else
                {
                    ChangelogEntry cle = new ChangelogEntry();

                    cle.StartRevision = revision;
                    PopulateChangeLogEntry(node, cle, revision);
                    clEntries.Add(cle);
                }
            }

            if (arguments.ContainsKey(ArgumentManager.Args.swap))
            {
                if ((bool)arguments[ArgumentManager.Args.swap])
                {
                    clEntries.Reverse();
                }
            }

            if (arguments.ContainsKey(ArgumentManager.Args.iswap))
            {
                if ((bool)arguments[ArgumentManager.Args.iswap])
                {
                    foreach (ChangelogEntry cle in clEntries)
                    {
                        cle.Msg.Reverse();
                    }
                }
            }

            string changeLog = SetStringTemplate(clEntries);

            return(changeLog);
        }