예제 #1
0
 private static SVNInfo SharpSVNToSVNInfo(Source source, Collection<SvnInfoEventArgs> collection)
 {
     SVNInfo info = new SVNInfo
     {
         Source = source
     };
     if ((collection != null) || (collection.Count > 0))
     {
         SvnInfoEventArgs arg = collection[0];
         info.LastChangedAuthor = arg.LastChangeAuthor;
         info.LastChangedDate = arg.LastChangeTime;
         info.Path = arg.Path;
         info.RepositoryRoot = arg.RepositoryRoot.ToString();
         info.Revision = arg.Revision;
         info.URL = arg.Uri.ToString();
     }
     return info;
 }
예제 #2
0
 internal void SetInfo(SVNInfo info)
 {
     Info = info;
 }
예제 #3
0
 private static SVNLog SharpSVNToSVNLog(Source source, Collection<SvnLogEventArgs> collection, SVNInfo info, Collection<SvnStatusEventArgs> statusCollection)
 {
     SVNLog log = new SVNLog();
     Dictionary<string, SvnStatusEventArgs> statusMap = GetStatusMap(statusCollection);
     foreach (SvnLogEventArgs logItem in collection)
     {
         DateTime localTime = logItem.Time.ToLocalTime();
         SVNLogEntry entry = new SVNLogEntry(source, logItem.Revision, logItem.Author, localTime, logItem.LogMessage);
         SvnChangeItemCollection items = logItem.ChangedPaths;
         if (items != null)
         {
             List<SVNPath> paths = new List<SVNPath>();
             foreach (SvnChangeItem item in items)
             {
                 SVNPath path = new SVNPath(entry, SVNActionConverter.ToSVNAction(item.Action), item.Path);
                 string pathName = item.Path;
                 if (pathName.StartsWith("/"))
                 {
                     pathName = pathName.Substring(1);
                 }
                 string pathUri = info.RepositoryRoot + pathName;
                 path.Uri = pathUri;
                 if (statusMap.ContainsKey(pathUri))
                 {
                     SvnStatusEventArgs statusItem = statusMap[pathUri];
                     path.FilePath = statusItem.FullPath;
                 }
                 else
                 {
                     string filePath = SVNPath.GuessFilePath(entry, path.Name, info);
                     if (FileSystemHelper.Exists(filePath))
                     {
                         path.FilePath = filePath;
                     }
                     else
                     {
                         path.FilePath = pathUri;
                     }
                 }
                 paths.Add(path);
             }
             entry.Paths = paths;
             log.LogEntries.Add(entry);
         }
     }
     return log;
 }
예제 #4
0
 internal static string GuessFilePath(SVNLogEntry logEntry, string name, SVNInfo info)
 {
     if (info == null)
     {
         return name;
     }
     if (logEntry.Source.IsURL)
     {
         return (info.RepositoryRoot + name);
     }
     if (FileSystemHelper.FileExists(info.Path))
     {
         return info.Path;
     }
     string sourcePath = logEntry.Source.Path;
     string target = null;
     string fileProtocol = "file:///";
     if (info.URL.Contains(fileProtocol))
     {
         target = name;
         if (target.StartsWith(fileProtocol))
         {
             target = target.Substring(fileProtocol.Length);
         }
         else
         {
             string rootBase = info.URL.Substring(info.RepositoryRoot.Length);
             if (rootBase.Length <= target.Length)
             {
                 target = target.Substring(rootBase.Length);
                 if (target.StartsWith("/"))
                 {
                     target = target.Substring(1, target.Length - 1);
                 }
                 target = Path.Combine(sourcePath, target);
             }
         }
     }
     if (target == null)
     {
         target = name.Trim().Replace('/', '\\');
         string rootBase = info.URL.Substring(info.RepositoryRoot.Length);
         if (string.IsNullOrEmpty(rootBase))
         {
             target = target.TrimStart(new[]
             {
                 '\\'
             });
             target = Path.Combine(sourcePath, target);
         }
         else if (name.Length > rootBase.Length)
         {
             target = sourcePath + name.Substring(rootBase.Length);
         }
     }
     try
     {
         target = FileSystemHelper.GetFullPath(target);
     }
     catch (Exception ex)
     {
         Logger.Log.Error(string.Format("Error in System.IO.Path.GetFullPath (source={0}, sourcePath={1}, target={2})", logEntry.Source, sourcePath, target), ex);
     }
     return target;
 }