Exemplo n.º 1
0
        /// <summary>Control rebase process.</summary>
        /// <param name="control">Type of operation.</param>
        public Task RebaseAsync(RebaseControl control, IProgress <OperationProgress> progress)
        {
            Verify.State.IsFalse(IsDisposed, "Repository is disposed.");

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

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

            case RebaseControl.Skip:
                if (progress != null)
                {
                    progress.Report(new OperationProgress(Resources.StrsSkippingCommit.AddEllipsis()));
                }
                break;

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

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

            return(Accessor.Rebase.InvokeAsync(new RebaseParameters(control), progress, CancellationToken.None)
                   .ContinueWith(
                       t =>
            {
                block.Dispose();
                _refs.RefreshBranches();
                _head.Refresh();
                _status.Refresh();
                OnStateChanged();
                OnUpdated();
                TaskUtility.PropagateFaultedStates(t);
            },
                       CancellationToken.None,
                       TaskContinuationOptions.ExecuteSynchronously,
                       TaskScheduler.Default));
        }
Exemplo n.º 2
0
        /// <summary>Control rebase process.</summary>
        /// <param name="control">Type of operation.</param>
        public void Rebase(RebaseControl control)
        {
            Verify.State.IsFalse(IsDisposed, "Repository is disposed.");

            using (Monitor.BlockNotifications(
                       RepositoryNotifications.BranchChanged,
                       RepositoryNotifications.Checkout,
                       RepositoryNotifications.WorktreeUpdated,
                       RepositoryNotifications.IndexUpdated))
            {
                try
                {
                    Accessor.Rebase.Invoke(new RebaseParameters(control));
                }
                finally
                {
                    _refs.RefreshBranches();
                    _head.Refresh();
                    _status.Refresh();
                    OnStateChanged();
                    OnUpdated();
                }
            }
        }
Exemplo n.º 3
0
        private void InvokeRebaseControl(RebaseControl control)
        {
            var parent = _guiProvider.Environment.MainForm;

            GuiCommands.Rebase(parent, Repository, control);
        }
Exemplo n.º 4
0
 public RebaseParameters(RebaseControl control)
 {
     Control = control;
 }
Exemplo n.º 5
0
        public static GuiCommandStatus Rebase(IWin32Window parent, Repository repository, RebaseControl control)
        {
            Verify.Argument.IsNotNull(repository, nameof(repository));

            try
            {
                ProgressForm.MonitorTaskAsModalWindow(parent, Resources.StrRebase,
                                                      p => repository.RebaseAsync(control, p));
                return(GuiCommandStatus.Completed);
            }
            catch (OperationCanceledException)
            {
                return(GuiCommandStatus.Canceled);
            }
            catch (GitException exc)
            {
                GitterApplication.MessageBoxService.Show(
                    parent,
                    exc.Message,
                    Resources.ErrFailedToRebase,
                    MessageBoxButton.Close,
                    MessageBoxIcon.Error);
                return(GuiCommandStatus.Faulted);
            }
        }
Exemplo n.º 6
0
 public RebaseParameters(RebaseControl control)
 {
     Control = control;
 }
Exemplo n.º 7
0
 public Command GetRebaseCommand(RebaseControl control)
 {
     ICommandArgument arg;
     switch(control)
     {
         case RebaseControl.Abort:
             arg = RebaseCommand.Abort();
             break;
         case RebaseControl.Continue:
             arg = RebaseCommand.Continue();
             break;
         case RebaseControl.Skip:
             arg = RebaseCommand.Skip();
             break;
         default:
             throw new ArgumentException("control");
     }
     return new RebaseCommand(arg);
 }
Exemplo n.º 8
0
        private void InvokeRebaseControl(RebaseControl control)
        {
            var parent = _guiProvider.Environment.MainForm;

            GuiCommands.Rebase(parent, Repository, control);
        }
Exemplo n.º 9
0
        /// <summary>Control rebase process.</summary>
        /// <param name="control">Type of operation.</param>
        public Task RebaseAsync(RebaseControl control, IProgress<OperationProgress> progress)
        {
            Verify.State.IsFalse(IsDisposed, "Repository is disposed.");

            switch(control)
            {
                case RebaseControl.Abort:
                    if(progress != null)
                    {
                        progress.Report(new OperationProgress(Resources.StrsAbortingRebase.AddEllipsis()));
                    }
                    break;
                case RebaseControl.Continue:
                    if(progress != null)
                    {
                        progress.Report(new OperationProgress(Resources.StrsContinuingRebase.AddEllipsis()));
                    }
                    break;
                case RebaseControl.Skip:
                    if(progress != null)
                    {
                        progress.Report(new OperationProgress(Resources.StrsSkippingCommit.AddEllipsis()));
                    }
                    break;
                default:
                    throw new ArgumentException(
                        "Unknown RebaseControl value: {0}".UseAsFormat(control),
                        "control");
            }

            var block = Monitor.BlockNotifications(
                RepositoryNotifications.BranchChanged,
                RepositoryNotifications.Checkout,
                RepositoryNotifications.WorktreeUpdated,
                RepositoryNotifications.IndexUpdated);
            return Accessor.Rebase.InvokeAsync(new RebaseParameters(control), progress, CancellationToken.None)
                .ContinueWith(
                t =>
                {
                    block.Dispose();
                    _refs.RefreshBranches();
                    _head.Refresh();
                    _status.Refresh();
                    OnStateChanged();
                    OnUpdated();
                    TaskUtility.PropagateFaultedStates(t);
                },
                CancellationToken.None,
                TaskContinuationOptions.ExecuteSynchronously,
                TaskScheduler.Default);
        }
Exemplo n.º 10
0
        /// <summary>Control rebase process.</summary>
        /// <param name="control">Type of operation.</param>
        public void Rebase(RebaseControl control)
        {
            Verify.State.IsFalse(IsDisposed, "Repository is disposed.");

            using(Monitor.BlockNotifications(
                RepositoryNotifications.BranchChanged,
                RepositoryNotifications.Checkout,
                RepositoryNotifications.WorktreeUpdated,
                RepositoryNotifications.IndexUpdated))
            {
                try
                {
                    Accessor.Rebase.Invoke(new RebaseParameters(control));
                }
                finally
                {
                    _refs.RefreshBranches();
                    _head.Refresh();
                    _status.Refresh();
                    OnStateChanged();
                    OnUpdated();
                }
            }
        }