예제 #1
0
        internal static void CheckinPathsPartial(
            WorkspaceInfo wkInfo,
            List <string> paths,
            string comment,
            ViewHost viewHost,
            CheckinDialog dialog,
            GuiMessage.IGuiMessage guiMessage,
            IProgressControls progressControls,
            IGluonViewSwitcher gluonViewSwitcher)
        {
            BaseCommandsImpl baseCommands = new BaseCommandsImpl();

            progressControls.ShowProgress(PlasticLocalization.GetString(
                                              PlasticLocalization.Name.CheckinInFilesProgress));

            IThreadWaiter waiter = ThreadWaiter.GetWaiter(50);

            waiter.Execute(
                /*threadOperationDelegate*/ delegate
            {
                baseCommands.PartialCheckin(wkInfo, paths, comment);
            },
                /*afterOperationDelegate*/ delegate
            {
                progressControls.HideProgress();

                ((IPlasticDialogCloser)dialog).CloseDialog();

                if (waiter.Exception is CheckinConflictsException)
                {
                    // we need to explicitly call EditorWindow.Close() to ensure
                    // that the dialog is closed before asking the user
                    dialog.Close();

                    if (!UserWantsToShowIncomingView(guiMessage))
                    {
                        return;
                    }

                    gluonViewSwitcher.ShowIncomingChangesView();
                    return;
                }

                if (waiter.Exception != null)
                {
                    ExceptionsHandler.DisplayException(waiter.Exception);
                    return;
                }

                viewHost.RefreshView(ViewType.CheckinView);
                viewHost.RefreshView(ViewType.HistoryView);
            });
        }
        void LaunchMigration(
            string unityAccessToken,
            string projectPath,
            string organizationName,
            RepId repId,
            long changesetId,
            long branchId,
            Action afterWorkspaceMigratedAction,
            ProgressControlsForMigration progressControls)
        {
            string serverName = string.Format(
                "{0}@cloud", organizationName);

            TokenExchangeResponse tokenExchangeResponse = null;

            mWorkspaceInfo = null;

            CreateWorkspaceFromCollab.Progress progress = new CreateWorkspaceFromCollab.Progress();

            BuildProgressSpeedAndRemainingTime.ProgressData progressData =
                new BuildProgressSpeedAndRemainingTime.ProgressData(DateTime.Now);

            IThreadWaiter waiter = ThreadWaiter.GetWaiter(10);

            waiter.Execute(
                /*threadOperationDelegate*/
                delegate
            {
                tokenExchangeResponse = AutoConfig.PlasticCredentials(
                    unityAccessToken,
                    serverName,
                    projectPath);

                if (tokenExchangeResponse.Error != null)
                {
                    return;
                }

                RepositoryInfo repInfo = new BaseCommandsImpl().
                                         GetRepositoryInfo(repId, serverName);

                if (repInfo == null)
                {
                    return;
                }

                repInfo.SetExplicitServer(serverName);

                mWorkspaceInfo = CreateWorkspaceFromCollab.Create(
                    projectPath, repInfo.Name, repInfo,
                    changesetId, branchId,
                    progress);
            },
                /*afterOperationDelegate*/
                delegate
            {
                progressControls.HideProgress();

                if (waiter.Exception != null)
                {
                    DisplayException(progressControls, waiter.Exception);
                    TrackWorkspaceMigrationFinishedFailureEvent(mWorkspaceInfo);
                    return;
                }

                if (tokenExchangeResponse.Error != null)
                {
                    mLog.ErrorFormat(
                        "Unable to get TokenExchangeResponse: {0} [code {1}]",
                        tokenExchangeResponse.Error.Message,
                        tokenExchangeResponse.Error.ErrorCode);
                }

                if (tokenExchangeResponse.Error != null ||
                    mWorkspaceInfo == null)
                {
                    progressControls.ShowError(
                        "Failed to convert your workspace to Plastic SCM");
                    TrackWorkspaceMigrationFinishedFailureEvent(mWorkspaceInfo);
                    return;
                }

                progressControls.ShowSuccess(
                    "Your workspace has been successfully converted to Plastic SCM");

                mIsMigrationCompleted = true;

                TrackFeatureUseEvent.For(
                    PlasticGui.Plastic.API.GetRepositorySpec(mWorkspaceInfo),
                    TrackFeatureUseEvent.Features.WorkspaceMigrationFinishedSuccess);

                afterWorkspaceMigratedAction();
            },
                /*timerTickDelegate*/
                delegate
            {
                UpdateProgress(projectPath, progress, progressControls, progressData);
            });
        }
