ShowDialog() public static method

public static ShowDialog ( GitUI.GitModuleForm owner, string arguments ) : bool
owner GitUI.GitModuleForm
arguments string
return bool
Ejemplo n.º 1
0
 private void SynchronizeSubmoduleClick(object sender, EventArgs e)
 {
     Cursor.Current = Cursors.WaitCursor;
     var process = new FormProcess(GitCommands.GitCommands.SubmoduleSyncCmd(SubModuleName.Text));
     process.ShowDialog();
     Initialize();
 }
Ejemplo n.º 2
0
 private void InitSubmodule_Click(object sender, EventArgs e)
 {
     Cursor.Current = Cursors.WaitCursor;
     FormProcess process = new FormProcess(GitCommands.GitCommands.SubmoduleInitCmd(SubModuleName.Text));
     process.ShowDialog();
     Initialize();
 }
Ejemplo n.º 3
0
        private void OkClick(object sender, EventArgs e)
        {
            try
            {
                //Get a localbranch name
                var remoteName = GitCommands.GitCommands.GetRemoteName(Branches.Text, GitCommands.GitCommands.GetRemotes());
                var localBranchName = Branches.Text.Substring(remoteName.Length + 1);

                var command = "checkout";
                if (Remotebranch.Checked)
                {
                    var result =
                        MessageBox.Show(
                            "You choose to checkout a remote branch." + Environment.NewLine + Environment.NewLine +
                            "Do you want create a local branch with the name '" + localBranchName + "'" +
                            Environment.NewLine + "that track's this remote branch?", "Checkout branch",
                            MessageBoxButtons.YesNo);
                    if (result == DialogResult.Yes)
                        command += string.Format(" -b {0}", localBranchName);
                }

                if (Force.Checked)
                    command += " --force";
                command += " \"" + Branches.Text + "\"";
                var form = new FormProcess(command);
                form.ShowDialog();
                if (!form.ErrorOccured())
                    Close();
            }
            catch(Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 4
0
 public static bool ShowDialog(IWin32Window owner, string process, string arguments, string aWorkingDirectory, string input, bool useDialogSettings)
 {
     using (var formProcess = new FormProcess(process, arguments, aWorkingDirectory, input, useDialogSettings))
     {
         formProcess.ShowDialog(owner);
         return !formProcess.ErrorOccurred();
     }
 }
 private void Cleanup_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Are you sure you want to cleanup the repository?", "Cleanup", MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         FormProcess form = new FormProcess(GitCommandHelpers.CleanUpCmd(false, RemoveDirectories.Checked, RemoveNonIgnored.Checked, RemoveIngnored.Checked));
         form.ShowDialog();
         PreviewOutput.Text = form.OutputString.ToString();
     }
 }
 private void Cleanup_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show(_reallyCleanupQuestion.Text, _reallyCleanupQuestionCaption.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         var form = new FormProcess(GitCommandHelpers.CleanUpCmd(false, RemoveDirectories.Checked, RemoveNonIgnored.Checked, RemoveIngnored.Checked));
         form.ShowDialog();
         PreviewOutput.Text = form.OutputString.ToString();
     }
 }
Ejemplo n.º 7
0
        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();

            var wasConflict = MergeConflictHandler.HandleMergeConflicts();

            if (!process.ErrorOccurred() || wasConflict)
                Close();
        }
Ejemplo n.º 8
0
        private void OkClick(object sender, EventArgs e)
        {
            var process = new FormProcess(GitCommands.GitCommands.MergeBranchCmd(Branches.Text, fastForward.Checked));
            process.ShowDialog();

            MergeConflictHandler.HandleMergeConflicts();

            if (!process.ErrorOccured())
                Close();
        }
Ejemplo n.º 9
0
 private void BisectRange( string startRevision, string endRevision )
 {
     var command = GitCommandHelpers.MarkRevisionBisectCmd(true, startRevision);
     var form = new FormProcess(command);
     form.ShowDialog(this);
     if (form.ErrorOccurred)
         return;
     command = GitCommandHelpers.MarkRevisionBisectCmd(false, endRevision);
     form = new FormProcess(command);
     form.ShowDialog(this);
 }
