示例#1
0
 private void RevisionGridSelectionChanged(object sender, EventArgs e)
 {
     Cursor.Current            = Cursors.WaitCursor;
     DiffFiles.GitItemStatuses = null;
     DiffFiles.SetDiffs(RevisionGrid.GetSelectedRevisions());
     Cursor.Current = Cursors.Default;
 }
示例#2
0
 private void RevisionGridSelectionChanged(object sender, EventArgs e)
 {
     using (WaitCursorScope.Enter())
     {
         DiffFiles.SetDiffs(RevisionGrid.GetSelectedRevisions());
     }
 }
示例#3
0
        public void ForceRefreshRevisions()
        {
            var revisions = _revisionGrid.GetSelectedRevisions();

            if (revisions.Count != 0)
            {
                _oldRevision = revisions[0].Guid;
                _oldDiffItem = DiffFiles.SelectedItem;
            }
            else
            {
                _oldRevision = null;
                _oldDiffItem = null;
            }

            RefreshArtificial();
        }
示例#4
0
        private void fileHistoryDiffToolstripMenuItem_Click(object sender, EventArgs e)
        {
            GitItemStatus item = DiffFiles.SelectedItem;

            if (item.IsTracked)
            {
                IList <GitRevision> revisions = RevisionGrid.GetSelectedRevisions();

                if (revisions.Count == 0 || GitRevision.IsArtificial(revisions[0].Guid))
                {
                    UICommands.StartFileHistoryDialog(this, item.Name);
                }
                else
                {
                    UICommands.StartFileHistoryDialog(this, item.Name, revisions[0], false);
                }
            }
        }
示例#5
0
 private void ViewSelectedFileDiff()
 {
     using (WaitCursorScope.Enter())
     {
         var revisions   = RevisionGrid.GetSelectedRevisions();
         var selectedRev = revisions.FirstOrDefault();
         var firstId     = revisions.Skip(1).LastOrDefault()?.ObjectId ?? selectedRev?.FirstParentGuid;
         diffViewer.ViewChangesAsync(firstId, selectedRev, DiffFiles.SelectedItem);
     }
 }
示例#6
0
        private void ViewSelectedFileDiff()
        {
            if (DiffFiles.SelectedItem == null)
            {
                diffViewer.ViewPatch("");
                return;
            }

            Cursor.Current = Cursors.WaitCursor;
            diffViewer.ViewChanges(RevisionGrid.GetSelectedRevisions(), DiffFiles.SelectedItem, String.Empty);
            Cursor.Current = Cursors.Default;
        }
示例#7
0
        private void ViewSelectedFileDiff()
        {
            if (DiffFiles.SelectedItem == null)
            {
                diffViewer.ViewPatch("");
                return;
            }

            using (WaitCursorScope.Enter())
            {
                diffViewer.ViewChangesAsync(RevisionGrid.GetSelectedRevisions(), DiffFiles.SelectedItem, string.Empty);
            }
        }
示例#8
0
        private void openWithDifftoolToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (DiffFiles.SelectedItem == null)
            {
                return;
            }

            GitUIExtensions.DiffWithRevisionKind diffKind;

            if (sender == aLocalToolStripMenuItem)
            {
                diffKind = GitUIExtensions.DiffWithRevisionKind.DiffALocal;
            }
            else if (sender == bLocalToolStripMenuItem)
            {
                diffKind = GitUIExtensions.DiffWithRevisionKind.DiffBLocal;
            }
            else if (sender == parentOfALocalToolStripMenuItem)
            {
                diffKind = GitUIExtensions.DiffWithRevisionKind.DiffAParentLocal;
            }
            else if (sender == parentOfBLocalToolStripMenuItem)
            {
                diffKind = GitUIExtensions.DiffWithRevisionKind.DiffBParentLocal;
            }
            else
            {
                Debug.Assert(sender == aBToolStripMenuItem, "Not implemented DiffWithRevisionKind: " + sender);
                diffKind = GitUIExtensions.DiffWithRevisionKind.DiffAB;
            }

            string parentGuid = RevisionGrid.GetSelectedRevisions().Count() == 1 ? DiffFiles.SelectedItemParent : null;

            foreach (var selectedItem in DiffFiles.SelectedItems)
            {
                RevisionGrid.OpenWithDifftool(selectedItem.Name, selectedItem.OldName, diffKind, parentGuid);
            }
        }
