private void Revert_Click(object sender, EventArgs e)
        {
            List <string> argumentsList = new List <string>();
            bool          CanExecute    = true;

            if (IsMerge)
            {
                if (ParentsList.SelectedItems.Count == 0)
                {
                    MessageBox.Show(this, _noneParentSelectedText.Text, _noneParentSelectedTextCaption.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    CanExecute = false;
                }
                else
                {
                    argumentsList.Add("-m " + (ParentsList.SelectedItems[0].Index + 1));
                }
            }
            if (checkAddReference.Checked)
            {
                argumentsList.Add("-x");
            }
            if (CanExecute)
            {
                FormProcess.ShowDialog(this, GitCommandHelpers.CherryPickCmd(Revision.Guid, AutoCommit.Checked, string.Join(" ", argumentsList.ToArray())));
                MergeConflictHandler.HandleMergeConflicts(UICommands, this, AutoCommit.Checked);
                DialogResult = DialogResult.OK;
                Close();
            }
        }
Exemple #2
0
        private bool EvaluateProcessDialogResults(IWin32Window owner, FormProcess process, bool stashed)
        {
            try
            {
                if (EvaluateResultsBasedOnSettings(stashed, process))
                {
                    return(true);
                }
            }
            finally
            {
                if (stashed)
                {
                    bool messageBoxResult =
                        MessageBox.Show(owner, _applyShashedItemsAgain.Text, _applyShashedItemsAgainCaption.Text,
                                        MessageBoxButtons.YesNo) == DialogResult.Yes;
                    if (ShouldStashPop(messageBoxResult, process, true))
                    {
                        new FormProcess("stash pop").ShowDialog(owner);
                        MergeConflictHandler.HandleMergeConflicts(owner);
                    }
                }

                ScriptManager.RunEventScripts(ScriptEvent.AfterPull);
            }

            return(false);
        }
Exemple #3
0
        private DialogResult EvaluateProcessDialogResults(IWin32Window owner, FormProcess process, bool stashed)
        {
            try
            {
                if (EvaluateResultsBasedOnSettings(stashed, process))
                {
                    return(DialogResult.OK);
                }
            }
            finally
            {
                if (stashed)
                {
                    bool messageBoxResult = Settings.AutoPopStashAfterPull ||
                                            MessageBox.Show(owner, _applyShashedItemsAgain.Text, _applyShashedItemsAgainCaption.Text,
                                                            MessageBoxButtons.YesNo) == DialogResult.Yes;
                    if (ShouldStashPop(messageBoxResult, process, true))
                    {
                        FormProcess.ShowDialog(owner, Module, "stash pop");
                        MergeConflictHandler.HandleMergeConflicts(UICommands, owner, false);
                    }
                }

                ScriptManager.RunEventScripts(Module, ScriptEvent.AfterPull);
            }

            return(DialogResult.No);
        }
Exemple #4
0
        private void ApplyClick(object sender, EventArgs e)
        {
            new FormProcess(string.Format("stash apply {0}", Stashes.Text)).ShowDialog(this);

            MergeConflictHandler.HandleMergeConflicts(this);

            Initialize();
        }
Exemple #5
0
        private void ApplyClick(object sender, EventArgs e)
        {
            FormProcess.ShowDialog(this, string.Format("stash apply \"{0}\"", Stashes.Text));

            MergeConflictHandler.HandleMergeConflicts(UICommands, this, false);

            Initialize();
        }
Exemple #6
0
        private void Revert_Click(object sender, EventArgs e)
        {
            new FormProcess(GitCommandHelpers.RevertCmd(Revision.Guid, AutoCommit.Checked)).ShowDialog(this);

            MergeConflictHandler.HandleMergeConflicts(this);

            Close();
        }
        private void OkClick(object sender, EventArgs e)
        {
            var process = new FormProcess(GitCommandHelpers.MergeBranchCmd(Branches.Text, fastForward.Checked, squash.Checked, noCommit.Checked, _NO_TRANSLATE_mergeStrategy.Text));

            process.ShowDialog();

            MergeConflictHandler.HandleMergeConflicts();

            if (!process.ErrorOccurred())
            {
                Close();
            }
        }
Exemple #8
0
        private void OkClick(object sender, EventArgs e)
        {
            Settings.NoFastForwardMerge = noFastForward.Checked;

            var successfullyMerged = FormProcess.ShowDialog(this,
                                                            GitCommandHelpers.MergeBranchCmd(Branches.GetSelectedText(), fastForward.Checked, squash.Checked, noCommit.Checked, _NO_TRANSLATE_mergeStrategy.Text));

            var wasConflict = MergeConflictHandler.HandleMergeConflicts(this);

            if (successfullyMerged || wasConflict)
            {
                Close();
            }
        }
        private void CherryPick_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            if (RevisionGrid.GetSelectedRevisions().Count != 1)
            {
                MessageBox.Show(this, _noRevisionSelectedMsgBox.Text, _noRevisionSelectedMsgBoxCaption.Text);
                return;
            }
            bool          formClosed = false;
            List <string> arguments  = new List <string>();
            bool          IsMerge    = Settings.Module.IsMerge(RevisionGrid.GetSelectedRevisions()[0].Guid);

            if (IsMerge && !autoParent.Checked)
            {
                GitRevision[] ParentsRevisions = Settings.Module.GetParents(RevisionGrid.GetSelectedRevisions()[0].Guid);
                var           choose           = new FormCherryPickMerge(ParentsRevisions);
                choose.ShowDialog(this);
                if (choose.OkClicked)
                {
                    arguments.Add("-m " + (choose.ParentsList.SelectedItems[0].Index + 1));
                }
                else
                {
                    formClosed = true;
                }
            }
            else if (IsMerge)
            {
                arguments.Add("-m 1");
            }

            if (checkAddReference.Checked)
            {
                arguments.Add("-x");
            }

            if (!formClosed)
            {
                MessageBox.Show(this, _cmdExecutedMsgBox.Text + " " + Environment.NewLine + Settings.Module.CherryPick(RevisionGrid.GetSelectedRevisions()[0].Guid, AutoCommit.Checked, string.Join(" ", arguments.ToArray())), _cmdExecutedMsgBoxCaption.Text);

                MergeConflictHandler.HandleMergeConflicts(this);

                RevisionGrid.RefreshRevisions();

                Cursor.Current = Cursors.Default;
            }
        }