Ejemplo n.º 10
0
        private void OkClick(object sender, EventArgs e)
        {
            var branchName = BranchNameTextBox.Text.Trim();

            if (branchName.IsNullOrWhiteSpace())
            {// ""
                MessageBox.Show(_branchNameIsEmpty.Text, Text);
                DialogResult = DialogResult.None;
                return;
            }
            if (!Module.CheckBranchFormat(branchName))
            {// invalid branch name
                MessageBox.Show(string.Format(_branchNameIsNotValud.Text, branchName), Text);
                DialogResult = DialogResult.None;
                return;
            }
            try
            {
                if (Revision == null && _startPoint == null)
                {
                    MessageBox.Show(this, _noRevisionSelected.Text, Text);
                    return;
                }

                var branchCmd = GitCommandHelpers.BranchCmd(branchName, _startPoint ?? Revision.Guid,
                                                            CheckoutAfterCreate.Checked);
                FormProcess.ShowDialog(this, branchCmd);

                string cmd;
                if (Orphan.Checked)
                {
                    cmd = GitCommandHelpers.CreateOrphanCmd(branchName, Revision.Guid);
                }
                else
                {
                    cmd = GitCommandHelpers.BranchCmd(branchName, Revision.Guid,
                                                      CheckoutAfterCreate.Checked);
                }

                bool wasSuccessFul = FormProcess.ShowDialog(this, cmd);
                if (Orphan.Checked && wasSuccessFul && ClearOrphan.Checked)
                {// orphan AND orphan creation success AND clear
                    cmd = GitCommandHelpers.RemoveCmd();
                    FormProcess.ShowDialog(this, cmd);
                }

                DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 11
0
 private void ShowProcessDialogBox(IWin32Window owner, string source, FormProcess process)
 {
     if (process == null)
     {
         return;
     }
     if (!PullAll())
     {
         process.Remote = source;
     }
     process.ShowDialog(owner);
     ErrorOccurred = process.ErrorOccurred();
 }
Ejemplo n.º 12
0
        private void BisectRange(string startRevision, string endRevision)
        {
            var command = GitCommandHelpers.MarkRevisionBisectCmd(true, startRevision);
            var form    = new FormProcess(command);

            form.ShowDialog(this);
            if (!form.ErrorOccurred())
            {
                command = GitCommandHelpers.MarkRevisionBisectCmd(false, endRevision);
                form    = new FormProcess(command);
                form.ShowDialog(this);
            }
        }
Ejemplo n.º 13
0
        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();
            }
        }
Ejemplo n.º 14
0
        private void BisectRange(string startRevision, string endRevision)
        {
            var command = GitCommandHelpers.ContinueBisectCmd(GitBisectOption.Good, startRevision);
            using (var form = new FormProcess(command))
            {
                form.ShowDialog(this);
                if (form.ErrorOccurred())
                    return;
            }

            command = GitCommandHelpers.ContinueBisectCmd(GitBisectOption.Bad, endRevision);
            FormProcess.ShowDialog(this, command);
        }
Ejemplo n.º 15
0
        private void RemoveClick(object sender, EventArgs e)
        {
            if (MessageBox.Show(this,
                                _removeDanglingObjectsQuestion.Text,
                                _removeDanglingObjectsCaption.Text,
                                MessageBoxButtons.YesNo) != DialogResult.Yes)
            {
                return;
            }

            FormProcess.ShowDialog(this, "prune");
            UpdateLostObjects();
        }
Ejemplo n.º 16
0
        public bool StartBatchFileProcessDialog(object owner, string batchFile)
        {
            string tempFileName = Path.ChangeExtension(Path.GetTempFileName(), ".cmd");

            using (var writer = new StreamWriter(tempFileName))
            {
                writer.WriteLine("@prompt $G");
                writer.Write(batchFile);
            }
            FormProcess.ShowDialog(owner as IWin32Window, "cmd.exe", "/C \"" + tempFileName + "\"");
            File.Delete(tempFileName);
            return(true);
        }
Ejemplo n.º 17
0
        private void BisectRange(string startRevision, string endRevision)
        {
            var command       = GitCommandHelpers.ContinueBisectCmd(GitBisectOption.Good, startRevision);
            var errorOccurred = !FormProcess.ShowDialog(this, command);

            if (errorOccurred)
            {
                return;
            }

            command = GitCommandHelpers.ContinueBisectCmd(GitBisectOption.Bad, endRevision);
            FormProcess.ShowDialog(this, command);
        }
