void CreateNewFileIfNeeded(IDXVcsRepository repository, string vcsTargetFile, DXVcsBranch branch) { if (repository.IsUnderVss(vcsTargetFile)) { throw new ArgumentException("File is under vss alrealy!"); } string filePath = GetFilePathForNewFile(repository, vcsTargetFile, branch); if (File.Exists(filePath)) { var attr = File.GetAttributes(filePath); if (attr == FileAttributes.ReadOnly) { throw new ArgumentException("File is readonly!"); } File.Delete(filePath); } string dir = Path.GetDirectoryName(filePath); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } using (var f = File.Create(filePath)) { f.Close(); } }
public bool IsItemUnderVss(string filePath, DXVcsBranch current) { try { string vcsTargetPath = GetMergeVcsPathByOriginalPath(filePath, current); IDXVcsRepository repository = DXVcsRepositoryFactory.Create(Port.VcsServer); return(repository.IsUnderVss(vcsTargetPath)); } catch (Exception e) { Logger.AddError("IsItemUnderVss failed.", e); } return(true); }
public void CompareCurrentWithPortVersion(string filePath, DXVcsBranch current) { try { IDXVcsRepository repository = DXVcsRepositoryFactory.Create(Port.VcsServer); string vcsTargetPath = GetMergeVcsPathByOriginalPath(filePath, current); if (!repository.IsUnderVss(vcsTargetPath)) { DXMessageBox.Show("Target is not under vss"); return; } string fileTargetPath = repository.GetFileWorkingPath(vcsTargetPath); PreviewTarget(repository, fileTargetPath, vcsTargetPath, filePath, false); } catch (Exception e) { DXMessageBox.Show(e.Message); } }