private void TouchPath(SvnTouchedPath touchedPath) { if (touchedPath.IsFile) { switch (touchedPath.Action) { case SvnTouchedPath.SvnTouchedPathAction.MODIFIED: TouchFile(TouchedFile.TouchedFileAction.MODIFIED, touchedPath.Path); break; case SvnTouchedPath.SvnTouchedPathAction.ADDED: TouchFile(TouchedFile.TouchedFileAction.ADDED, touchedPath.Path, touchedPath.SourcePath, touchedPath.SourceRevision); break; case SvnTouchedPath.SvnTouchedPathAction.DELETED: TouchFile(TouchedFile.TouchedFileAction.DELETED, touchedPath.Path); break; case SvnTouchedPath.SvnTouchedPathAction.REPLACED: TouchFile(TouchedFile.TouchedFileAction.DELETED, touchedPath.Path); TouchFile(TouchedFile.TouchedFileAction.ADDED, touchedPath.Path, touchedPath.SourcePath, touchedPath.SourceRevision); break; default: break; } } else if (touchedPath.Action == SvnTouchedPath.SvnTouchedPathAction.DELETED) { foreach (var deletedFile in PathList(touchedPath.Path, PreviousRevision())) { TouchFile(TouchedFile.TouchedFileAction.DELETED, deletedFile); } } }
private IEnumerable <SvnTouchedPath> SvnTouchedPaths() { List <SvnTouchedPath> svnTouchedPaths = new List <SvnTouchedPath>(); XElement diffSumXml; using (var diffSum = svn.DiffSum(Revision)) { diffSumXml = XElement.Load(new StreamReader(diffSum)); } int repositoryPathLength = svn.RepositoryPath.Length; var logPathInfo = (from x in logXml.Descendants("path") select new { Path = x.Value, Action = ParsePathAction(x.Attribute("action").Value), SourcePath = x.Attribute("copyfrom-path") == null ? null : x.Attribute("copyfrom-path").Value, SourceRevision = x.Attribute("copyfrom-rev") == null ? null : x.Attribute("copyfrom-rev").Value }).ToList(); var diffSumPathInfo = (from x in diffSumXml.Descendants("path") select new { Path = x.Value.Substring(repositoryPathLength), Action = ParsePathAction(x.Attribute("item").Value), IsFile = x.Attribute("kind").Value == "file" }).ToList(); var replacedPaths = logPathInfo.Where(x => x.Action == SvnTouchedPath.SvnTouchedPathAction.REPLACED && x.SourcePath != null ).Select(x => x.Path); foreach (var pathInfo in diffSumPathInfo) { var touchedPath = new SvnTouchedPath() { Path = pathInfo.Path, IsFile = pathInfo.IsFile, Action = pathInfo.Action }; if (touchedPath.Action == SvnTouchedPath.SvnTouchedPathAction.MODIFIED && replacedPaths.Contains(touchedPath.Path)) { touchedPath.Action = SvnTouchedPath.SvnTouchedPathAction.REPLACED; } svnTouchedPaths.Add(touchedPath); } foreach (var pathInfo in logPathInfo .Where(x => x.SourcePath != null) .OrderBy(x => x.Path) ) { var touchedPath = svnTouchedPaths.SingleOrDefault(x => x.Path == pathInfo.Path ); if (touchedPath == null) { continue; } if (!touchedPath.IsFile) { foreach (var copiedFile in svnTouchedPaths .Where(x => x.Path.StartsWith(pathInfo.Path + "/")) ) { var copiedFileLogInfo = logPathInfo.SingleOrDefault(x => x.Path == copiedFile.Path); if ( (copiedFileLogInfo == null) || (copiedFileLogInfo.Action != SvnTouchedPath.SvnTouchedPathAction.ADDED) ) { copiedFile.SourcePath = copiedFile.Path.Replace(pathInfo.Path, pathInfo.SourcePath); copiedFile.SourceRevision = pathInfo.SourceRevision; } } } else { touchedPath.SourcePath = touchedPath.Path.Replace(pathInfo.Path, pathInfo.SourcePath); touchedPath.SourceRevision = pathInfo.SourceRevision; } } return(svnTouchedPaths); }