コード例 #1
0
 public static               SvnLogInfo[] GetLogs(string path, string revision)
 {
     if (revision == null)
     {
         var logCommand = new SvnCommand("log")
         {
             (SvnPath)path,
             SvnCommandItem.FromRevision($"head:1"),
             SvnCommandItem.Xml,
             SvnCommandItem.Verbose,
             SvnCommandItem.FromMaxCount(MaxLogCount),
             SvnCommandItem.WithAllRevprops
         };
         return(SvnLogInfo.Read(logCommand.Run()));
     }
     else
     {
         var logCommand = new SvnCommand("log")
         {
             (SvnPath)path,
             SvnCommandItem.FromRevision($"{revision}:1"),
             SvnCommandItem.Xml,
             SvnCommandItem.Verbose,
             SvnCommandItem.FromMaxCount(MaxLogCount),
             SvnCommandItem.WithAllRevprops
         };
         return(SvnLogInfo.Read(logCommand.Run()));
     }
 }
コード例 #2
0
        public LogInfo[] GetLog(string basePath, string repositoryName, string revision)
        {
            var uri  = this.GetUrl(basePath, repositoryName);
            var logs = SvnLogInfo.GetLogs(uri.ToString(), revision);

            return(logs.Select(item => (LogInfo)item).ToArray());
        }
コード例 #3
0
        public static               SvnLogInfo[] RunForGetBranch(Uri uri)
        {
            var logCommand = new SvnCommand("log")
            {
                (SvnPath)uri,
                SvnCommandItem.Xml,
                SvnCommandItem.Verbose,
                new SvnCommandItem("stop-on-copy")
            };

            return(SvnLogInfo.Read(logCommand.Run()));
        }
コード例 #4
0
        public static SvnLogInfo GetFirstLog(string path)
        {
            var info      = SvnInfo.Run(path);
            var revision  = info.LastChangedRevision;
            var localPath = PathUtility.Separator + UriUtility.MakeRelativeOfDirectory(info.RepositoryRoot, info.Uri);

            while (revision != "1")
            {
                var logs = SvnLogInfo.Run(info.Uri.ToString(), "1", revision, 100);
                foreach (var item in logs)
                {
                    var renamed = false;
                    foreach (var changedPath in item.ChangedPaths)
                    {
                        if (changedPath.Action == "A" && changedPath.Path == localPath)
                        {
                            localPath = changedPath.CopyFromPath;
                            renamed   = true;
                            break;
                        }
                    }

                    var deleted = false;
                    if (renamed == true)
                    {
                        foreach (var changedPath in item.ChangedPaths)
                        {
                            if (changedPath.Action == "D" && changedPath.Path == localPath)
                            {
                                deleted = true;
                                break;
                            }
                        }

                        if (deleted == false)
                        {
                            return(item);
                        }
                    }
                }
                if (logs.Count() == 1)
                {
                    return(logs.First());
                }
                else
                {
                    revision = logs.Last().Revision;
                }
            }

            return(SvnLogInfo.GetLogs(info.Uri.ToString(), "1").First());
        }
コード例 #5
0
        private static SvnLogInfo Parse(XElement element)
        {
            LogPropertyInfo[] props = null;
            var commentValue        = element.XPathSelectElement("msg").Value;
            var comment             = null as string;

            var obj = new SvnLogInfo()
            {
                Author   = element.XPathSelectElement("author").Value,
                Revision = element.Attribute("revision").Value,
                Comment  = comment ?? commentValue,
                DateTime = XmlConvert.ToDateTime(element.XPathSelectElement("date").Value, XmlDateTimeSerializationMode.Utc)
            };
            var pathItems       = element.XPathSelectElements("paths/path").ToArray();
            var changedItemList = new List <SvnChangeInfo>();

            foreach (var item in pathItems)
            {
                var changedItem = SvnChangeInfo.Parse(item);
                changedItemList.Add(changedItem);
            }
            obj.ChangedPaths = changedItemList.ToArray();

            if (props == null)
            {
                var propItems    = element.XPathSelectElements("revprops/property").ToArray();
                var propItemList = new List <SvnPropertyValue>();
                foreach (var item in propItems)
                {
                    var propItem = SvnPropertyValue.Parse(item);
                    propItemList.Add(propItem);

                    if (propItem.Prefix == propertyPrefix && propItem.Key == LogPropertyInfo.UserIDKey)
                    {
                        obj.Author = propItem.Value;
                    }
                }
                obj.Properties = propItemList.ToArray();
            }
            else
            {
                var propList = new List <SvnPropertyValue>();
                foreach (var item in props)
                {
                    propList.Add((SvnPropertyValue)item);
                }
                obj.Properties = propList.ToArray();
            }

            return(obj);
        }