示例#9
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();
                }
            }
        }
示例#10
0
        private void ViewSelectedFileDiff()
        {
            if (DiffFiles.SelectedItem == null)
            {
                diffViewer.Clear();
                return;
            }

            using (WaitCursorScope.Enter())
            {
                var revisions   = RevisionGrid.GetSelectedRevisions();
                var selectedRev = revisions.FirstOrDefault();
                var firstId     = revisions.Skip(1).LastOrDefault()?.ObjectId;
                diffViewer.ViewChangesAsync(firstId, selectedRev, DiffFiles.SelectedItem, string.Empty);
            }
        }
示例#11
0
        private ContextMenuDiffToolInfo GetContextMenuDiffToolInfo()
        {
            bool firstIsParent = _revisionTester.AllFirstAreParentsToSelected(DiffFiles.SelectedItemParents, DiffFiles.Revision);
            bool localExists   = _revisionTester.AnyLocalFileExists(DiffFiles.SelectedItemsWithParent.Select(i => i.Item));

            IEnumerable <string> selectedItemParentRevs = DiffFiles.Revision.ParentGuids;
            bool allAreNew         = DiffFiles.SelectedItemsWithParent.All(i => i.Item.IsNew);
            bool allAreDeleted     = DiffFiles.SelectedItemsWithParent.All(i => i.Item.IsDeleted);
            var  revisions         = _revisionGrid.GetSelectedRevisions();
            bool firstParentsValid = revisions != null && revisions.Count > 1;

            var selectionInfo = new ContextMenuDiffToolInfo(_headRevision, selectedItemParentRevs,
                                                            allAreNew: allAreNew,
                                                            allAreDeleted: allAreDeleted,
                                                            firstIsParent: firstIsParent,
                                                            firstParentsValid: firstParentsValid,
                                                            localExists: localExists);

            return(selectionInfo);
        }
