Beispiel #1
0
 protected override bool RunCommand(VersionControlItemList items, bool test)
 {
     return(IgnoreCommand.Ignore(items, test));
 }
        private TestResult RunCommand(Commands cmd, bool test, bool projRecurse = true)
        {
            VersionControlItemList items = GetItems(projRecurse);

            foreach (VersionControlItem it in items)
            {
                if (it.Repository == null)
                {
                    if (cmd != Commands.Publish)
                    {
                        return(TestResult.NoVersionControl);
                    }
                }
                else if (it.Repository.VersionControlSystem != null && !it.Repository.VersionControlSystem.IsInstalled)
                {
                    return(TestResult.Disable);
                }
            }

            bool res = false;

            try {
                switch (cmd)
                {
                case Commands.Update:
                    res = UpdateCommand.Update(items, test);
                    break;

                case Commands.Diff:
                    res = DiffCommand.Show(items, test);
                    break;

                case Commands.Log:
                    res = LogCommand.Show(items, test);
                    break;

                case Commands.Status:
                    res = StatusView.Show(items, test, false);
                    break;

                case Commands.Add:
                    res = AddCommand.Add(items, test);
                    break;

                case Commands.Remove:
                    res = RemoveCommand.Remove(items, test);
                    break;

                case Commands.Revert:
                    res = RevertCommand.Revert(items, test);
                    break;

                case Commands.Lock:
                    res = LockCommand.Lock(items, test);
                    break;

                case Commands.Unlock:
                    res = UnlockCommand.Unlock(items, test);
                    break;

                case Commands.Publish:
                    VersionControlItem it = items [0];
                    if (items.Count == 1 && it.IsDirectory && it.WorkspaceObject != null)
                    {
                        res = PublishCommand.Publish(it.WorkspaceObject, it.Path, test);
                    }
                    break;

                case Commands.Annotate:
                    res = BlameCommand.Show(items, test);
                    break;

                case Commands.CreatePatch:
                    res = CreatePatchCommand.CreatePatch(items, test);
                    break;

                case Commands.Ignore:
                    res = IgnoreCommand.Ignore(items, test);
                    break;

                case Commands.Unignore:
                    res = UnignoreCommand.Unignore(items, test);
                    break;

                case Commands.ResolveConflicts:
                    res = ResolveConflictsCommand.ResolveConflicts(items, test);
                    break;
                }
            }
            catch (Exception ex) {
                if (test)
                {
                    LoggingService.LogError(ex.ToString());
                }
                else
                {
                    MessageService.ShowException(ex, GettextCatalog.GetString("Version control command failed."));
                }
                return(TestResult.Disable);
            }

            return(res ? TestResult.Enable : TestResult.Disable);
        }