private ChangesetVersionSpec ConvertToChangesetSpec(LabelVersionSpec spec)
        {
            VersionControlLabel Label = this.ServerConnection.SourceControl.QueryLabels(spec.Label, spec.Scope, null, true)[0];
            int HighestChangesetId    = 0;

            foreach (Item item in Label.Items)
            {
                if (HighestChangesetId < item.ChangesetId)
                {
                    HighestChangesetId = item.ChangesetId;
                }
            }
            return(new ChangesetVersionSpec(HighestChangesetId));
        }
Exemple #2
0
        public void LabelSourceControl(IIntegrationResult result)
        {
            if (ApplyLabel && result.Succeeded)
            {
                Log.Debug(String.Format("Applying label \"{0}\"", result.Label));
                VersionControlLabel Label = new VersionControlLabel(this.SourceControl, result.Label, _SourceControl.AuthenticatedUser, this.ProjectPath, "Labeled by CruiseControl.NET");

                Changeset Set = this.ChangesetQueue.GetCurrentIntegrationSet();

                LabelItemSpec[] LabelSpec = new LabelItemSpec[] {
                    new LabelItemSpec(new ItemSpec(this.ProjectPath, RecursionType.Full), new ChangesetVersionSpec(Set.ChangesetId), false)
                };

                this.SourceControl.CreateLabel(Label, LabelSpec, LabelChildOption.Replace);
            }
            this.ChangesetQueue.EndIntegration();
        }
Exemple #3
0
        private void PerformLabel(SourceProject project, IIntegrationResult result)
        {
            if (project.ApplyLabel)
            {
                Log.Debug(String.Format("Applying label \"{0}\" on project \"{1}\"", result.Label, project.ProjectPath));

                string comment = result.StartTime.ToString() + " on " + project.ProjectPath;

                VersionControlLabel vcLabel = new VersionControlLabel(
                    this.SourceControl, result.Label, this.SourceControl.AuthorizedUser,
                    project.ProjectPath, comment);

                // Create Label Item Spec.
                ItemSpec itemSpec = new ItemSpec(project.ProjectPath, RecursionType.Full);

                LabelItemSpec[] labelItemSpec = new LabelItemSpec[] {
                    new LabelItemSpec(itemSpec, new DateVersionSpec(result.StartTime), false)
                };

                this.SourceControl.CreateLabel(vcLabel, labelItemSpec, LabelChildOption.Replace);
            }
        }
Exemple #4
0
 public ChangeSetLabelObject(VersionControlLabel oLabel)
 {
     m_dtCreationDate = oLabel.LastModifiedDate;
     m_bIsLabel       = true;
     m_oLabel         = oLabel;
 }
Exemple #5
0
        //Creates a BatchScriptCreater and does the merging or makes a file
        public void CreateBranchAndMerge(System.Collections.ICollection historyAndLabelList, String szPatchPath, String szBranchPath, String szTrunkPath, VersionControlLabel trunkLabel, String szBatchFileName)
        {
            VersionControlServer sourceControl = null;
            Workspace            workspace     = null;

            //
            GetPathAndScope(szPatchPath, out sourceControl, out workspace);
        }
Exemple #6
0
        /// <summary>
        /// Création d'un label lors de la publication
        /// </summary>
        /// <param name="model"></param>
        private void CreateLabel(CandleModel model, string modelFileName)
        {
            if (model == null || modelFileName == null)
            {
                return;
            }

            try
            {
                DTE dte = GetService <DTE>();

                string solutionFolder = Path.GetDirectoryName(modelFileName);

                // Récupère les caractèristiques du workspace contenant le fichier contenant le modèle
                if (Workstation.Current == null)
                {
                    throw new Exception("TFS not installed");
                }

                WorkspaceInfo wi = Workstation.Current.GetLocalWorkspaceInfo(solutionFolder);
                if (wi == null)
                {
                    LogError("The current solution is not in a Team System workspace");
                    return;
                }

                // Récupèration du server TFS à partir des infos du workspace
                TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer(wi.ServerUri.AbsoluteUri);

                // Création d'un label sur la solution
                VersionControlServer vcs = tfs.GetService(typeof(VersionControlServer)) as VersionControlServer;
                vcs.NonFatalError += new ExceptionEventHandler(vcs_NonFatalError);
                // On prend tous les fichiers de la solution
                ItemSpec      itemSpec      = new ItemSpec(solutionFolder, RecursionType.Full);
                LabelItemSpec labelItemSpec = new LabelItemSpec(itemSpec, VersionSpec.Latest, false);

                string changeSet = "-";
                // Calcul du nom du label
                string labelName = String.Format(labelNameFormat, DateTime.Now, wi.OwnerName, wi.Computer, model.Version, model.Version.Revision, changeSet);
                // Calcul du commentaire
                string labelComment = String.Format(labelCommentFormat, DateTime.Now, wi.OwnerName, wi.Computer, model.Version, model.Version.Revision, changeSet);

                //Checkin
                if (forceCheckin)
                {
                    Workspace ws = wi.GetWorkspace(tfs);

                    PendingChange[] pendingChanges = ws.GetPendingChanges(new ItemSpec[] { itemSpec }, false);
                    if (pendingChanges.Length > 0)
                    {
                        changeSet = ws.CheckIn(pendingChanges, labelComment).ToString();

                        // Mise à jour de l'explorateur de solution (icones)
                        Microsoft.VisualStudio.Shell.ServiceProvider serviceProvider = new Microsoft.VisualStudio.Shell.ServiceProvider((Microsoft.VisualStudio.OLE.Interop.IServiceProvider)dte);
                        IVersionControlProvider versionControlProvider = (IVersionControlProvider)serviceProvider.GetService(typeof(IVersionControlProvider));
                        if (versionControlProvider != null)
                        {
                            versionControlProvider.RefreshStatus();
                        }

                        // On intègre le changeset dans le commentaire
                        labelName    = String.Format(labelNameFormat, DateTime.Now, wi.OwnerName, wi.Computer, model.Version, model.Version.Revision, changeSet);
                        labelComment = String.Format(labelCommentFormat, DateTime.Now, wi.OwnerName, wi.Computer, model.Version, model.Version.Revision, changeSet);
                    }
                }

                string scope;
                string label;
                LabelSpec.Parse(labelName, null, false, out label, out scope);
                VersionControlLabel vcl = new VersionControlLabel(vcs, label, null, scope, labelComment);

                // Et on applique le label.
                LabelResult[] results = vcs.CreateLabel(vcl, new LabelItemSpec[] { labelItemSpec }, childOption);
            }
            catch (Exception ex)
            {
                LogError(ex);
                nbErrors++;
            }

            if (nbErrors > 0 && stopOnError)
            {
                throw new PublishingException();
            }
        }