public void Handler(object sender, SvnLogEventArgs args) { foreach (var changedPath in args.ChangedPaths) { FileDiff fileInfo = new FileDiff( ConvertFrom(changedPath.Action), ConvertFrom(changedPath.NodeKind), changedPath.Path, changedPath.CopyFromPath); FileChanges.Add(fileInfo.Name, fileInfo); } }
public FileDiff AddFileDiff(FileDiff fileDiff) { FileDiffs.Add(fileDiff); return(fileDiff); }
public CommitDiff GetRevisionDiffs(long revision, IDictionary <string, FileDiff> fileInfo, StreamReader reader) { Uri repro = RemoteRepro; string path = repro.AbsolutePath + '/'; var results = new CommitDiff(revision); FileDiff diff = null; bool ignoreFileContent = false; using (reader) { string line = reader.ReadLine(); int startRemovedLineNumber = 1; int startAddedLineNumber = 1; while (line != null) { if (line.StartsWith("Index: ")) { if (diff != null) { // save current file results.AddFileDiff(diff); } string fileName = path + line.Substring("Index: ".Length); // ex: revision 33513 (ref14240) // deleted directory : file name not found in log but found in diff (can ignore) if (fileInfo.ContainsKey(fileName) == false) { ignoreFileContent = true; // Add an entry thought as deleted or moved out of trunk // TODO maybe see if file is realy deelted or just ignore with filestate unknown // assume deleted for the moment results.AddFileDiff(new FileDiff(FileState.Deleted, FileType.None, fileName, null)); diff = null; } else { diff = fileInfo[fileName]; ignoreFileContent = diff.FileState == FileState.Deleted; } line = reader.ReadLine(); } else if (line.StartsWith("+++ ") || line.StartsWith("--- ") || line.StartsWith("==============")) { line = reader.ReadLine(); } else { if (ignoreFileContent == false) { if (line.StartsWith("@@")) { string[] filePos = line.Split(new char[] { '@', ' ' }, StringSplitOptions.RemoveEmptyEntries); startRemovedLineNumber = int.Parse(filePos[0].Split(',')[0].Substring(1)); startAddedLineNumber = int.Parse(filePos[1].Split(',')[0].Substring(1)); diff.AddLine(ChangeState.BreakPoint, line, startRemovedLineNumber, startAddedLineNumber); } else { // we could have a binary file and wish to ignore the content of such things // so precheck the line and ignore content if that is the conclusion if (IsBinaryFile(line)) { ignoreFileContent = true; diff.Lines.Clear(); diff.FileType = FileType.Binary; } else { if (line.StartsWith("+")) { diff.AddLine(ChangeState.Added, line.Substring(1), startRemovedLineNumber, startAddedLineNumber++); } else if (line.StartsWith("-")) { diff.AddLine(ChangeState.Removed, line.Substring(1), startRemovedLineNumber++, startAddedLineNumber); } else { diff.AddLine(ChangeState.None, line.Substring(Math.Min(1, line.Length)), startRemovedLineNumber++, startAddedLineNumber++); } } } } line = reader.ReadLine(); } } if (diff != null) { // save current file results.AddFileDiff(diff); } } return(results); }