Exemple #10
0
        private void CherryPick_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            if (RevisionGrid.GetRevisions().Count != 1)
            {
                MessageBox.Show("Select 1 revision to pick.", "Cherry pick");
                return;
            }
            bool   formClosed = false;
            string arguments  = "";
            bool   IsMerge    = GitCommandHelpers.IsMerge(RevisionGrid.GetRevisions()[0].Guid);

            if (IsMerge && !autoParent.Checked)
            {
                GitRevision[] ParentsRevisions = GitCommandHelpers.GetParents(RevisionGrid.GetRevisions()[0].Guid);
                var           choose           = new FormCherryPickMerge(ParentsRevisions);
                choose.ShowDialog();
                if (choose.OkClicked)
                {
                    arguments = "-m " + (choose.ParentsList.SelectedItems[0].Index + 1);
                }
                else
                {
                    formClosed = true;
                }
            }
            else if (IsMerge)
            {
                arguments = "-m 1";
            }

            if (!formClosed)
            {
                MessageBox.Show("Command executed " + Environment.NewLine + GitCommandHelpers.CherryPick(RevisionGrid.GetRevisions()[0].Guid, AutoCommit.Checked, arguments), "Cherry pick");

                MergeConflictHandler.HandleMergeConflicts();

                RevisionGrid.RefreshRevisions();

                Cursor.Current = Cursors.Default;
            }
        }
