Example #1
0
            internal static void IfRepositoryIsEmpty(
                WorkspaceInfo wkInfo,
                string repository,
                bool isGluonWorkspace,
                IPlasticAPI plasticApi,
                IProgressControls progressControls,
                ICreateWorkspaceListener createWorkspaceListener,
                PlasticWindow plasticWindow)
            {
                RepositoryInfo repInfo           = null;
                bool           isEmptyRepository = false;

                progressControls.ShowProgress(string.Empty);

                IThreadWaiter waiter = ThreadWaiter.GetWaiter(10);

                waiter.Execute(
                    /*threadOperationDelegate*/ delegate
                {
                    RepositorySpec repSpec = new SpecGenerator().
                                             GenRepositorySpec(false, repository);

                    repInfo = plasticApi.GetRepositoryInfo(repSpec);

                    isEmptyRepository = IsEmptyRepositoryCondition.
                                        Evaluate(wkInfo, repSpec, plasticApi);
                },
                    /*afterOperationDelegate*/ delegate
                {
                    progressControls.HideProgress();

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

                    if (!SetupCloudProjectId.HasCloudProjectId())
                    {
                        SetupCloudProjectId.ForRepository(repInfo);
                    }

                    if (!isEmptyRepository)
                    {
                        plasticWindow.RefreshWorkspaceUI();
                        AssetMenu.AssetMenuItems.Enable();
                        return;
                    }

                    CheckinPackagesAndProjectSettingsFolders(
                        wkInfo, isGluonWorkspace, plasticApi,
                        progressControls, createWorkspaceListener);
                });
            }
Example #2
0
        static string GetServerFromRepositoryName(string repositoryName)
        {
            if (string.IsNullOrEmpty(repositoryName))
            {
                return(string.Empty);
            }

            RepositorySpec repSpec = new SpecGenerator().
                                     GenRepositorySpec(false, repositoryName);

            return(repSpec.Server);
        }
Example #3
0
        static void DoNewRepositoryButton(
            Action <RepositoryCreationData> createRepositoryAction,
            EditorWindow parentWindow,
            string repository,
            string defaultServer)
        {
            RepositorySpec repSpec = new SpecGenerator().
                                     GenRepositorySpec(false, repository);

            RepositoryCreationData creationData = CreateRepositoryDialog.CreateRepository(
                parentWindow,
                repSpec.Server,
                defaultServer,
                ClientConfig.Get().GetWorkspaceServer());

            createRepositoryAction(creationData);
        }
Example #4
0
        void IPlasticDialogCloser.CloseDialog()
        {
            ((IProgressControls)mProgressControls).ShowProgress(string.Empty);

            IThreadWaiter waiter = ThreadWaiter.GetWaiter(10);

            waiter.Execute(
                /*threadOperationDelegate*/ delegate
            {
                RepositorySpec repSpec = new SpecGenerator().GenRepositorySpec(
                    false, mWkCreationData.Repository);

                bool repositoryExist = PlasticGui.Plastic.API.CheckRepositoryExists(
                    repSpec.Server, repSpec.Name);

                if (!repositoryExist)
                {
                    PlasticGui.Plastic.API.CreateRepository(repSpec.Server, repSpec.Name);
                }
            },
                /*afterOperationDelegate*/ delegate
            {
                ((IProgressControls)mProgressControls).HideProgress();

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

                mWkCreationData.Result = true;
                mWorkspaceOperations.CreateWorkspace(mWkCreationData);

                // the operation calls IWorkspacesRefreshableView.RefreshAndSelect
                // when the workspace is created
            });
        }
Example #5
0
        static void MergeToMain()
        {
            try
            {
                WorkspaceInfo mWkInfo = FindWorkspace.InfoForApplicationPath(Application.dataPath, Plastic.API);

                if (mWkInfo == null)
                {
                    return;
                }

                RepositorySpec repSpec = Plastic.API.GetRepositorySpec(mWkInfo);
                RepositoryInfo repInfo = Plastic.API.GetRepositoryInfo(repSpec);

                BranchInfo workingBranchInfo = Plastic.API.GetWorkingBranch(mWkInfo);
                BranchInfo mainBranchInfo    = Plastic.API.GetMainBranch(repSpec);

                if (workingBranchInfo.BranchId == mainBranchInfo.BranchId)
                {
                    return;
                }

                SpecGenerator specGenerator   = new SpecGenerator(repInfo);
                BranchSpec    sourceSpec      = specGenerator.GenBranchSpec(false, workingBranchInfo.BranchName);
                BranchSpec    destinationSpec = specGenerator.GenBranchSpec(false, mainBranchInfo.BranchName);

                MergeSource mergeSource = MergeSourceBuilder.BuildMergeSource(repInfo,
                                                                              null, sourceSpec, destinationSpec, new MergeParameters());
                BuildMerge.ApplyMergeForMerge(mWkInfo, null).MergeTo(mergeSource, mMergeComments);
            }
            finally
            {
                string plasticIniFilePah = Path.Combine(Application.dataPath, "../plastic.ini");
                File.Delete(plasticIniFilePah);
            }
        }