public bool AddFileToRepository(string pathToFile, string comment = "") { try { FileInRepo file = GetFileIfExist(pathToFile); if (file == null) { file = new FileInRepo(pathToFile, comment); file.AssignToRepository(this); repository.Add(file); File.Copy(pathToFile, Path.Combine(pathToRepo, file.NameInRepo)); OnChanged(this, new EventArgs()); return true; } else { FileInRepo newVersionOfFile = FileInRepo.GetPartialCopy(file); newVersionOfFile.Version += 1; newVersionOfFile.Comment = comment; newVersionOfFile.NameInRepo = newVersionOfFile.GenerateUniqueNameForFile(); newVersionOfFile.AssignToRepository(this); repository.Add(newVersionOfFile); File.Copy(pathToFile, Path.Combine(pathToRepo, newVersionOfFile.NameInRepo)); OnChanged(this, new EventArgs()); return true; } } catch { return false; } }
public void ShowDiffs(FileInRepo fileFromRepo, string pathToRepo) { System.Diagnostics.Process.Start(pathToDiffEditor, fileFromRepo.FullPath + " " + Path.Combine(pathToRepo,fileFromRepo.NameInRepo)); }
public void RestoreFile(FileInRepo file) { File.Copy(Path.Combine(pathToRepo, file.NameInRepo), file.FullPath, true); }
public bool RemoveFileFromRepository(FileInRepo file) { File.Delete(Path.Combine(pathToRepo, file.NameInRepo)); repository.Remove(file); OnChanged(this, new EventArgs()); return true; }
public FileInRepo GetFullCopy() { FileInRepo tmp = new FileInRepo(); tmp.Name = this.Name; tmp.FullPath = this.FullPath; tmp.Comment = this.Comment; tmp.NameInRepo = this.NameInRepo; tmp.Version = this.Version; tmp.FullPathInRepo = this.FullPathInRepo; return tmp; }
public static FileInRepo GetPartialCopy(FileInRepo original) { FileInRepo result = new FileInRepo(original.FullPath); result.Version = original.Version; return result; }