Exemple #11
0
        private void Revert_Click(object sender, EventArgs e)
        {
            var parentIndex = 0;

            if (_isMerge)
            {
                if (ParentsList.SelectedItems.Count != 1)
                {
                    MessageBox.Show(this, _noneParentSelectedText.Text, _noneParentSelectedTextCaption.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    parentIndex = ParentsList.SelectedItems[0].Index + 1;
                }
            }

            FormProcess.ShowDialog(this, GitCommandHelpers.RevertCmd(Revision.Guid, AutoCommit.Checked, parentIndex));
            MergeConflictHandler.HandleMergeConflicts(UICommands, this, AutoCommit.Checked);
            Close();
        }
Exemple #12
0
        private bool EvaluateResultsBasedOnSettings(bool stashed, FormProcess process)
        {
            if (!Settings.Module.InTheMiddleOfConflictedMerge() &&
                !Settings.Module.InTheMiddleOfRebase() &&
                (process != null && !process.ErrorOccurred()))
            {
                InitModules();
                return(true);
            }

            // Rebase failed -> special 'rebase' merge conflict
            if (Rebase.Checked && Settings.Module.InTheMiddleOfRebase())
            {
                GitUICommands.Instance.StartRebaseDialog(null);
                if (!Settings.Module.InTheMiddleOfConflictedMerge() &&
                    !Settings.Module.InTheMiddleOfRebase())
                {
                    return(true);
                }
            }
            else
            {
                MergeConflictHandler.HandleMergeConflicts(this);
                if (!Settings.Module.InTheMiddleOfConflictedMerge() &&
                    !Settings.Module.InTheMiddleOfRebase())
                {
                    return(true);
                }
            }

            if (!AutoStash.Checked || !stashed || Settings.Module.InTheMiddleOfConflictedMerge() ||
                Settings.Module.InTheMiddleOfRebase())
            {
                return(true);
            }
            return(false);
        }
Exemple #13
0
        private void Revert_Click(object sender, EventArgs e)
        {
            string arguments  = "";
            bool   CanExecute = true;

            if (IsMerge)
            {
                if (ParentsList.SelectedItems.Count == 0)
                {
                    MessageBox.Show(this, _noneParentSelectedText.Text, _noneParentSelectedTextCaption.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    CanExecute = false;
                }
                else
                {
                    arguments = "-m " + (ParentsList.SelectedItems[0].Index + 1);
                }
            }
            if (CanExecute)
            {
                new FormProcess(GitCommandHelpers.CherryPickCmd(Revision.Guid, AutoCommit.Checked, arguments)).ShowDialog(this);
                MergeConflictHandler.HandleMergeConflicts(this);
                Close();
            }
        }
        public bool PullChanges()
        {
            if (PullFromUrl.Checked && string.IsNullOrEmpty(PullSource.Text))
            {
                MessageBox.Show(_selectSourceDirectory.Text);
                return(false);
            }
            if (PullFromRemote.Checked && string.IsNullOrEmpty(Remotes.Text) && !PullAll())
            {
                MessageBox.Show(_selectRemoteRepository.Text);
                return(false);
            }

            if (!Fetch.Checked && Branches.Text == "*")
            {
                MessageBox.Show(_fetchAllBranchesCanOnlyWithFetch.Text);
                return(false);
            }

            if (Merge.Checked)
            {
                Settings.PullMerge = "merge";
            }
            if (Rebase.Checked)
            {
                Settings.PullMerge = "rebase";
            }
            if (Fetch.Checked)
            {
                Settings.PullMerge = "fetch";
            }

            Settings.AutoStash = AutoStash.Checked;

            Repositories.RepositoryHistory.AddMostRecentRepository(PullSource.Text);

            string source;

            if (PullFromUrl.Checked)
            {
                source = PullSource.Text;
            }
            else
            {
                LoadPuttyKey();
                source = PullAll() ? "--all" : Remotes.Text;
            }

            ScriptManager.RunEventScripts(ScriptEvent.BeforePull);

            var stashed = false;

            if (!Fetch.Checked && AutoStash.Checked && GitCommandHelpers.GitStatus(false).Count > 0)
            {
                new FormProcess("stash save").ShowDialog();
                stashed = true;
            }

            FormProcess process = null;

            if (Fetch.Checked)
            {
                process = new FormProcess(GitCommandHelpers.FetchCmd(source, Branches.Text, null));
            }
            else
            {
                string localBranch = GitCommandHelpers.GetSelectedBranch();
                if (localBranch.Equals("(no branch)", StringComparison.OrdinalIgnoreCase) || string.IsNullOrEmpty(Branches.Text))
                {
                    localBranch = null;
                }

                if (Merge.Checked)
                {
                    process = new FormProcess(GitCommandHelpers.PullCmd(source, Branches.Text, localBranch, false));
                }
                else if (Rebase.Checked)
                {
                    process = new FormProcess(GitCommandHelpers.PullCmd(source, Branches.Text, localBranch, true));
                }
            }

            if (process != null)
            {
                process.ShowDialog();
            }

            try
            {
                if (!GitCommandHelpers.InTheMiddleOfConflictedMerge() &&
                    !GitCommandHelpers.InTheMiddleOfRebase() &&
                    (process != null && !process.ErrorOccurred()))
                {
                    return(true);
                }

                // Rebase failed -> special 'rebase' merge conflict
                if (Rebase.Checked && GitCommandHelpers.InTheMiddleOfRebase())
                {
                    GitUICommands.Instance.StartRebaseDialog(null);
                    if (!GitCommandHelpers.InTheMiddleOfConflictedMerge() &&
                        !GitCommandHelpers.InTheMiddleOfRebase())
                    {
                        return(true);
                    }
                }
                else
                {
                    MergeConflictHandler.HandleMergeConflicts();
                    if (!GitCommandHelpers.InTheMiddleOfConflictedMerge() &&
                        !GitCommandHelpers.InTheMiddleOfRebase())
                    {
                        return(true);
                    }
                }

                if (!AutoStash.Checked || !stashed || GitCommandHelpers.InTheMiddleOfConflictedMerge() ||
                    GitCommandHelpers.InTheMiddleOfRebase())
                {
                    return(true);
                }

                if (MessageBox.Show(_applyShashedItemsAgain.Text, _applyShashedItemsAgainCaption.Text,
                                    MessageBoxButtons.YesNo) != DialogResult.Yes)
                {
                    return(true);
                }

                if (stashed)
                {
                    new FormProcess("stash pop").ShowDialog();
                }

                MergeConflictHandler.HandleMergeConflicts();
            }
            finally
            {
                ScriptManager.RunEventScripts(ScriptEvent.AfterPull);
            }

            return(false);
        }
Exemple #15
0
        public bool PullChanges()
        {
            if (PullFromUrl.Checked && string.IsNullOrEmpty(PullSource.Text))
            {
                MessageBox.Show(this, _selectSourceDirectory.Text);
                return(false);
            }
            if (PullFromRemote.Checked && string.IsNullOrEmpty(_NO_TRANSLATE_Remotes.Text) && !PullAll())
            {
                MessageBox.Show(this, _selectRemoteRepository.Text);
                return(false);
            }

            if (!Fetch.Checked && Branches.Text == "*")
            {
                MessageBox.Show(this, _fetchAllBranchesCanOnlyWithFetch.Text);
                return(false);
            }

            if (Merge.Checked)
            {
                Settings.PullMerge = "merge";
            }
            if (Rebase.Checked)
            {
                Settings.PullMerge = "rebase";
            }
            if (Fetch.Checked)
            {
                Settings.PullMerge = "fetch";
            }

            Settings.AutoStash = AutoStash.Checked;

            //ask only if exists commit not pushed to remote yet
            if (Rebase.Checked && PullFromRemote.Checked)
            {
                string branchRemote = _NO_TRANSLATE_Remotes.Text;
                string remoteBranchName;
                if (Branches.Text.IsNullOrEmpty())
                {
                    remoteBranchName = Settings.Module.GetSetting("branch." + branch + ".merge");
                    remoteBranchName = Settings.Module.RunGitCmd("name-rev --name-only \"" + remoteBranchName + "\"").Trim();
                }
                else
                {
                    remoteBranchName = Branches.Text;
                }
                remoteBranchName = branchRemote + "/" + remoteBranchName;
                if (Settings.Module.ExistsMergeCommit(remoteBranchName, branch))
                {
                    DialogResult dr = MessageBox.Show(this, _areYouSureYouWantToRebaseMerge.Text, _areYouSureYouWantToRebaseMergeCaption.Text, MessageBoxButtons.YesNoCancel);
                    if (dr == DialogResult.Cancel)
                    {
                        Close();
                        return(false);
                    }
                    else if (dr != DialogResult.Yes)
                    {
                        return(false);
                    }
                }
            }

            Repositories.RepositoryHistory.AddMostRecentRepository(PullSource.Text);

            string source;

            if (PullFromUrl.Checked)
            {
                source = PullSource.Text;
            }
            else
            {
                LoadPuttyKey();
                source = PullAll() ? "--all" : _NO_TRANSLATE_Remotes.Text;
            }

            ScriptManager.RunEventScripts(ScriptEvent.BeforePull);

            var stashed = false;

            if (!Fetch.Checked && AutoStash.Checked && Settings.Module.GitStatus(false).Count > 0)
            {
                new FormProcess("stash save").ShowDialog(this);
                stashed = true;
            }

            FormProcess process = null;

            if (Fetch.Checked)
            {
                process = new FormRemoteProcess(Settings.Module.FetchCmd(source, Branches.Text, null));
            }
            else
            {
                string localBranch = Settings.Module.GetSelectedBranch();
                if (localBranch.Equals("(no branch)", StringComparison.OrdinalIgnoreCase) || string.IsNullOrEmpty(Branches.Text))
                {
                    localBranch = null;
                }

                if (Merge.Checked)
                {
                    process = new FormRemoteProcess(Settings.Module.PullCmd(source, Branches.Text, localBranch, false));
                }
                else if (Rebase.Checked)
                {
                    process = new FormRemoteProcess(Settings.Module.PullCmd(source, Branches.Text, localBranch, true));
                }
            }

            if (process != null)
            {
                if (!PullAll())
                {
                    process.Remote = source;
                }
                process.ShowDialog(this);
                ErrorOccurred = process.ErrorOccurred();
            }

            try
            {
                if (!Settings.Module.InTheMiddleOfConflictedMerge() &&
                    !Settings.Module.InTheMiddleOfRebase() &&
                    (process != null && !process.ErrorOccurred()))
                {
                    if (!Fetch.Checked && File.Exists(Settings.WorkingDir + ".gitmodules"))
                    {
                        if (!IsSubmodulesIntialized() && AskIfSubmodulesShouldBeInitialized())
                        {
                            GitUICommands.Instance.StartInitSubmodulesRecursiveDialog(this);
                        }
                    }

                    return(true);
                }

                // Rebase failed -> special 'rebase' merge conflict
                if (Rebase.Checked && Settings.Module.InTheMiddleOfRebase())
                {
                    GitUICommands.Instance.StartRebaseDialog(null);
                    if (!Settings.Module.InTheMiddleOfConflictedMerge() &&
                        !Settings.Module.InTheMiddleOfRebase())
                    {
                        return(true);
                    }
                }
                else
                {
                    MergeConflictHandler.HandleMergeConflicts(this);
                    if (!Settings.Module.InTheMiddleOfConflictedMerge() &&
                        !Settings.Module.InTheMiddleOfRebase())
                    {
                        return(true);
                    }
                }

                if (!AutoStash.Checked || !stashed || Settings.Module.InTheMiddleOfConflictedMerge() ||
                    Settings.Module.InTheMiddleOfRebase())
                {
                    return(true);
                }
            }
            finally
            {
                if (stashed &&
                    process != null &&
                    !process.ErrorOccurred() &&
                    !Settings.Module.InTheMiddleOfConflictedMerge() &&
                    !Settings.Module.InTheMiddleOfRebase() &&
                    MessageBox.Show(this, _applyShashedItemsAgain.Text, _applyShashedItemsAgainCaption.Text, MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    new FormProcess("stash pop").ShowDialog(this);
                    MergeConflictHandler.HandleMergeConflicts(this);
                }

                ScriptManager.RunEventScripts(ScriptEvent.AfterPull);
            }

            return(false);
        }
Exemple #16
0
 private void Checkout_Click(object sender, EventArgs e)
 {
     GitUICommands.Instance.StartCheckoutBranchDialog(this);
     MergeConflictHandler.HandleMergeConflicts(this);
     RevisionGrid.RefreshRevisions();
 }