示例#12
0
        private void FormatPatch_Click(object sender, EventArgs e)
        {
            if (SaveToDir.Checked && string.IsNullOrEmpty(OutputPath.Text))
            {
                MessageBox.Show(this, _noOutputPathEnteredText.Text);
                return;
            }

            if (!SaveToDir.Checked && string.IsNullOrEmpty(MailTo.Text))
            {
                MessageBox.Show(this, _noEmailEnteredText.Text);
                return;
            }

            if (!SaveToDir.Checked && string.IsNullOrEmpty(MailSubject.Text))
            {
                MessageBox.Show(this, _noSubjectEnteredText.Text);
                return;
            }

            if (!SaveToDir.Checked && string.IsNullOrEmpty(AppSettings.SmtpServer))
            {
                MessageBox.Show(this, _wrongSmtpSettingsText.Text);
                return;
            }

            string savePatchesToDir = OutputPath.Text;

            if (!SaveToDir.Checked)
            {
                savePatchesToDir = Path.Combine(Module.WorkingDirGitDir, "PatchesToMail");
                if (Directory.Exists(savePatchesToDir))
                {
                    foreach (string file in Directory.GetFiles(savePatchesToDir, "*.patch"))
                    {
                        File.Delete(file);
                    }
                }
                else
                {
                    Directory.CreateDirectory(savePatchesToDir);
                }
            }

            string rev1   = "";
            string rev2   = "";
            string result = "";

            var revisions = RevisionGrid.GetSelectedRevisions();

            if (revisions.Count > 0)
            {
                if (revisions.Count == 1)
                {
                    var parents = revisions[0].ParentIds;
                    rev1   = parents?.Count > 0 ? parents[0].ToString() : "";
                    rev2   = revisions[0].Guid;
                    result = Module.FormatPatch(rev1, rev2, savePatchesToDir);
                }
                else if (revisions.Count == 2)
                {
                    var parents = revisions[0].ParentIds;
                    rev1   = parents?.Count > 0 ? parents[0].ToString() : "";
                    rev2   = revisions[1].Guid;
                    result = Module.FormatPatch(rev1, rev2, savePatchesToDir);
                }
                else
                {
                    int n = 0;
                    foreach (GitRevision revision in revisions)
                    {
                        n++;
                        var parents = revision.ParentIds;
                        rev1    = parents?.Count > 0 ? parents[0].ToString() : "";
                        rev2    = revision.Guid;
                        result += Module.FormatPatch(rev1, rev2, savePatchesToDir, n);
                    }
                }
            }
            else
            {
                MessageBox.Show(this, _revisionsNeededText.Text, _revisionsNeededCaption.Text);
                return;
            }

            if (!SaveToDir.Checked)
            {
                result += Environment.NewLine + Environment.NewLine;
                if (SendMail(savePatchesToDir))
                {
                    result += _sendMailResult.Text + " " + MailTo.Text;
                }
                else
                {
                    result += _sendMailResultFailed.Text;
                }

                // Clean up
                if (Directory.Exists(savePatchesToDir))
                {
                    foreach (string file in Directory.GetFiles(savePatchesToDir, "*.patch"))
                    {
                        File.Delete(file);
                    }
                }
            }

            MessageBox.Show(this, result, _patchResultCaption.Text);
            Close();
        }