Ejemplo n.º 18
0
        private void okButton_Click(object sender, EventArgs e)
        {
            try
            {
                var dirTo = this._NO_TRANSLATE_destinationComboBox.Text;
                if (!dirTo.EndsWith(Settings.PathSeparator.ToString()) && !dirTo.EndsWith(Settings.PathSeparatorWrong.ToString()))
                {
                    dirTo += Settings.PathSeparator.ToString();
                }

                dirTo += this._NO_TRANSLATE_subdirectoryTextBox.Text;

                //Repositories.RepositoryHistory.AddMostRecentRepository(_NO_TRANSLATE_From.Text);
                //Repositories.RepositoryHistory.AddMostRecentRepository(dirTo);

                if (!Directory.Exists(dirTo))
                {
                    Directory.CreateDirectory(dirTo);
                }

                var  authorsfile      = this._NO_TRANSLATE_authorsFileTextBox.Text;
                bool resetauthorsfile = false;
                if (authorsfile != null && authorsfile.Trim().Length != 0 && !File.Exists(authorsfile.Trim()) && !(resetauthorsfile = AskContinutWithoutAuthorsFile(authorsfile)))
                {
                    return;
                }
                if (resetauthorsfile)
                {
                    authorsfile = null;
                }
                var errorOccurred = !FormProcess.ShowDialog(this, Settings.GitCommand,
                                                            GitSvnCommandHelpers.CloneCmd(_NO_TRANSLATE_svnRepositoryComboBox.Text, dirTo, authorsfile));

                if (errorOccurred || Module.InTheMiddleOfPatch())
                {
                    return;
                }
                if (ShowInTaskbar == false && AskIfNewRepositoryShouldBeOpened(dirTo))
                {
                    if (GitModuleChanged != null)
                    {
                        GitModuleChanged(new GitModule(dirTo));
                    }
                }
                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, "Exception: " + ex.Message, "Clone failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 19
0
        private void OkClick(object sender, EventArgs e)
        {
            try
            {
                var command = "checkout";
                if (Remotebranch.Checked)
                {
                    //Get a localbranch name
                    var remoteName      = GitCommandHelpers.GetRemoteName(Branches.Text, GitCommandHelpers.GetRemotes());
                    var localBranchName = Branches.Text.Substring(remoteName.Length + 1);

                    MessageBoxIcon icon = MessageBoxIcon.Question;

                    //try to determine the 'best' name for a local branch, check if the local
                    //name for the remote branch is already used
                    if (LocalBranchExists(localBranchName))
                    {
                        localBranchName = string.Concat(remoteName, "_", localBranchName);
                        icon            = MessageBoxIcon.Exclamation;
                    }

                    var result = MessageBox.Show(string.Format(trackRemoteBranch.Text, localBranchName), trackRemoteBranchCaption.Text, MessageBoxButtons.YesNoCancel, icon);

                    if (result == DialogResult.Cancel)
                    {
                        return;
                    }

                    if (result == DialogResult.Yes)
                    {
                        command += string.Format(" -b {0}", localBranchName);
                    }
                }

                if (Force.Checked)
                {
                    command += " --force";
                }
                command += " \"" + Branches.Text + "\"";
                var form = new FormProcess(command);
                form.ShowDialog();
                if (!form.ErrorOccurred())
                {
                    Close();
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 20
0
        private void Add_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(Directory.Text) || string.IsNullOrEmpty(LocalPath.Text))
            {
                MessageBox.Show("A remote path and local path are required");
                return;
            }

            Cursor.Current = Cursors.WaitCursor;
            FormProcess formProcess = new FormProcess(GitCommands.GitCommands.AddSubmoduleCmd(Directory.Text, LocalPath.Text, Branch.Text));
            formProcess.ShowDialog();

            Close();
        }
Ejemplo n.º 21
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();
            }
        }
Ejemplo n.º 22
0
        private void AbortClick(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            FormProcess.ShowDialog(this, GitCommandHelpers.AbortRebaseCmd());

            if (!Module.InTheMiddleOfRebase())
            {
                Close();
            }

            EnableButtons();
            patchGrid1.Initialize();
            Cursor.Current = Cursors.Default;
        }
Ejemplo n.º 23
0
        public bool StartUpdateSubmodulesDialog()
        {
            if (!InvokeEvent(PreUpdateSubmodules))
            {
                return(true);
            }

            var process = new FormProcess(GitCommandHelpers.SubmoduleUpdateCmd(""));

            process.ShowDialog();

            InvokeEvent(PostUpdateSubmodules);

            return(true);
        }
Ejemplo n.º 24
0
        private void Start_Click(object sender, EventArgs e)
        {
            FormProcess.ShowDialog(this, GitCommandHelpers.StartBisectCmd());
            UpdateButtonsState();

            IList <GitRevision> revisions = _revisionGrid.GetSelectedRevisions();

            if (revisions.Count > 1)
            {
                if (MessageBox.Show(this, _bisectStart.Text, Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    BisectRange(revisions.First().Guid, revisions.Last().Guid);
                    Close();
                }
            }
        }
Ejemplo n.º 25
0
        private void AddClick(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(Directory.Text) || string.IsNullOrEmpty(LocalPath.Text))
            {
                MessageBox.Show(this, _remoteAndLocalPathRequired.Text, Text);
                return;
            }

            Cursor.Current = Cursors.WaitCursor;
            var addSubmoduleCmd = GitCommandHelpers.AddSubmoduleCmd(Directory.Text, LocalPath.Text, Branch.Text, chkForce.Checked);

            FormProcess.ShowDialog(this, addSubmoduleCmd);

            Close();
            Cursor.Current = Cursors.Default;
        }
Ejemplo n.º 26
0
        private void button1_Click(object sender, EventArgs e)
        {
            string options = "";

            if (Unreachable.Checked)
                options += " --unreachable";

            if (FullCheck.Checked)
                options += " --full";

            if (NoReflogs.Checked)
                options += " --no-reflogs";

            FormProcess process = new FormProcess("fsck-objects --lost-found" + options);
            process.ShowDialog();
            FormVerify_Shown(null, null);
        }
Ejemplo n.º 27
0
        private void OkClick(object sender, EventArgs e)
        {
            try
            {
                var dirTo = _NO_TRANSLATE_To.Text;
                if (!dirTo.EndsWith(Settings.PathSeparator.ToString()) && !dirTo.EndsWith(Settings.PathSeparatorWrong.ToString()))
                {
                    dirTo += Settings.PathSeparator.ToString();
                }

                dirTo += _NO_TRANSLATE_NewDirectory.Text;

                Repositories.RepositoryHistory.AddMostRecentRepository(_NO_TRANSLATE_From.Text);
                Repositories.RepositoryHistory.AddMostRecentRepository(dirTo);


                var fromProcess =
                    new FormProcess(Settings.GitCommand,
                                    GitCommandHelpers.CloneCmd(_NO_TRANSLATE_From.Text, dirTo,
                                                               CentralRepository.Checked, Branches.Text, null));
                fromProcess.SetUrlTryingToConnect(_NO_TRANSLATE_From.Text);
                fromProcess.ShowDialog();

                if (fromProcess.ErrorOccurred() || GitCommandHelpers.InTheMiddleOfPatch())
                {
                    return;
                }

                if (ShowInTaskbar == false && AskIfNewRepositoryShouldBeOpened(dirTo))
                {
                    Settings.WorkingDir = dirTo;

                    if (File.Exists(Settings.WorkingDir + ".gitmodules") &&
                        AskIfSubmodulesShouldBeInitialized())
                    {
                        InitSubmodules();
                    }
                }
                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, "Exception: " + ex.Message, "Clone failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 28
0
        public bool StartSyncSubmodulesDialog(IWin32Window owner)
        {
            if (!RequiresValidWorkingDir(owner))
            {
                return(false);
            }

            if (!InvokeEvent(owner, PreSyncSubmodules))
            {
                return(true);
            }

            FormProcess.ShowDialog(owner, GitCommandHelpers.SubmoduleSyncCmd(""));

            InvokeEvent(owner, PostSyncSubmodules);

            return(true);
        }
Ejemplo n.º 29
0
        public bool StartSvnFetchDialog(IWin32Window owner)
        {
            if (!RequiredValidGitSvnWorikingDir(owner))
            {
                return(false);
            }

            if (!InvokeEvent(owner, PreSvnFetch))
            {
                return(true);
            }

            FormProcess.ShowDialog(owner, Settings.GitCommand, GitSvnCommandHelpers.FetchCmd());

            InvokeEvent(owner, PostSvnFetch);

            return(true);
        }
Ejemplo n.º 30
0
        private void Ok_Click(object sender, EventArgs e)
        {
            try
            {
                if (RevisionGrid.GetSelectedRevisions().Count != 1)
                {
                    MessageBox.Show(this, _selectOneRevision.Text, _branchCaption.Text);
                    return;
                }

                string cmd = GitCommandHelpers.BranchCmd(BName.Text, RevisionGrid.GetSelectedRevisions()[0].Guid, CheckoutAfterCreate.Checked);
                FormProcess.ShowDialog(this, cmd);

                Close();
            }
            catch
            {
            }
        }
Ejemplo n.º 31
0
        private void Save_Click(object sender, EventArgs e)
        {
            if (revisionGrid1.GetSelectedRevisions().Count != 1)
            {
                MessageBox.Show(this, _noRevisionSelectedMsgBox.Text, Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            string revision = revisionGrid1.GetSelectedRevisions()[0].TreeGuid;

            using (var saveFileDialog = new SaveFileDialog {
                Filter = _saveFileDialogFilter.Text + "|*.zip", Title = _saveFileDialogCaption.Text
            })
            {
                if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
                {
                    FormProcess.ShowDialog(this, "archive --format=zip " + revision + " --output \"" + saveFileDialog.FileName + "\"");
                    Close();
                }
            }
        }
Ejemplo n.º 32
0
        public bool StartInitSubmodulesDialog(IWin32Window owner)
        {
            if (!RequiresValidWorkingDir())
            {
                return(false);
            }

            if (!InvokeEvent(PreInitSubmodules))
            {
                return(true);
            }

            var process = new FormProcess(GitCommandHelpers.SubmoduleInitCmd(""));

            process.ShowDialog(owner);

            InvokeEvent(PostInitSubmodules);

            return(true);
        }
Ejemplo n.º 33
0
        public bool StartSvnRebaseDialog(IWin32Window owner)
        {
            if (!RequiredValidGitSvnWorikingDir())
            {
                return(false);
            }

            if (!InvokeEvent(PreSvnRebase))
            {
                return(true);
            }

            var fromProcess = new FormProcess(Settings.GitCommand, GitSvnCommandHelpers.RebaseCmd());

            fromProcess.ShowDialog(owner);

            InvokeEvent(PostSvnRebase);

            return(true);
        }
        private void OkClick(object sender, EventArgs e)
        {
            try
            {
                Settings.MergeAtCheckout            = rbMerge.Checked;
                Settings.CreateLocalBranchForRemote = rbCreateBranch.Checked;
                var command = "checkout";

                //Get a localbranch name
                if (rbCreateBranch.Checked)
                {
                    command += string.Format(" -b {0}", _newLocalBranchName);
                }
                else if (rbResetBranch.Checked)
                {
                    command += string.Format(" -B {0}", _localBranchName);
                }

                if (rbMerge.Checked)
                {
                    command += " -m";
                }

                if (rbReset.Checked)
                {
                    command += " --force";
                }

                command += " \"" + _branch + "\"";
                var form = new FormProcess(command);
                form.ShowDialog(this);
                if (!form.ErrorOccurred())
                {
                    Close();
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 35
0
        public bool StartUpdateSubmodulesRecursiveDialog()
        {
            if (!RequiresValidWorkingDir())
            {
                return(false);
            }

            if (!InvokeEvent(PreUpdateSubmodulesRecursive))
            {
                return(true);
            }

            var process = new FormProcess(GitCommandHelpers.SubmoduleUpdateCmd(""));

            process.ShowDialog();
            UpdateSubmodulesRecursive();

            InvokeEvent(PostUpdateSubmodulesRecursive);

            return(true);
        }
Ejemplo n.º 36
0
        public bool StartSyncSubmodulesRecursiveDialog(IWin32Window owner)
        {
            if (!RequiresValidWorkingDir())
            {
                return(false);
            }

            if (!InvokeEvent(PreSyncSubmodulesRecursive))
            {
                return(true);
            }

            var process = new FormProcess(GitCommandHelpers.SubmoduleSyncCmd(""));

            process.ShowDialog(owner);
            ForEachSubmodulesRecursive(GitCommandHelpers.SubmoduleSyncCmd(""));

            InvokeEvent(PostSyncSubmodulesRecursive);

            return(true);
        }
Ejemplo n.º 37
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();
        }
        private void OkClick(object sender, EventArgs e)
        {
            try
            {
                Settings.AutoStash = cbAutoStash.Checked;
                var command = "checkout";

                //Get a localbranch name
                if (rbCreateBranch.Checked)
                {
                    command += string.Format(" -b {0}", _newLocalBranchName);
                }
                else if (rbResetBranch.Checked)
                {
                    command += string.Format(" -B {0}", _localBranchName);
                }

                command += " \"" + _branch + "\"";
                bool stashed = CalculateStashedValue();
                var  form    = new FormProcess(command);
                form.ShowDialog(this);
                if (!form.ErrorOccurred() && stashed)
                {
                    bool messageBoxResult = MessageBox.Show(this, _applyShashedItemsAgain.Text,
                                                            _applyShashedItemsAgainCaption.Text, MessageBoxButtons.YesNo) == DialogResult.Yes;
                    if (messageBoxResult)
                    {
                        new FormProcess("stash pop").ShowDialog(this);
                    }
                }
                if (!form.ErrorOccurred())
                {
                    Close();
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 39
0
        private void OkClick(object sender, EventArgs e)
        {
            try
            {
                if (RevisionGrid.GetSelectedRevisions().Count != 1)
                {
                    MessageBox.Show(this, _noRevisionSelectedMsgBox.Text, _noRevisionSelectedMsgBoxCaption.Text);
                    return;
                }

                string command = GitCommandHelpers.CheckoutCmd(RevisionGrid.GetSelectedRevisions()[0].Guid,
                                                               Force.Checked ? LocalChangesAction.Reset : 0);

                FormProcess.ShowDialog(this, command);

                Close();
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 40
0
        private void ClearClick(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            if (Settings.StashConfirmDropShow)
            {
                DialogResult res = PSTaskDialog.cTaskDialog.MessageBox(
                    this,
                    stashDropConfirmTitle.Text,
                    cannotBeUndone.Text,
                    areYouSure.Text,
                    "",
                    "",
                    dontShowAgain.Text,
                    PSTaskDialog.eTaskDialogButtons.OKCancel,
                    PSTaskDialog.eSysIcons.Information,
                    PSTaskDialog.eSysIcons.Information);
                if (res == DialogResult.OK)
                {
                    FormProcess.ShowDialog(this, string.Format("stash drop \"{0}\"", Stashes.Text));
                    NeedRefresh = true;
                    Initialize();
                    Cursor.Current = Cursors.Default;
                }

                if (PSTaskDialog.cTaskDialog.VerificationChecked)
                {
                    Settings.StashConfirmDropShow = false;
                }
            }
            else
            {
                FormProcess.ShowDialog(this, string.Format("stash drop \"{0}\"", Stashes.Text));
                NeedRefresh = true;
                Initialize();
                Cursor.Current = Cursors.Default;
            }
        }
Ejemplo n.º 41
0
        private void LoadLostObjects()
        {
            Cursor.Current = Cursors.WaitCursor;

            var options = GetOptions();

            var process = new FormProcess("fsck-objects" + options);

            process.ShowDialog();

            var warningList = new List <string>();

            foreach (var warning in process.OutputString.ToString().Split('\n', '\r'))
            {
                if (!string.IsNullOrEmpty(warning) && (!ShowOnlyCommits.Checked || warning.Contains("commit")))
                {
                    warningList.Add(ExtendWarning(warning));
                }
            }

            Warnings.DataSource = warningList;
            Cursor.Current      = Cursors.Default;
        }
Ejemplo n.º 42
0
        private void OkClick(object sender, EventArgs e)
        {
            try
            {
                if (Revision == null)
                {
                    MessageBox.Show(_noRevisionSelected.Text, Text);
                    return;
                }
                var branchCmd = GitCommandHelpers.BranchCmd(BranchNameTextBox.Text, Revision.Guid,
                                                                  CheckoutAfterCreate.Checked);
                using (var formProcess = new FormProcess(branchCmd))
                {
                    formProcess.ShowDialog();
                }

                DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 43
0
        private void OkClick(object sender, EventArgs e)
        {
            try
            {
                if (Revision == null)
                {
                    MessageBox.Show(this, _noRevisionSelected.Text, Text);
                    return;
                }
                var branchCmd = GitCommandHelpers.BranchCmd(BranchNameTextBox.Text, Revision.Guid,
                                                            CheckoutAfterCreate.Checked);
                using (var formProcess = new FormProcess(branchCmd))
                {
                    formProcess.ShowDialog(this);
                }

                DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 44
0
        private static void InitializeSubmodulesRecursive()
        {
            string oldworkingdir = Settings.WorkingDir;

            foreach (GitSubmodule submodule in (new GitCommands.GitCommands()).GetSubmodules())
            {
                if (!string.IsNullOrEmpty(submodule.LocalPath))
                {
                    Settings.WorkingDir = oldworkingdir + submodule.LocalPath;

                    if (Settings.WorkingDir != oldworkingdir && File.Exists(GitCommands.Settings.WorkingDir + ".gitmodules"))
                    {
                        FormProcess process = new FormProcess(GitCommands.GitCommands.SubmoduleInitCmd(""));
                        process.ShowDialog();

                        InitializeSubmodulesRecursive();
                    }

                    Settings.WorkingDir = oldworkingdir;
                }
            }

            Settings.WorkingDir = oldworkingdir;
        }
Ejemplo n.º 45
0
 private static void InitSubmodules()
 {
     var process = new FormProcess(GitCommandHelpers.SubmoduleInitCmd(""));
     process.ShowDialog();
     InitializeSubmodulesRecursive();
 }
Ejemplo n.º 46
0
        private void OkClick(object sender, EventArgs e)
        {
            try
            {
                var dirTo = _NO_TRANSLATE_To.Text;
                if (!dirTo.EndsWith(Settings.PathSeparator.ToString()) && !dirTo.EndsWith(Settings.PathSeparatorWrong.ToString()))
                    dirTo += Settings.PathSeparator.ToString();

                dirTo += _NO_TRANSLATE_NewDirectory.Text;

                Repositories.RepositoryHistory.AddMostRecentRepository(_NO_TRANSLATE_From.Text);
                Repositories.RepositoryHistory.AddMostRecentRepository(dirTo);

                var fromProcess =
                    new FormProcess(Settings.GitCommand,
                                    GitCommandHelpers.CloneCmd(_NO_TRANSLATE_From.Text, dirTo,
                                                                     CentralRepository.Checked, null));
                fromProcess.ShowDialog();

                if (fromProcess.ErrorOccurred() || GitCommandHelpers.InTheMiddleOfPatch())
                    return;

                if (ShowInTaskbar == false && AskIfNewRepositoryShouldBeOpened(dirTo))
                {
                    Settings.WorkingDir = dirTo;

                    if (File.Exists(Settings.WorkingDir + ".gitmodules") &&
                        AskIfSubmodulesShouldBeInitialized())
                        InitSubmodules();
                }
                Close();
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
        private void OkClick(object sender, EventArgs e)
        {
            try
            {
                Settings.AutoStash = cbAutoStash.Checked;
                var command = "checkout";

                //Get a localbranch name
                if (rbCreateBranch.Checked)
                    command += string.Format(" -b {0}", _newLocalBranchName);
                else if (rbResetBranch.Checked)
                    command += string.Format(" -B {0}", _localBranchName);

                command += " \"" + _branch + "\"";
                bool stashed = CalculateStashedValue();
                var form = new FormProcess(command);
                form.ShowDialog(this);
                if (!form.ErrorOccurred() && stashed)
                {
                    bool messageBoxResult = MessageBox.Show(this, _applyShashedItemsAgain.Text,
                        _applyShashedItemsAgainCaption.Text, MessageBoxButtons.YesNo) == DialogResult.Yes;
                    if (messageBoxResult)
                        new FormProcess("stash pop").ShowDialog(this);
                }
                if (!form.ErrorOccurred())
                    Close();
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 48
0
 public bool StartGitCommandProcessDialog(IWin32Window owner, string arguments)
 {
     var process = new FormProcess(arguments);
     process.ShowDialog(owner);
     return true;
 }
Ejemplo n.º 49
0
 public bool StartCommandLineProcessDialog(object owner, string command, string arguments)
 {
     var process = new FormProcess(command, arguments);
     process.ShowDialog(owner as IWin32Window);
     return true;
 }
Ejemplo n.º 50
0
 public bool StartBatchFileProcessDialog(object owner, string batchFile)
 {
     string tempFileName = Path.ChangeExtension(Path.GetTempFileName(), ".cmd");
     using (var writer = new StreamWriter(tempFileName))
     {
         writer.WriteLine("@prompt $G");
         writer.Write(batchFile);
     }
     var process = new FormProcess("cmd.exe", "/C \"" + tempFileName + "\"");
     process.ShowDialog(owner as IWin32Window);
     File.Delete(tempFileName);
     return true;
 }
Ejemplo n.º 51
0
        public bool StartUpdateSubmodulesDialog(IWin32Window owner)
        {
            if (!RequiresValidWorkingDir())
                return false;

            if (!InvokeEvent(owner, PreUpdateSubmodules))
                return true;

            var process = new FormProcess(GitCommandHelpers.SubmoduleUpdateCmd(""));
            process.ShowDialog(owner);

            InvokeEvent(owner, PostUpdateSubmodules);

            return true;
        }
Ejemplo n.º 52
0
        public bool StartSvnRebaseDialog(IWin32Window owner)
        {
            if (!RequiredValidGitSvnWorikingDir())
                return false;

            if (!InvokeEvent(owner, PreSvnRebase))
                return true;

            var fromProcess = new FormProcess(Settings.GitCommand, GitSvnCommandHelpers.RebaseCmd());
            fromProcess.ShowDialog(owner);

            InvokeEvent(owner, PostSvnRebase);

            return true;
        }
Ejemplo n.º 53
0
        public bool StartInitSubmodulesRecursiveDialog(IWin32Window owner)
        {
            if (!RequiresValidWorkingDir())
                return false;

            if (!InvokeEvent(PreInitSubmodulesRecursive))
                return true;

            var process = new FormProcess(GitCommandHelpers.SubmoduleInitCmd(""));
            process.ShowDialog(owner);
            ForEachSubmodulesRecursive(GitCommandHelpers.SubmoduleInitCmd(""));

            InvokeEvent(PostInitSubmodulesRecursive);

            return true;
        }
Ejemplo n.º 54
0
        private static void ForEachSubmodulesRecursive(IWin32Window owner, string cmd)
        {
            var oldworkingdir = Settings.WorkingDir;

            foreach (GitSubmodule submodule in (new GitCommandsInstance()).GetSubmodules())
            {
                if (string.IsNullOrEmpty(submodule.LocalPath))
                    continue;

                Settings.WorkingDir = oldworkingdir + submodule.LocalPath;

                if (Settings.WorkingDir != oldworkingdir && File.Exists(Settings.WorkingDir + ".gitmodules"))
                {
                    var process = new FormProcess(cmd);
                    process.ShowDialog(owner);

                    ForEachSubmodulesRecursive(owner, cmd);
                }

                Settings.WorkingDir = oldworkingdir;
            }

            Settings.WorkingDir = oldworkingdir;
        }
Ejemplo n.º 55
0
 public static void ShowDialog(IWin32Window owner, string arguments, bool useDialogSettings)
 {
     using (var formProcess = new FormProcess(arguments, useDialogSettings))
     {
         formProcess.ShowDialog(owner);
     }
 }
Ejemplo n.º 56
0
        private void PushClick(object sender, EventArgs e)
        {
            if (PullFromUrl.Checked && string.IsNullOrEmpty(PushDestination.Text))
            {
                MessageBox.Show(_selectDestinationDirectory.Text);
                return;
            }
            if (PullFromRemote.Checked && string.IsNullOrEmpty(Remotes.Text))
            {
                MessageBox.Show(_selectRemote.Text);
                return;
            }
            if (TabControlTagBranch.SelectedTab == TagTab && string.IsNullOrEmpty(TagComboBox.Text) &&
                !PushAllTags.Checked)
            {
                MessageBox.Show(_selectTag.Text);
                return;
            }

            //Extra check if the branch is already known to the remote, give a warning when not.
            //This is not possible when the remote is an URL, but this is ok since most users push to
            //known remotes anyway.
            if (TabControlTagBranch.SelectedTab == BranchTab && PullFromRemote.Checked)
            {
                //The current branch is not known by the remote (as far as we now since we are disconnected....)
                if (!GitCommands.GitCommands.GetBranches(true, Remotes.Text).Contains(RemoteBranch.Text))
                    //Ask if this is what the user wants
                    if (MessageBox.Show(_branchNewForRemote.Text, _pushCaption.Text, MessageBoxButtons.YesNo) ==
                        DialogResult.No)
                        return;
            }

            Repositories.RepositoryHistory.AddMostRecentRepository(PushDestination.Text);

            var remote = "";
            string destination;
            if (PullFromUrl.Checked)
            {
                destination = PushDestination.Text;
            }
            else
            {
                if (GitCommands.GitCommands.Plink())
                {
                    if (!File.Exists(Settings.Pageant))
                        MessageBox.Show(_cannotLoadPutty.Text, PuttyText);
                    else
                        GitCommands.GitCommands.StartPageantForRemote(Remotes.Text);
                }

                destination = Remotes.Text;
                remote = Remotes.Text.Trim();
            }

            string pushCmd;
            if (TabControlTagBranch.SelectedTab == BranchTab)
                pushCmd = GitCommands.GitCommands.PushCmd(destination, Branch.Text, RemoteBranch.Text,
                                                          PushAllBranches.Checked, ForcePushBranches.Checked);
            else
                pushCmd = GitCommands.GitCommands.PushTagCmd(destination, TagComboBox.Text, PushAllTags.Checked,
                                                             ForcePushBranches.Checked);
            var form = new FormProcess(pushCmd)
                       {
                           Remote = remote,
                           Text = string.Format(_pushToCaption.Text, destination)
                       };

            form.ShowDialog();

            if (!GitCommands.GitCommands.InTheMiddleOfConflictedMerge() &&
                !GitCommands.GitCommands.InTheMiddleOfRebase() && !form.ErrorOccured())
                Close();
        }
Ejemplo n.º 57
0
        void BranchSelectToolStripItem_Click(object sender, EventArgs e)
        {
            bool needRefresh;
            bool force;
            if (!GitUICommands.Instance.CheckForDirtyDir(this, out needRefresh, out force))
            {
                var toolStripItem = (ToolStripItem)sender;
                string args = force ? "-f": null;

                var command = "checkout".Join(" ", args).Join(" ", string.Format("\"{0}\"", toolStripItem.Text));
                var form = new FormProcess(command);
                form.ShowDialog(this);
                needRefresh = true;
            }

            if (needRefresh)
                Initialize();
        }
Ejemplo n.º 58
0
 private void ShowProcessDialogBox(IWin32Window owner, string source, FormProcess process)
 {
     if (process == null)
         return;
     if (!IsPullAll())
         process.Remote = source;
     process.ShowDialog(owner);
     ErrorOccurred = process.ErrorOccurred();
 }
Ejemplo n.º 59
0
        private void DoCommit(bool amend, bool push)
        {
            if (GitCommandHelpers.InTheMiddleOfConflictedMerge())
            {
                MessageBox.Show(_mergeConflicts.Text, _mergeConflictsCaption.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (string.IsNullOrEmpty(Message.Text))
            {
                MessageBox.Show(_enterCommitMessage.Text, _enterCommitMessageCaption.Text, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return;
            }

            if (GitCommandHelpers.GetSelectedBranch().Equals("(no branch)", StringComparison.OrdinalIgnoreCase) &&
                MessageBox.Show(_notOnBranch.Text, _notOnBranchCaption.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.No)
                return;

            try
            {
                SetCommitMessageFromTextBox(Message.Text);

                var form = new FormProcess(GitCommandHelpers.CommitCmd(amend, toolAuthor.Text));
                form.ShowDialog();

                NeedRefresh = true;

                if (form.ErrorOccurred())
                    return;

                Message.Text = string.Empty;

                if (push)
                {
                    GitUICommands.Instance.StartPushDialog(true);
                }

                if (Settings.CloseCommitDialogAfterCommit)
                {
                    Close();
                    return;
                }

                if (Unstaged.GitItemStatuses.Any(gitItemStatus => gitItemStatus.IsTracked))
                {
                    InitializedStaged();
                    return;
                }

                if (Settings.CloseCommitDialogAfterLastCommit)
                    Close();
                else
                    InitializedStaged();
            }
            catch (Exception e)
            {
                MessageBox.Show(string.Format("Exception: {0}", e.Message));
            }
        }
Ejemplo n.º 60
0
        private void OkClick(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            if (string.IsNullOrEmpty(Branches.Text))
            {
                MessageBox.Show(_noBranchSelectedText.Text);
                return;
            }

            var form = new FormProcess(GitCommandHelpers.RebaseCmd(Branches.Text, chkInteractive.Checked, chkAutosquash.Checked));
            form.ShowDialog();
            if (form.OutputString.ToString().Trim() == "Current branch a is up to date.")
                MessageBox.Show(_branchUpToDateText.Text, _branchUpToDateCaption.Text);

            if (!GitCommandHelpers.InTheMiddleOfConflictedMerge() &&
                !GitCommandHelpers.InTheMiddleOfRebase() &&
                !GitCommandHelpers.InTheMiddleOfPatch())
                Close();

            EnableButtons();
            patchGrid1.Initialize();
            Cursor.Current = Cursors.Default;
        }