Ejemplo n.º 1
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);
            }
        }