Example #1
0
        public Task CherryPickAsync(CherryPickControl control, IProgress <OperationProgress> progress)
        {
            Verify.State.IsFalse(IsDisposed, "Repository is disposed.");

            switch (control)
            {
            case CherryPickControl.Abort:
                if (progress != null)
                {
                    progress.Report(new OperationProgress(Resources.StrsAbortingCherryPick.AddEllipsis()));
                }
                break;

            case CherryPickControl.Continue:
                if (progress != null)
                {
                    progress.Report(new OperationProgress(Resources.StrsContinuingCherryPick.AddEllipsis()));
                }
                break;

            case CherryPickControl.Quit:
                if (progress != null)
                {
                    progress.Report(new OperationProgress(Resources.StrsQuitingCherryPick.AddEllipsis()));
                }
                break;

            default:
                throw new ArgumentException(
                          "Unknown CherryPickControl value: {0}".UseAsFormat(control),
                          "control");
            }

            var block = Monitor.BlockNotifications(
                RepositoryNotifications.BranchChanged,
                RepositoryNotifications.WorktreeUpdated,
                RepositoryNotifications.IndexUpdated);

            return(Accessor.CherryPick.InvokeAsync(new CherryPickParameters(control), progress, CancellationToken.None)
                   .ContinueWith(
                       t =>
            {
                block.Dispose();
                _head.Refresh();
                _status.Refresh();
                OnStateChanged();
                OnUpdated();
                TaskUtility.PropagateFaultedStates(t);
            }));
        }
Example #2
0
        public async Task CherryPickAsync(CherryPickControl control, IProgress <OperationProgress> progress)
        {
            Verify.State.IsFalse(IsDisposed, "Repository is disposed.");

            switch (control)
            {
            case CherryPickControl.Abort:
                progress?.Report(new OperationProgress(Resources.StrsAbortingCherryPick.AddEllipsis()));
                break;

            case CherryPickControl.Continue:
                progress?.Report(new OperationProgress(Resources.StrsContinuingCherryPick.AddEllipsis()));
                break;

            case CherryPickControl.Quit:
                progress?.Report(new OperationProgress(Resources.StrsQuitingCherryPick.AddEllipsis()));
                break;

            default:
                throw new ArgumentException(
                          "Unknown CherryPickControl value: {0}".UseAsFormat(control),
                          nameof(control));
            }

            var block = Monitor.BlockNotifications(
                RepositoryNotifications.BranchChanged,
                RepositoryNotifications.WorktreeUpdated,
                RepositoryNotifications.IndexUpdated);

            try
            {
                await Accessor.CherryPick
                .InvokeAsync(new CherryPickParameters(control), progress, CancellationToken.None)
                .ConfigureAwait(continueOnCapturedContext: false);
            }
            catch
            {
                throw;
            }
            finally
            {
                block.Dispose();
                if (Head.Pointer is Branch branch && !branch.IsRemote)
                {
                    branch.Refresh();
                }
Example #3
0
        private void InvokeCherryPickControl(CherryPickControl control)
        {
            var parent = _guiProvider.Environment.MainForm;

            GuiCommands.CherryPick(parent, Repository, control);
        }
Example #4
0
 /// <summary>Create <see cref="CherryPickParameters"/>.</summary>
 public CherryPickParameters(CherryPickControl control)
 {
     Control = control;
 }
Example #5
0
        public static GuiCommandStatus CherryPick(IWin32Window parent, Repository repository, CherryPickControl control)
        {
            Verify.Argument.IsNotNull(repository, nameof(repository));

            try
            {
                ProgressForm.MonitorTaskAsModalWindow(parent, Resources.StrCherryPick,
                                                      p => repository.CherryPickAsync(control, p));
                return(GuiCommandStatus.Completed);
            }
            catch (OperationCanceledException)
            {
                return(GuiCommandStatus.Canceled);
            }
            catch (GitException exc)
            {
                GitterApplication.MessageBoxService.Show(
                    parent,
                    exc.Message,
                    Resources.ErrFailedToCherryPick,
                    MessageBoxButton.Close,
                    MessageBoxIcon.Error);
                return(GuiCommandStatus.Faulted);
            }
        }
Example #6
0
 public Command GetCherryPickCommand(CherryPickControl control)
 {
     switch(control)
     {
         case CherryPickControl.Continue:
             return new CherryPickCommand(CherryPickCommand.Continue());
         case CherryPickControl.Quit:
             return new CherryPickCommand(CherryPickCommand.Quit());
         case CherryPickControl.Abort:
             return new CherryPickCommand(CherryPickCommand.Abort());
         default:
             throw new ArgumentException("Unknown enum value.", "control");
     }
 }
Example #7
0
        private void InvokeCherryPickControl(CherryPickControl control)
        {
            var parent = _guiProvider.Environment.MainForm;

            GuiCommands.CherryPick(parent, Repository, control);
        }
Example #8
0
 /// <summary>Create <see cref="CherryPickParameters"/>.</summary>
 public CherryPickParameters(CherryPickControl control)
 {
     Control = control;
 }
Example #9
0
        public Task CherryPickAsync(CherryPickControl control, IProgress<OperationProgress> progress)
        {
            Verify.State.IsFalse(IsDisposed, "Repository is disposed.");

            switch(control)
            {
                case CherryPickControl.Abort:
                    if(progress != null)
                    {
                        progress.Report(new OperationProgress(Resources.StrsAbortingCherryPick.AddEllipsis()));
                    }
                    break;
                case CherryPickControl.Continue:
                    if(progress != null)
                    {
                        progress.Report(new OperationProgress(Resources.StrsContinuingCherryPick.AddEllipsis()));
                    }
                    break;
                case CherryPickControl.Quit:
                    if(progress != null)
                    {
                        progress.Report(new OperationProgress(Resources.StrsQuitingCherryPick.AddEllipsis()));
                    }
                    break;
                default:
                    throw new ArgumentException(
                        "Unknown CherryPickControl value: {0}".UseAsFormat(control),
                        "control");
            }

            var block = Monitor.BlockNotifications(
                RepositoryNotifications.BranchChanged,
                RepositoryNotifications.WorktreeUpdated,
                RepositoryNotifications.IndexUpdated);
            return Accessor.CherryPick.InvokeAsync(new CherryPickParameters(control), progress, CancellationToken.None)
                .ContinueWith(
                t =>
                {
                    block.Dispose();
                    _head.Refresh();
                    _status.Refresh();
                    OnStateChanged();
                    OnUpdated();
                    TaskUtility.PropagateFaultedStates(t);
                });
        }