bool CheckInMovedFile(string vcsPath, string newVcsPath, string localPath, string newLocalPath, string comment) { try { Log.Message($"Checkin for moved file {vcsPath}"); var repo = DXVcsConnectionHelper.Connect(server, this.user, this.password); if (!repo.IsUnderVss(vcsPath)) { Log.Error($"Move file failed. Can`t locate {vcsPath}."); return(false); } if (repo.IsUnderVss(newVcsPath)) { Log.Error($"Move file error. File {vcsPath} already exist."); return(false); } repo.UndoCheckout(vcsPath, comment); repo.MoveFile(vcsPath, newVcsPath, comment); CheckOutFile(newVcsPath, newLocalPath, true, comment); CheckInFile(newVcsPath, newLocalPath, comment); return(true); } catch (Exception ex) { Log.Error($"Move file {vcsPath} failed.", ex); return(false); } }
public bool CheckOutFile(string vcsPath, string localPath, bool dontGetLocalCopy, string comment) { try { var repo = DXVcsConnectionHelper.Connect(server, this.user, this.password); if (repo.IsUnderVss(vcsPath)) { if (repo.IsCheckedOut(vcsPath)) { if (repo.IsCheckedOutByMe(vcsPath)) { return(true); } var fileData = repo.GetFileData(vcsPath); Log.Message($"File {vcsPath} is checked out by {fileData.CheckedOutUser} already. Check out failed."); return(false); } repo.CheckOutFile(vcsPath, localPath, comment, dontGetLocalCopy); } else { Log.Error($"File {vcsPath} is not under vss."); return(false); } return(true); } catch (Exception ex) { Log.Error($"Checkout file {vcsPath} failed. ", ex); return(false); } }
public IList <HistoryItem> GenerateHistory(TrackBranch branch, DateTime from) { try { var repo = DXVcsConnectionHelper.Connect(server, user, password); var history = Enumerable.Empty <HistoryItem>(); foreach (var trackItem in branch.TrackItems) { string trackPath = branch.GetTrackRoot(trackItem); var historyForItem = repo.GetProjectHistory(trackPath, true, from).Select(x => new HistoryItem() { ActionDate = x.ActionDate, Comment = x.Comment, Label = x.Label, Message = x.Message, Name = x.Name, User = x.User, Track = trackItem, }); history = history.Concat(historyForItem); } return(history.ToList()); } catch (Exception ex) { Log.Error("History generation failed.", ex); throw; } }
public void CreateLabel(string vcsPath, string labelName, string comment = "") { try { var repo = DXVcsConnectionHelper.Connect(server, this.user, this.password); repo.CreateLabel(vcsPath, labelName, comment); } catch (Exception ex) { Log.Error($"Create label {labelName} failed.", ex); } }
public void GetFile(string historyPath, string localPath, DateTime timestamp) { try { var repo = DXVcsConnectionHelper.Connect(server, this.user, this.password); repo.Get(historyPath, localPath, timestamp); } catch (Exception ex) { Log.Error($"Loading sync history from {historyPath} failed", ex); } }
public IEnumerable <UserInfo> GetUsers() { try { var repo = DXVcsConnectionHelper.Connect(server, user, password); return(repo.GetUsers()); } catch (Exception ex) { Log.Error($"Get users from vcs failed.", ex); throw; } }
public FileHistoryInfo[] GetFileHistory(string historyPath, DateTime from) { try { var repo = DXVcsConnectionHelper.Connect(server, this.user, this.password); return(repo.GetFileHistoryEx(historyPath, from)); } catch (Exception ex) { Log.Error($"Loading sync history from {historyPath} failed", ex); } return(null); }
bool PerformHasFileTestBeforeCheckout(string vcsPath) { try { var repo = DXVcsConnectionHelper.Connect(server, this.user, this.password); return(repo.IsUnderVss(vcsPath)); } catch (Exception ex) { Log.Error($"Test file {vcsPath} before ckeckout failed.", ex); return(false); } }
public void GetProject(string server, string vcsPath, string localPath, DateTime timeStamp) { try { var repo = DXVcsConnectionHelper.Connect(server, this.user, this.password); repo.GetProject(vcsPath, localPath, timeStamp); Log.Message($"Get project from vcs performed for {vcsPath}"); } catch (Exception ex) { Log.Error("Get prroject from vcs failed.", ex); throw; } }
public IList <TrackItem> GenerateTrackItems(TrackBranch trackBranch, TrackItem trackItem) { if (!trackItem.GoDeeper) { return new List <TrackItem>() { trackItem } } ; try { var repo = DXVcsConnectionHelper.Connect(server, user, password); string trackRoot = trackBranch.GetTrackRoot(trackItem); var projectData = repo.GetProjectData(trackRoot); if (projectData.IsNull || projectData.SubProjectsCount == 0) { return new List <TrackItem>() { trackItem } } ; var innerProjects = repo.GetProjects(trackRoot); if (innerProjects == null || innerProjects.Length == 0) { return new List <TrackItem>() { trackItem } } ; List <TrackItem> result = new List <TrackItem>(innerProjects.Length); foreach (var info in innerProjects) { var newTrackItem = new TrackItem(); newTrackItem.Branch = trackBranch.Name; newTrackItem.GoDeeper = false; newTrackItem.Path = trackItem.Path + @"/" + info.Name; newTrackItem.ProjectPath = Path.Combine(trackItem.ProjectPath, info.Name).Replace(@"\", @"/"); newTrackItem.AdditionalOffset = trackItem.AdditionalOffset; result.Add(newTrackItem); } return(result); } catch (Exception ex) { Log.Error("Generating trackitems from config failed", ex); throw ex; } }
public string GetFile(string historyPath, string local) { try { var repo = DXVcsConnectionHelper.Connect(server, this.user, this.password); string localPath = Path.GetTempFileName(); repo.GetLatestFileVersion(historyPath, localPath); return(localPath); } catch (Exception ex) { Log.Error($"Loading sync history from {historyPath} failed", ex); return(null); } }
bool IsSharedFile(string vcsPath) { try { var repo = DXVcsConnectionHelper.Connect(server, this.user, this.password); if (!repo.IsUnderVss(vcsPath)) { return(false); } return(repo.HasLiveLinks(vcsPath)); } catch (Exception ex) { Log.Error("Check shared file status failure.", ex); throw ex; } }
bool CheckOutCreateFile(string vcsPath, string localPath, string comment) { try { Log.Message($"Checkout for create file {vcsPath}"); var repo = DXVcsConnectionHelper.Connect(server, this.user, this.password); if (!repo.IsUnderVss(vcsPath)) { repo.AddFile(vcsPath, new byte[0], comment); } repo.CheckOutFile(vcsPath, localPath, comment, true); return(true); } catch (Exception ex) { Log.Error($"Add new file {vcsPath} failed.", ex); return(false); } }
public bool UndoCheckoutFile(string vcsPath, string localPath) { try { var repo = DXVcsConnectionHelper.Connect(server, this.user, this.password); if (repo.IsUnderVss(vcsPath)) { if (repo.IsCheckedOutByMe(vcsPath)) { repo.UndoCheckout(vcsPath, localPath); } } return(true); } catch (Exception ex) { Log.Error($"Undo checkout file {vcsPath} failed. ", ex); return(false); } }
public bool CheckInFile(string vcsPath, string localPath, string comment) { try { var repo = DXVcsConnectionHelper.Connect(server, this.user, this.password); if (repo.IsUnderVss(vcsPath) && repo.IsCheckedOutByMe(vcsPath)) { repo.CheckInFile(vcsPath, localPath, comment); } else { Log.Error($"File {vcsPath} is not under vss."); return(false); } return(true); } catch (Exception ex) { Log.Error($"Checkin file {vcsPath} failed. ", ex); return(false); } }
void CheckIsSingleSharedFile(IEnumerable <SyncItem> files, SyncItem sharedFile) { try { var repo = DXVcsConnectionHelper.Connect(server, this.user, this.password); var liveLinks = repo.GetLiveLinks(sharedFile.VcsPath); int conflicts = 0; foreach (var liveLink in liveLinks) { if (files.Any(x => x.VcsPath == liveLink.Path)) { conflicts = conflicts + 1; } } sharedFile.SharedFile = true; sharedFile.SingleSharedFile = conflicts < 2; } catch (Exception ex) { Log.Error("Check shared file status failure.", ex); throw ex; } }
TestFileResult PerformSimpleTestBeforeCheckout(string vcsPath, bool ignoreSharedFiles, bool singleSharedFile, bool allowSingleSharedFile) { try { var repo = DXVcsConnectionHelper.Connect(server, this.user, this.password); if (!repo.IsUnderVss(vcsPath)) { return(TestFileResult.Ok); } bool hasLiveLinks = repo.HasLiveLinks(vcsPath); if (hasLiveLinks) { if (ignoreSharedFiles) { return(TestFileResult.Ignore); } if (!allowSingleSharedFile || !singleSharedFile) { Log.Error($"Can`t process shared file {vcsPath}. Destroy active links or sync this file manually using vcs."); return(TestFileResult.Fail); } Log.Message($@"Shared file with simple commit detected {vcsPath}. File change allowed."); } var filedata = repo.GetFileData(vcsPath); bool isFree = !filedata.CheckedOut || filedata.CheckedOutMe; if (!isFree) { Log.Error($"Can`t process checked out file {vcsPath}. Contact {filedata.CheckedOutUser} or resert check out state."); return(TestFileResult.Fail); } return(TestFileResult.Ok); } catch (Exception ex) { Log.Error($"Test file {vcsPath} before checkout failed.", ex); } return(TestFileResult.Fail); }
bool CheckOutDeleteFile(string vcsPath, string localPath, string comment) { try { Log.Message($"Checkout for deleted file {vcsPath}"); var repo = DXVcsConnectionHelper.Connect(server, this.user, this.password); if (!repo.IsUnderVss(vcsPath)) { return(true); } if (repo.IsCheckedOut(vcsPath) && !repo.IsCheckedOutByMe(vcsPath)) { Log.Error($"File {vcsPath} is checked out already."); return(false); } repo.CheckOutFile(vcsPath, localPath, comment, true); return(true); } catch (Exception ex) { Log.Error($"Add new file {vcsPath} failed.", ex); return(false); } }