예제 #3
0
        internal static void CheckinPaths(
            WorkspaceInfo wkInfo,
            List <string> paths,
            string comment,
            IWorkspaceWindow workspaceWindow,
            CheckinDialog dialog,
            GuiMessage.IGuiMessage guiMessage,
            IProgressControls progressControls,
            IMergeViewLauncher mergeViewLauncher)
        {
            BaseCommandsImpl baseCommands = new BaseCommandsImpl();

            progressControls.ShowProgress("Checkin in files");

            IThreadWaiter waiter = ThreadWaiter.GetWaiter(50);

            waiter.Execute(
                /*threadOperationDelegate*/ delegate
            {
                CheckinParams ciParams = new CheckinParams();
                ciParams.paths         = paths.ToArray();
                ciParams.comment       = comment;
                ciParams.time          = DateTime.MinValue;
                ciParams.flags         = CheckinFlags.Recurse | CheckinFlags.ProcessSymlinks;

                baseCommands.CheckIn(ciParams);
            },
                /*afterOperationDelegate*/ delegate
            {
                progressControls.HideProgress();
                ((IPlasticDialogCloser)dialog).CloseDialog();

                if (waiter.Exception is CmClientMergeNeededException ||
                    waiter.Exception is CmClientUpdateMergeNeededException)
                {
                    // we need to explicitly call EditorWindow.Close() to ensure
                    // that the dialog is closed before asking the user
                    dialog.Close();

                    if (!UserWantsToShowIncomingView(guiMessage))
                    {
                        return;
                    }

                    ShowIncomingChanges.FromCheckin(
                        wkInfo,
                        mergeViewLauncher,
                        progressControls);

                    return;
                }

                if (waiter.Exception != null)
                {
                    ExceptionsHandler.DisplayException(waiter.Exception);
                    return;
                }

                workspaceWindow.RefreshView(ViewType.PendingChangesView);
                workspaceWindow.RefreshView(ViewType.HistoryView);
            });
        }
예제 #4
0
        void LaunchMigration(
            string unityAccessToken,
            string projectPath,
            string organizationName,
            RepId repId,
            long changesetId,
            long branchId,
            Action afterWorkspaceMigratedAction,
            IProgressControls progressControls)
        {
            string serverName = string.Format(
                "{0}@cloud", organizationName);

            progressControls.ShowProgress(
                "Migrating project to Plastic SCM...");

            TokenExchangeResponse tokenExchangeResponse = null;
            WorkspaceInfo         workspaceInfo         = null;

            IThreadWaiter waiter = ThreadWaiter.GetWaiter(10);

            waiter.Execute(
                /*threadOperationDelegate*/
                delegate
            {
                // we just migrate a cloud project,
                // so let's assume we're going to use Cloud Edition
                SetupUnityEditionToken.CreateCloudEditionTokenIfNeeded();

                if (!ClientConfig.IsConfigured())
                {
                    AutoConfigClientConf.FromUnityAccessToken(
                        unityAccessToken, serverName, projectPath);
                }

                tokenExchangeResponse = WebRestApiClient.
                                        PlasticScm.TokenExchange(unityAccessToken);

                if (tokenExchangeResponse.Error != null)
                {
                    return;
                }

                CloudEditionWelcomeWindow.JoinCloudServer(
                    serverName,
                    tokenExchangeResponse.User,
                    tokenExchangeResponse.AccessToken);

                RepositoryInfo repInfo = new BaseCommandsImpl().
                                         GetRepositoryInfo(repId, serverName);

                if (repInfo == null)
                {
                    return;
                }

                repInfo.SetExplicitServer(serverName);

                workspaceInfo = CreateWorkspaceFromCollab.Create(
                    projectPath, repInfo.Name, repInfo,
                    changesetId, branchId,
                    new CreateWorkspaceFromCollab.Progress());
            },
                /*afterOperationDelegate*/
                delegate
            {
                progressControls.HideProgress();

                if (waiter.Exception != null)
                {
                    DisplayException(progressControls, waiter.Exception);
                    return;
                }

                if (tokenExchangeResponse.Error != null)
                {
                    mLog.ErrorFormat(
                        "Unable to get TokenExchangeResponse: {0} [code {1}]",
                        tokenExchangeResponse.Error.Message,
                        tokenExchangeResponse.Error.ErrorCode);
                }

                if (tokenExchangeResponse.Error != null ||
                    workspaceInfo == null)
                {
                    progressControls.ShowError(
                        "Failed to migrate the project to Plastic SCM");
                    return;
                }

                progressControls.ShowSuccess(
                    "The project migration to Plastic SCM is completed successfully");

                mIsMigrationCompleted = true;

                afterWorkspaceMigratedAction();
            });
        }