예제 #1
0
파일: DataManager.cs 프로젝트: Gvin/Diplom
 public void RemoveChange(Change change)
 {
     changeManager.RemoveChange(change);
 }
예제 #2
0
파일: DataManager.cs 프로젝트: Gvin/Diplom
 public void AddChange(Change change, Commit commit)
 {
     changeManager.AddChange(change, commit);
 }
예제 #3
0
        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;
        }