public void RemoveChange(Change change) { changeManager.RemoveChange(change); }
public void AddChange(Change change, Commit commit) { changeManager.AddChange(change, commit); }
private List<Change> GetFileChanges(String repositoryPath, String commitPath, RepositoryFile file) { var result = new List<Change>(); var sourcePath = file.GetFileRealPath(repositoryPath); var destinationPath = file.GetFileRealPath(commitPath); TextFile sourceFile; TextFile destinationFile; if (System.IO.File.Exists(destinationPath)) { destinationFile = new TextFile(destinationPath); } else { destinationFile = new TextFile(); DataManager.GetInstance().MarkFileAsDeleted(file); } sourceFile = new TextFile(sourcePath); var difference = DiffHelper.GetDifference(sourceFile, destinationFile); foreach (DiffResultSpan diffResultSpan in difference) { switch (diffResultSpan.Status) { case DiffResultSpanStatus.DeleteSource: for (int i = 0; i < diffResultSpan.Length; i++) { var change = new Change(file, ChangeType.Remove, diffResultSpan.SourceIndex, ((TextLine) sourceFile.GetByIndex(diffResultSpan.SourceIndex + i)). Line); result.Add(change); } break; case DiffResultSpanStatus.AddDestination: for (int i = 0; i < diffResultSpan.Length; i++) { var change = new Change(file, ChangeType.Add, diffResultSpan.DestIndex, ((TextLine)destinationFile.GetByIndex(diffResultSpan.DestIndex + i)). Line); result.Add(change); } break; case DiffResultSpanStatus.Replace: for (int i = 0; i < diffResultSpan.Length; i++) { var change = new Change(file, ChangeType.Update, diffResultSpan.SourceIndex, ((TextLine)sourceFile.GetByIndex(diffResultSpan.SourceIndex + i)). Line); result.Add(change); } break; } } return result; }