コード例 #6
0
        public static SvnLogInfo GetLatestLog(string path)
        {
            var logCommand = new SvnCommand("log")
            {
                (SvnPath)path,
                SvnCommandItem.FromRevision($"head:1"),
                SvnCommandItem.Xml,
                SvnCommandItem.Verbose,
                SvnCommandItem.FromMaxCount(1),
                SvnCommandItem.WithAllRevprops
            };

            return(SvnLogInfo.Read(logCommand.Run()).First());
        }
コード例 #7
0
        public static               SvnLogInfo[] Run(string path, string minRevision, string maxRevision, int count)
        {
            var logCommand = new SvnCommand("log")
            {
                (SvnPath)path,
                SvnCommandItem.FromRevision($"{maxRevision}:{minRevision}"),
                SvnCommandItem.Xml,
                SvnCommandItem.Verbose,
                SvnCommandItem.FromMaxCount(count),
                SvnCommandItem.WithAllRevprops,
            };

            return(SvnLogInfo.Read(logCommand.Run()));
        }
コード例 #8
0
        public RepositoryInfo GetRepositoryInfo(string basePath, string repositoryName)
        {
            var uri            = this.GetUrl(basePath, repositoryName);
            var latestLog      = SvnLogInfo.GetLatestLog($"{uri}");
            var firstLog       = SvnLogInfo.GetFirstLog($"{uri}");
            var repositoryInfo = new RepositoryInfo()
            {
                ID               = GuidUtility.FromName(repositoryName + firstLog.Revision),
                Name             = repositoryName,
                Comment          = firstLog.Comment,
                Revision         = latestLog.Revision,
                CreationInfo     = new SignatureDate(firstLog.Author, firstLog.DateTime),
                ModificationInfo = new SignatureDate(latestLog.Author, latestLog.DateTime),
            };

            return(repositoryInfo);
        }
コード例 #9
0
        public static               SvnLogInfo[] Read(string text)
        {
            var logItemList = new List <SvnLogInfo>();

            using (var sr = new StringReader(text))
            {
                var doc      = XDocument.Load(sr);
                var logItems = doc.XPathSelectElements("/log/logentry");

                foreach (var item in logItems)
                {
                    var logItem = SvnLogInfo.Parse(item);
                    logItemList.Add(logItem);
                }
            }
            return(logItemList.ToArray());
        }
コード例 #10
0
        public static               SvnLogInfo[] GetLogs(string[] paths, string revision)
        {
            var logCommand = new SvnCommand("log")
            {
                SvnCommandItem.FromRevision($"{revision ?? "head"}:1"),
                SvnCommandItem.Xml,
                SvnCommandItem.Verbose,
                SvnCommandItem.FromMaxCount(MaxLogCount),
                SvnCommandItem.WithAllRevprops,
            };

            foreach (var item in paths)
            {
                logCommand.Add((SvnPath)item);
            }
            return(SvnLogInfo.Read(logCommand.Run()));
        }
コード例 #11
0
ファイル: SvnRepository.cs プロジェクト: s2quake/JSSoft.Crema
        public LogInfo[] GetLog(string[] paths, string revision)
        {
            var logs = SvnLogInfo.GetLogs(paths, revision);

            return(logs.Select(item => (LogInfo)item).ToArray());
        }