コード例 #1
0
        async public Task StartUpdate(ICommitStorageUpdateContextProvider contextProvider,
                                      Action <string> onProgressChange, Action onUpdateStateChange)
        {
            if (onProgressChange == null || onUpdateStateChange == null)
            {
                throw new NotImplementedException(); // not tested cases
            }

            try
            {
                ++_activeAwaitedUpdateRequestCount;
                traceInformation(String.Format("StartUpdate() called with context of type {0}",
                                               contextProvider?.GetContext()?.GetType().ToString() ?? "null"));
                await doUpdate(true, contextProvider?.GetContext(), onProgressChange);
            }
            catch (RepositoryAccessorException ex)
            {
                throw new LocalCommitStorageUpdaterFailedException("Cannot update file storage", ex);
            }
            finally
            {
                --_activeAwaitedUpdateRequestCount;
                reportProgress(onProgressChange, String.Empty);
                traceInformation("StartUpdate() finished");
            }
        }
コード例 #2
0
        async private Task <bool> prepareCommitStorage(
            MergeRequestKey mrk, ILocalCommitStorage storage, ICommitStorageUpdateContextProvider contextProvider,
            bool isLimitExceptionFatal)
        {
            Trace.TraceInformation(String.Format(
                                       "[MainForm] Preparing commit storage by user request for MR IId {0} (at {1})...",
                                       mrk.IId, storage.Path));

            try
            {
                _mergeRequestsUpdatingByUserRequest.Add(mrk);
                updateStorageDependentControlState(mrk);
                addOperationRecord(getStorageSummaryUpdateInformation());
                await storage.Updater.StartUpdate(contextProvider, status => onStorageUpdateProgressChange(status, mrk),
                                                  () => onStorageUpdateStateChange());

                return(true);
            }
            catch (LocalCommitStorageUpdaterCancelledException)
            {
                MessageBox.Show("Cannot perform requested action without up-to-date storage", "Warning",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
                addOperationRecord("Storage update cancelled by user");
                return(false);
            }
            catch (LocalCommitStorageUpdaterFailedException fex)
            {
                ExceptionHandlers.Handle(fex.Message, fex);
                MessageBox.Show(fex.OriginalMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                addOperationRecord("Failed to update storage");
                return(false);
            }
            catch (LocalCommitStorageUpdaterLimitException mex)
            {
                ExceptionHandlers.Handle(mex.Message, mex);
                if (!isLimitExceptionFatal)
                {
                    return(true);
                }
                string extraMessage = "If there are multiple revisions try selecting two other ones";
                MessageBox.Show(mex.OriginalMessage + ". " + extraMessage, "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                addOperationRecord("Failed to update storage");
                return(false);
            }
            catch (Exception) // just in case
            {
                Debug.Assert(false);
                return(false);
            }
            finally
            {
                if (!_exiting)
                {
                    _mergeRequestsUpdatingByUserRequest.Remove(mrk);
                    updateStorageDependentControlState(mrk);
                    addOperationRecord(getStorageSummaryUpdateInformation());
                }
            }
        }
コード例 #3
0
        public void RequestUpdate(ICommitStorageUpdateContextProvider contextProvider, Action onFinished)
        {
            _synchronizeInvoke.BeginInvoke(new Action(
                                               async() =>
            {
                try
                {
                    traceInformation(String.Format("RequestUpdate() called with context of type {0}",
                                                   contextProvider?.GetContext()?.GetType().ToString() ?? "null"));

                    await doUpdate(false, contextProvider?.GetContext(), null);
                    onFinished?.Invoke();
                }
                catch (RepositoryAccessorException ex)
                {
                    ExceptionHandlers.Handle("Silent update failed", ex);
                }
                catch (LocalCommitStorageUpdaterLimitException ex)
                {
                    ExceptionHandlers.Handle("Silent update failed", ex);
                }
                finally
                {
                    traceInformation("RequestUpdate() finished");
                }
            }), null);
        }
コード例 #4
0
        public void RequestUpdate(ICommitStorageUpdateContextProvider contextProvider, Action onFinished)
        {
            _synchronizeInvoke.BeginInvoke(new Action(
                                               async() =>
            {
                if (_gitRepository.ExpectingClone)
                {
                    traceInformation("RequestUpdate() does nothing because repository is not cloned");
                    return;
                }

                try
                {
                    traceInformation(String.Format("RequestUpdate() called with context of type {0}",
                                                   contextProvider?.GetContext()?.GetType().ToString() ?? "null"));

                    await doUpdate(false, contextProvider?.GetContext(), null);
                    onFinished?.Invoke();
                }
                catch (GitCommandException ex)
                {
                    ExceptionHandlers.Handle("Silent update failed", ex);
                }
                finally
                {
                    traceDebug("RequestUpdate() finished");
                }
            }), null);
        }
コード例 #5
0
        async public Task StartUpdate(ICommitStorageUpdateContextProvider contextProvider,
                                      Action <string> onProgressChange, Action onUpdateStateChange)
        {
            if (onProgressChange == null || onUpdateStateChange == null)
            {
                throw new NotImplementedException(); // not tested cases
            }

            try
            {
                traceInformation(String.Format("StartUpdate() called with context of type {0}",
                                               contextProvider?.GetContext()?.GetType().ToString() ?? "null"));
                registerCallbacks(onProgressChange, onUpdateStateChange);
                await doUpdate(true, contextProvider?.GetContext(), onProgressChange);
            }
            catch (GitCommandException ex)
            {
                handleException(ex);
            }
            finally
            {
                unregisterCallbacks(onProgressChange, onUpdateStateChange);
                reportProgress(onProgressChange, String.Empty);
                traceInformation("StartUpdate() finished");
            }
        }
コード例 #6
0
        /// <summary>
        /// Update passed GitRepository object.
        /// Throw InteractiveUpdaterException on unrecoverable errors.
        /// Throw CancelledByUserException and RepeatOperationException.
        /// </summary>
        async public Task StartUpdate(ICommitStorageUpdateContextProvider contextProvider,
                                      Action <string> onProgressChange, Action onUpdateStateChange)
        {
            if (_gitRepository.ExpectingClone && !isCloneAllowed(_gitRepository.Path))
            {
                throw new LocalCommitStorageUpdaterCancelledException();
            }

            await runAsync(_gitRepository, async() => await _updaterInternal.StartUpdate(
                               contextProvider, onProgressChange, onUpdateStateChange));
        }
コード例 #7
0
ファイル: MainForm.Async.cs プロジェクト: BartWeyder/mrHelper
        async private Task <bool> prepareCommitStorage(
            MergeRequestKey mrk, ILocalCommitStorage storage, ICommitStorageUpdateContextProvider contextProvider,
            bool isLimitExceptionFatal)
        {
            try
            {
                _mergeRequestsUpdatingByUserRequest.Add(mrk);
                updateStorageDependentControlState(mrk);
                labelWorkflowStatus.Text = getStorageSummaryUpdateInformation();
                await storage.Updater.StartUpdate(contextProvider, status => onStorageUpdateProgressChange(status, mrk),
                                                  () => onStorageUpdateStateChange());

                return(true);
            }
            catch (Exception ex)
            {
                if (ex is LocalCommitStorageUpdaterCancelledException)
                {
                    MessageBox.Show("Cannot perform requested action without up-to-date storage", "Warning",
                                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    labelWorkflowStatus.Text = "Storage update cancelled by user";
                }
                else if (ex is LocalCommitStorageUpdaterFailedException fex)
                {
                    ExceptionHandlers.Handle(ex.Message, ex);
                    MessageBox.Show(fex.OriginalMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    labelWorkflowStatus.Text = "Failed to update storage";
                }
                else if (ex is LocalCommitStorageUpdaterLimitException mex)
                {
                    ExceptionHandlers.Handle(ex.Message, mex);
                    if (!isLimitExceptionFatal)
                    {
                        return(true);
                    }
                    MessageBox.Show(mex.OriginalMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    labelWorkflowStatus.Text = "Failed to update storage";
                }
                return(false);
            }
            finally
            {
                _mergeRequestsUpdatingByUserRequest.Remove(mrk);
                updateStorageDependentControlState(mrk);
                labelWorkflowStatus.Text = getStorageSummaryUpdateInformation();
            }
        }
コード例 #8
0
 public void RequestUpdate(ICommitStorageUpdateContextProvider contextProvider, Action onFinished)
 {
     _updaterInternal?.RequestUpdate(contextProvider, onFinished);
 }