/// <summary> /// Discards selected changes from the selected project. /// </summary> public void Discard(string[] files) { if (CheckProjects()) { return; } ClientUI.ShowProgress("Discarding..."); try { var diffs = CurrentProject.BuildDiff(); var diff = diffs.Where(file => files.Any(x => x == file.FileName)).ToList(); var commit = Commit.FromDiff(diff.ToArray()); CurrentProject.Discard(commit.Files, x => { ClientUI.SetProgress("Discarding " + diff.Count + " change(s). " + x); }); } catch (Exception ex) { ClientUI.ShowMessage("Error when discarding, no changes were discared, message: <br>" + ex.Message, true); } ClientUI.HideProgress(); ClientUI.ShowProgress("Discarding done! Loading..."); CurrentProject.Refresh(delegate { UpdateView(); ClientUI.HideProgress(); }); }
/// <summary> /// Pulls all changes on the selected project. /// </summary> public void Pull() { if (CheckProjects()) { return; } try { ClientUI.ShowProgress("Pulling changes..."); CurrentProject.Pull(x => { ClientUI.SetProgress("Pulling..." + x); }); ClientUI.HideProgress(); ClientUI.ShowProgress("Pulling done! Loading..."); CurrentProject.Refresh(delegate { UpdateView(); ClientUI.HideProgress(); }); } catch (WarningException ex) { ClientUI.HideProgress(); ClientUI.ShowMessage(ex.Message); } catch (Exception ex) { ClientUI.HideProgress(); ClientUI.ShowMessage("Error when pulling, no changes were pulled, message: <br>" + ex.Message, true); } }
/// <summary> /// Pueshes selected changes from the selected project. /// </summary> public void Push(string[] files) { if (CheckProjects()) { return; } if (files.Length == 0) { ClientUI.ShowMessage("No file changes selected, select some."); return; } try { ClientUI.ShowProgress("Building commit..."); var diffs = CurrentProject.BuildDiff(); var diff = diffs.Where(file => files.Any(x => x == file.FileName)).ToList(); if (diff.Count == 0) { ClientUI.ShowMessage("No file changes selected, select some."); return; } var commit = Commit.FromDiff(diff.ToArray()); var datafile = commit.Build(CurrentProject.RootDir, CurrentProject.RootDir + ".mysync\\commit.zip", x => { ClientUI.SetProgress("Building commit... " + x); }); ClientUI.SetProgress("Pushing " + diff.Count + " change(s)."); CurrentProject.Push(commit, datafile, x => { ClientUI.SetProgress("Pushing " + diff.Count + " change(s). " + x); }); ClientUI.HideProgress(); ClientUI.ShowProgress("Push done! Loading..."); CurrentProject.Refresh(delegate { UpdateView(); ClientUI.HideProgress(); }); } catch (Exception ex) { ClientUI.HideProgress(); ClientUI.ShowMessage("Error when pushing, no changes were pushed, message: <br>" + ex.Message, true); } }