示例#13
0
        internal static bool RunScript(IWin32Window owner, GitModule aModule, ScriptInfo scriptInfo, RevisionGrid revisionGrid)
        {
            string originalCommand = scriptInfo.Command;
            string argument = scriptInfo.Arguments;

            string command = OverrideCommandWhenNecessary(originalCommand);
            var allSelectedRevisions = new List<GitRevision>();

            GitRevision selectedRevision = null;
            GitRevision currentRevision = null;

            var selectedLocalBranches = new List<GitRef>();
            var selectedRemoteBranches = new List<GitRef>();
            var selectedRemotes = new List<string>();
            var selectedBranches = new List<GitRef>();
            var selectedTags = new List<GitRef>();
            var currentLocalBranches = new List<GitRef>();
            var currentRemoteBranches = new List<GitRef>();
            var currentRemote = "";
            var currentBranches = new List<GitRef>();
            var currentTags = new List<GitRef>();

            foreach (string option in Options)
            {
                if (string.IsNullOrEmpty(argument) || !argument.Contains(option))
                    continue;
                if (option.StartsWith("{c") && currentRevision == null)
                {
                    currentRevision = GetCurrentRevision(aModule, revisionGrid, currentTags, currentLocalBranches, currentRemoteBranches, currentBranches, currentRevision);

                    if (currentLocalBranches.Count == 1)
                        currentRemote = aModule.GetSetting(string.Format("branch.{0}.remote", currentLocalBranches[0].Name));
                    else
                    {
                        currentRemote = aModule.GetCurrentRemote();
                        if (string.IsNullOrEmpty(currentRemote))
                            currentRemote = aModule.GetSetting(string.Format("branch.{0}.remote",
                                askToSpecify(currentLocalBranches, "Current Revision Branch")));
                    }
                }
                else if (option.StartsWith("{s") && selectedRevision == null && revisionGrid != null)
                {
                    allSelectedRevisions = revisionGrid.GetSelectedRevisions();
                    allSelectedRevisions.Reverse(); // Put first clicked revisions first
                    selectedRevision = CalculateSelectedRevision(revisionGrid, selectedRemoteBranches, selectedRemotes, selectedLocalBranches, selectedBranches, selectedTags);
                }

                string remote;
                string url;
                switch (option)
                {
                    case "{sHashes}":
                        argument = argument.Replace(option,
                            string.Join(" ", allSelectedRevisions.Select(revision => revision.Guid).ToArray()));
                        break;
                    case "{sTag}":
                        if (selectedTags.Count == 1)
                            argument = argument.Replace(option, selectedTags[0].Name);
                        else if (selectedTags.Count != 0)
                            argument = argument.Replace(option, askToSpecify(selectedTags, "Selected Revision Tag"));
                        else
                            argument = argument.Replace(option, "");
                        break;
                    case "{sBranch}":
                        if (selectedBranches.Count == 1)
                            argument = argument.Replace(option, selectedBranches[0].Name);
                        else if (selectedBranches.Count != 0)
                            argument = argument.Replace(option,
                                                        askToSpecify(selectedBranches, "Selected Revision Branch"));
                        else
                            argument = argument.Replace(option, "");
                        break;
                    case "{sLocalBranch}":
                        if (selectedLocalBranches.Count == 1)
                            argument = argument.Replace(option, selectedLocalBranches[0].Name);
                        else if (selectedLocalBranches.Count != 0)
                            argument = argument.Replace(option,
                                                        askToSpecify(selectedLocalBranches,
                                                                     "Selected Revision Local Branch"));
                        else
                            argument = argument.Replace(option, "");
                        break;
                    case "{sRemoteBranch}":
                        if (selectedRemoteBranches.Count == 1)
                            argument = argument.Replace(option, selectedRemoteBranches[0].Name);
                        else if (selectedRemoteBranches.Count != 0)
                            argument = argument.Replace(option,
                                                        askToSpecify(selectedRemoteBranches,
                                                                     "Selected Revision Remote Branch"));
                        else
                            argument = argument.Replace(option, "");
                        break;
                    case "{sRemote}":
                        if (selectedRemotes.Count == 0)
                        {
                            argument = argument.Replace(option, "");
                            break;
                        }
                        if (selectedRemotes.Count == 1)
                            remote = selectedRemotes[0];
                        else
                            remote = askToSpecify(selectedRemotes, "Selected Revision Remote");
                        argument = argument.Replace(option, remote);
                        break;
                    case "{sRemoteUrl}":
                        if (selectedRemotes.Count == 0)
                        {
                            argument = argument.Replace(option, "");
                            break;
                        }
                        if (selectedRemotes.Count == 1)
                            remote = selectedRemotes[0];
                        else
                            remote = askToSpecify(selectedRemotes, "Selected Revision Remote");
                        url = aModule.GetPathSetting(string.Format(SettingKeyString.RemoteUrl, remote));
                        argument = argument.Replace(option, url);
                        break;
                    case "{sRemotePathFromUrl}":
                        if (selectedRemotes.Count == 0)
                        {
                            argument = argument.Replace(option, "");
                            break;
                        }
                        if (selectedRemotes.Count == 1)
                            remote = selectedRemotes[0];
                        else
                            remote = askToSpecify(selectedRemotes, "Selected Revision Remote");
                        url = aModule.GetPathSetting(string.Format(SettingKeyString.RemoteUrl, remote));
                        argument = argument.Replace(option, GetRemotePath(url));
                        break;
                    case "{sHash}":
                        argument = argument.Replace(option, selectedRevision.Guid);
                        break;
                    case "{sMessage}":
                        argument = argument.Replace(option, selectedRevision.Message);
                        break;
                    case "{sAuthor}":
                        argument = argument.Replace(option, selectedRevision.Author);
                        break;
                    case "{sCommitter}":
                        argument = argument.Replace(option, selectedRevision.Committer);
                        break;
                    case "{sAuthorDate}":
                        argument = argument.Replace(option, selectedRevision.AuthorDate.ToString());
                        break;
                    case "{sCommitDate}":
                        argument = argument.Replace(option, selectedRevision.CommitDate.ToString());
                        break;
                    case "{cTag}":
                        if (currentTags.Count == 1)
                            argument = argument.Replace(option, currentTags[0].Name);
                        else if (currentTags.Count != 0)
                            argument = argument.Replace(option, askToSpecify(currentTags, "Current Revision Tag"));
                        else
                            argument = argument.Replace(option, "");
                        break;
                    case "{cBranch}":
                        if (currentBranches.Count == 1)
                            argument = argument.Replace(option, currentBranches[0].Name);
                        else if (currentBranches.Count != 0)
                            argument = argument.Replace(option,
                                                        askToSpecify(currentBranches, "Current Revision Branch"));
                        else
                            argument = argument.Replace(option, "");
                        break;
                    case "{cLocalBranch}":
                        if (currentLocalBranches.Count == 1)
                            argument = argument.Replace(option, currentLocalBranches[0].Name);
                        else if (currentLocalBranches.Count != 0)
                            argument = argument.Replace(option,
                                                        askToSpecify(currentLocalBranches,
                                                                     "Current Revision Local Branch"));
                        else
                            argument = argument.Replace(option, "");
                        break;
                    case "{cRemoteBranch}":
                        if (currentRemoteBranches.Count == 1)
                            argument = argument.Replace(option, currentRemoteBranches[0].Name);
                        else if (currentRemoteBranches.Count != 0)
                            argument = argument.Replace(option,
                                                        askToSpecify(currentRemoteBranches,
                                                                     "Current Revision Remote Branch"));
                        else
                            argument = argument.Replace(option, "");
                        break;
                    case "{cHash}":
                        argument = argument.Replace(option, currentRevision.Guid);
                        break;
                    case "{cMessage}":
                        argument = argument.Replace(option, currentRevision.Message);
                        break;
                    case "{cAuthor}":
                        argument = argument.Replace(option, currentRevision.Author);
                        break;
                    case "{cCommitter}":
                        argument = argument.Replace(option, currentRevision.Committer);
                        break;
                    case "{cAuthorDate}":
                        argument = argument.Replace(option, currentRevision.AuthorDate.ToString());
                        break;
                    case "{cCommitDate}":
                        argument = argument.Replace(option, currentRevision.CommitDate.ToString());
                        break;
                    case "{cDefaultRemote}":
                        if (string.IsNullOrEmpty(currentRemote))
                        {
                            argument = argument.Replace(option, "");
                            break;
                        }
                        argument = argument.Replace(option, currentRemote);
                        break;
                    case "{cDefaultRemoteUrl}":
                        if (string.IsNullOrEmpty(currentRemote))
                        {
                            argument = argument.Replace(option, "");
                            break;
                        }
                        url = aModule.GetPathSetting(string.Format(SettingKeyString.RemoteUrl, currentRemote));
                        argument = argument.Replace(option, url);
                        break;
                    case "{cDefaultRemotePathFromUrl}":
                        if (string.IsNullOrEmpty(currentRemote))
                        {
                            argument = argument.Replace(option, "");
                            break;
                        }
                        url = aModule.GetPathSetting(string.Format(SettingKeyString.RemoteUrl, currentRemote));
                        argument = argument.Replace(option, GetRemotePath(url));
                        break;
                    case "{UserInput}":
                        using (SimplePrompt Prompt = new SimplePrompt())
                        {
                            Prompt.ShowDialog();
                            argument = argument.Replace(option, Prompt.UserInput);
                        }
                        break;
                    case "{WorkingDir}":
                        argument = argument.Replace(option, aModule.WorkingDir);
                        break;
                }
            }
            command = ExpandCommandVariables(command,aModule);

            if (!scriptInfo.RunInBackground)
                FormProcess.ShowDialog(owner, command, argument, aModule.WorkingDir, null, true);
            else
            {
                if (originalCommand.Equals("{openurl}", StringComparison.CurrentCultureIgnoreCase))
                    Process.Start(argument);
                else
                    aModule.RunExternalCmdDetached(command, argument);
            }
            return !scriptInfo.RunInBackground;
        }
