Exemplo n.º 1
0
        public static GuiCommandStatus DropStashedState(IWin32Window parent, StashedStatesCollection stash)
        {
            Verify.Argument.IsNotNull(stash, nameof(stash));

            try
            {
                ProgressForm.MonitorTaskAsModalWindow(parent, Resources.StrStashDrop, stash.DropAsync);
                return(GuiCommandStatus.Completed);
            }
            catch (OperationCanceledException)
            {
                return(GuiCommandStatus.Canceled);
            }
            catch (InvalidOperationException)
            {
                return(GuiCommandStatus.Faulted);
            }
            catch (GitException exc)
            {
                GitterApplication.MessageBoxService.Show(
                    parent,
                    exc.Message,
                    Resources.ErrFailedToStashDrop,
                    MessageBoxButton.Close,
                    MessageBoxIcon.Error);
                return(GuiCommandStatus.Faulted);
            }
        }
Exemplo n.º 2
0
        public static GuiCommandStatus ApplyStashedState(IWin32Window parent, StashedStatesCollection stash, bool restoreIndex)
        {
            Verify.Argument.IsNotNull(stash, "stash");

            try
            {
                ProgressForm.MonitorTaskAsModalWindow(parent, Resources.StrStashApply,
                                                      p => stash.ApplyAsync(restoreIndex, p));
                return(GuiCommandStatus.Completed);
            }
            catch (OperationCanceledException)
            {
                return(GuiCommandStatus.Canceled);
            }
            catch (GitException exc)
            {
                GitterApplication.MessageBoxService.Show(
                    parent,
                    exc.Message,
                    Resources.ErrFailedToStashApply,
                    MessageBoxButton.Close,
                    MessageBoxIcon.Error);
                return(GuiCommandStatus.Faulted);
            }
        }
Exemplo n.º 3
0
        /// <summary>Create <see cref="Repository"/>.</summary>
        /// <param name="gitAccessor">Git repository access provider.</param>
        /// <param name="workingDirectory">Repository working directory.</param>
        /// <param name="load"><c>true</c> to load repository; <c>false</c> otherwise.</param>
        private Repository(IGitAccessor gitAccessor, string workingDirectory, bool load)
        {
            Verify.Argument.IsNotNull(gitAccessor, "gitAccessor");
            Verify.Argument.IsNotNull(workingDirectory, "workingDirectory");

            _workingDirectory     = GetWorkingDirectory(workingDirectory);
            _gitDirectory         = GetGitDirectory(_workingDirectory);
            _configurationManager = GetConfigurationManager(_gitDirectory);

            _accessor      = gitAccessor.CreateRepositoryAccessor(this);
            _revisionCache = new RevisionCache(this);
            _configuration = new ConfigParametersCollection(this);
            _status        = new Status(this);
            _stash         = new StashedStatesCollection(this);
            _refs          = new RefsCollection(this);
            _notes         = new NotesCollection(this);
            _remotes       = new RemotesCollection(this);
            _submodules    = new SubmodulesCollection(this);
            _users         = new UsersCollection(this);
            _hooks         = new HooksCollection(this);

            if(load)
            {
                try
                {
                    LoadCore(this, null, CancellationToken.None);
                }
                catch
                {
                    Dispose();
                    throw;
                }
            }
        }
Exemplo n.º 4
0
 public static GuiCommandStatus SaveStash(IWin32Window parent, StashedStatesCollection stash, bool keepIndex, bool includeUntracked, string message)
 {
     try
     {
         ProgressForm.MonitorTaskAsModalWindow(parent, Resources.StrStashSave,
                                               p => stash.SaveAsync(keepIndex, includeUntracked, message, p));
         return(GuiCommandStatus.Completed);
     }
     catch (OperationCanceledException)
     {
         return(GuiCommandStatus.Canceled);
     }
     catch (GitException exc)
     {
         GitterApplication.MessageBoxService.Show(
             parent,
             exc.Message,
             Resources.ErrFailedToStash,
             MessageBoxButton.Close,
             MessageBoxIcon.Error);
         return(GuiCommandStatus.Faulted);
     }
 }