示例#14
0
        internal static bool RunScript(IWin32Window owner, GitModule aModule, ScriptInfo scriptInfo, RevisionGrid revisionGrid)
        {
            string originalCommand = scriptInfo.Command;
            string argument        = scriptInfo.Arguments;

            string command = OverrideCommandWhenNecessary(originalCommand);
            var    allSelectedRevisions = new List <GitRevision>();

            GitRevision selectedRevision = null;
            GitRevision currentRevision  = null;

            var selectedLocalBranches  = new List <IGitRef>();
            var selectedRemoteBranches = new List <IGitRef>();
            var selectedRemotes        = new List <string>();
            var selectedBranches       = new List <IGitRef>();
            var selectedTags           = new List <IGitRef>();
            var currentLocalBranches   = new List <IGitRef>();
            var currentRemoteBranches  = new List <IGitRef>();
            var currentRemote          = "";
            var currentBranches        = new List <IGitRef>();
            var currentTags            = new List <IGitRef>();

            foreach (string option in Options)
            {
                if (string.IsNullOrEmpty(argument) || !argument.Contains(option))
                {
                    continue;
                }
                if (option.StartsWith("{c") && currentRevision == null)
                {
                    currentRevision = GetCurrentRevision(aModule, revisionGrid, currentTags, currentLocalBranches, currentRemoteBranches, currentBranches, currentRevision);

                    if (currentLocalBranches.Count == 1)
                    {
                        currentRemote = aModule.GetSetting(string.Format(SettingKeyString.BranchRemote, currentLocalBranches[0].Name));
                    }
                    else
                    {
                        currentRemote = aModule.GetCurrentRemote();
                        if (string.IsNullOrEmpty(currentRemote))
                        {
                            currentRemote = aModule.GetSetting(string.Format(SettingKeyString.BranchRemote,
                                                                             askToSpecify(currentLocalBranches, "Current Revision Branch")));
                        }
                    }
                }
                else if (option.StartsWith("{s") && selectedRevision == null && revisionGrid != null)
                {
                    allSelectedRevisions = revisionGrid.GetSelectedRevisions();
                    allSelectedRevisions.Reverse(); // Put first clicked revisions first
                    selectedRevision = CalculateSelectedRevision(revisionGrid, selectedRemoteBranches, selectedRemotes, selectedLocalBranches, selectedBranches, selectedTags);
                }

                string remote;
                string url;
                switch (option)
                {
                case "{sHashes}":
                    argument = argument.Replace(option,
                                                string.Join(" ", allSelectedRevisions.Select(revision => revision.Guid).ToArray()));
                    break;

                case "{sTag}":
                    if (selectedTags.Count == 1)
                    {
                        argument = argument.Replace(option, selectedTags[0].Name);
                    }
                    else if (selectedTags.Count != 0)
                    {
                        argument = argument.Replace(option, askToSpecify(selectedTags, "Selected Revision Tag"));
                    }
                    else
                    {
                        argument = argument.Replace(option, "");
                    }
                    break;

                case "{sBranch}":
                    if (selectedBranches.Count == 1)
                    {
                        argument = argument.Replace(option, selectedBranches[0].Name);
                    }
                    else if (selectedBranches.Count != 0)
                    {
                        argument = argument.Replace(option,
                                                    askToSpecify(selectedBranches, "Selected Revision Branch"));
                    }
                    else
                    {
                        argument = argument.Replace(option, "");
                    }
                    break;

                case "{sLocalBranch}":
                    if (selectedLocalBranches.Count == 1)
                    {
                        argument = argument.Replace(option, selectedLocalBranches[0].Name);
                    }
                    else if (selectedLocalBranches.Count != 0)
                    {
                        argument = argument.Replace(option,
                                                    askToSpecify(selectedLocalBranches,
                                                                 "Selected Revision Local Branch"));
                    }
                    else
                    {
                        argument = argument.Replace(option, "");
                    }
                    break;

                case "{sRemoteBranch}":
                    if (selectedRemoteBranches.Count == 1)
                    {
                        argument = argument.Replace(option, selectedRemoteBranches[0].Name);
                    }
                    else if (selectedRemoteBranches.Count != 0)
                    {
                        argument = argument.Replace(option,
                                                    askToSpecify(selectedRemoteBranches,
                                                                 "Selected Revision Remote Branch"));
                    }
                    else
                    {
                        argument = argument.Replace(option, "");
                    }
                    break;

                case "{sRemote}":
                    if (selectedRemotes.Count == 0)
                    {
                        argument = argument.Replace(option, "");
                        break;
                    }
                    if (selectedRemotes.Count == 1)
                    {
                        remote = selectedRemotes[0];
                    }
                    else
                    {
                        remote = askToSpecify(selectedRemotes, "Selected Revision Remote");
                    }
                    argument = argument.Replace(option, remote);
                    break;

                case "{sRemoteUrl}":
                    if (selectedRemotes.Count == 0)
                    {
                        argument = argument.Replace(option, "");
                        break;
                    }
                    if (selectedRemotes.Count == 1)
                    {
                        remote = selectedRemotes[0];
                    }
                    else
                    {
                        remote = askToSpecify(selectedRemotes, "Selected Revision Remote");
                    }
                    url      = aModule.GetSetting(string.Format(SettingKeyString.RemoteUrl, remote));
                    argument = argument.Replace(option, url);
                    break;

                case "{sRemotePathFromUrl}":
                    if (selectedRemotes.Count == 0)
                    {
                        argument = argument.Replace(option, "");
                        break;
                    }
                    if (selectedRemotes.Count == 1)
                    {
                        remote = selectedRemotes[0];
                    }
                    else
                    {
                        remote = askToSpecify(selectedRemotes, "Selected Revision Remote");
                    }
                    url      = aModule.GetSetting(string.Format(SettingKeyString.RemoteUrl, remote));
                    argument = argument.Replace(option, GetRemotePath(url));
                    break;

                case "{sHash}":
                    argument = argument.Replace(option, selectedRevision.Guid);
                    break;

                case "{sMessage}":
                    argument = argument.Replace(option, selectedRevision.Subject);
                    break;

                case "{sAuthor}":
                    argument = argument.Replace(option, selectedRevision.Author);
                    break;

                case "{sCommitter}":
                    argument = argument.Replace(option, selectedRevision.Committer);
                    break;

                case "{sAuthorDate}":
                    argument = argument.Replace(option, selectedRevision.AuthorDate.ToString());
                    break;

                case "{sCommitDate}":
                    argument = argument.Replace(option, selectedRevision.CommitDate.ToString());
                    break;

                case "{cTag}":
                    if (currentTags.Count == 1)
                    {
                        argument = argument.Replace(option, currentTags[0].Name);
                    }
                    else if (currentTags.Count != 0)
                    {
                        argument = argument.Replace(option, askToSpecify(currentTags, "Current Revision Tag"));
                    }
                    else
                    {
                        argument = argument.Replace(option, "");
                    }
                    break;

                case "{cBranch}":
                    if (currentBranches.Count == 1)
                    {
                        argument = argument.Replace(option, currentBranches[0].Name);
                    }
                    else if (currentBranches.Count != 0)
                    {
                        argument = argument.Replace(option,
                                                    askToSpecify(currentBranches, "Current Revision Branch"));
                    }
                    else
                    {
                        argument = argument.Replace(option, "");
                    }
                    break;

                case "{cLocalBranch}":
                    if (currentLocalBranches.Count == 1)
                    {
                        argument = argument.Replace(option, currentLocalBranches[0].Name);
                    }
                    else if (currentLocalBranches.Count != 0)
                    {
                        argument = argument.Replace(option,
                                                    askToSpecify(currentLocalBranches,
                                                                 "Current Revision Local Branch"));
                    }
                    else
                    {
                        argument = argument.Replace(option, "");
                    }
                    break;

                case "{cRemoteBranch}":
                    if (currentRemoteBranches.Count == 1)
                    {
                        argument = argument.Replace(option, currentRemoteBranches[0].Name);
                    }
                    else if (currentRemoteBranches.Count != 0)
                    {
                        argument = argument.Replace(option,
                                                    askToSpecify(currentRemoteBranches,
                                                                 "Current Revision Remote Branch"));
                    }
                    else
                    {
                        argument = argument.Replace(option, "");
                    }
                    break;

                case "{cHash}":
                    argument = argument.Replace(option, currentRevision.Guid);
                    break;

                case "{cMessage}":
                    argument = argument.Replace(option, currentRevision.Subject);
                    break;

                case "{cAuthor}":
                    argument = argument.Replace(option, currentRevision.Author);
                    break;

                case "{cCommitter}":
                    argument = argument.Replace(option, currentRevision.Committer);
                    break;

                case "{cAuthorDate}":
                    argument = argument.Replace(option, currentRevision.AuthorDate.ToString());
                    break;

                case "{cCommitDate}":
                    argument = argument.Replace(option, currentRevision.CommitDate.ToString());
                    break;

                case "{cDefaultRemote}":
                    if (string.IsNullOrEmpty(currentRemote))
                    {
                        argument = argument.Replace(option, "");
                        break;
                    }
                    argument = argument.Replace(option, currentRemote);
                    break;

                case "{cDefaultRemoteUrl}":
                    if (string.IsNullOrEmpty(currentRemote))
                    {
                        argument = argument.Replace(option, "");
                        break;
                    }
                    url      = aModule.GetSetting(string.Format(SettingKeyString.RemoteUrl, currentRemote));
                    argument = argument.Replace(option, url);
                    break;

                case "{cDefaultRemotePathFromUrl}":
                    if (string.IsNullOrEmpty(currentRemote))
                    {
                        argument = argument.Replace(option, "");
                        break;
                    }
                    url      = aModule.GetSetting(string.Format(SettingKeyString.RemoteUrl, currentRemote));
                    argument = argument.Replace(option, GetRemotePath(url));
                    break;

                case "{UserInput}":
                    using (SimplePrompt Prompt = new SimplePrompt())
                    {
                        Prompt.ShowDialog();
                        argument = argument.Replace(option, Prompt.UserInput);
                    }
                    break;

                case "{WorkingDir}":
                    argument = argument.Replace(option, aModule.WorkingDir);
                    break;
                }
            }
            command = ExpandCommandVariables(command, aModule);

            if (scriptInfo.IsPowerShell)
            {
                PowerShellHelper.RunPowerShell(command, argument, aModule.WorkingDir, scriptInfo.RunInBackground);
                return(false);
            }

            if (command.StartsWith(PluginPrefix))
            {
                command = command.Replace(PluginPrefix, "");
                foreach (var plugin in Plugin.LoadedPlugins.Plugins)
                {
                    if (plugin.Description.ToLower().Equals(command, StringComparison.CurrentCultureIgnoreCase))
                    {
                        var eventArgs = new GitUIEventArgs(owner, revisionGrid.UICommands, argument);
                        return(plugin.Execute(eventArgs));
                    }
                }
                return(false);
            }

            if (!scriptInfo.RunInBackground)
            {
                FormProcess.ShowStandardProcessDialog(owner, command, argument, aModule.WorkingDir, null, true);
            }
            else
            {
                if (originalCommand.Equals("{openurl}", StringComparison.CurrentCultureIgnoreCase))
                {
                    Process.Start(argument);
                }
                else
                {
                    aModule.RunExternalCmdDetached(command, argument);
                }
            }

            return(!scriptInfo.RunInBackground);
        }