Пример #1
0
        /// <summary>
        /// Does the work of opening the supplied Starteam view and calling
        /// the <see cref="visit"/> method setting the pattern in motion to perform the task.
        /// </summary>
        protected override void ExecuteTask()
        {
            _filesAffected = 0;
            testPreconditions();

            InterOpStarTeam.StView snapshot = openView();
            try {
                InterOpStarTeam.StStarTeamFinderStatics starTeamFinder = new InterOpStarTeam.StStarTeamFinderStatics();
                InterOpStarTeam.StFolder starTeamRootFolder            = starTeamFinder.findFolder(snapshot.RootFolder, _rootStarTeamFolder);

                // set the local folder.
                FileInfo localrootfolder;

                if (null == starTeamRootFolder)
                {
                    throw new BuildException("Unable to find root folder in repository.", Location);
                }
                if (null == _rootLocalFolder)
                {
                    // use Star Team's default
                    try {
                        localrootfolder = new FileInfo(starTeamRootFolder.Path);
                    }
                    catch (Exception e) {
                        throw new BuildException(string.Format("Could not get handle to root folder ({0}) found.", starTeamRootFolder.Path), Location, e);
                    }
                }
                else
                {
                    // force StarTeam to use our folder
                    try {
                        Log(Level.Info, "Overriding local folder to '{0}'", _rootLocalFolder);
                        localrootfolder = new FileInfo(_rootLocalFolder);
                    } catch (Exception e) {
                        throw new BuildException(string.Format("Could not get handle to root folder '{0}'.",
                                                               starTeamRootFolder.Path), Location, e);
                    }
                }

                // Inspect everything in the root folder and then recursively
                visit(starTeamRootFolder, localrootfolder);
                Log(Level.Info, "{0} files affected", _filesAffected.ToString());
            } catch (System.Exception e) {
                throw new BuildException(e.Message, Location, e);
            }
        }
Пример #2
0
        /// <summary>
        /// Override of base-class abstract function creates an appropriately configured view for checkoutlists.
        /// The current view or a view of the label specified <see cref="TreeBasedTask.Label" />.
        /// </summary>
        /// <param name="raw">the unconfigured <c>View</c></param>
        /// <returns>the snapshot <c>View</c> appropriately configured.</returns>
        protected override internal InterOpStarTeam.StView createSnapshotView(InterOpStarTeam.StView raw)
        {
            InterOpStarTeam.StViewConfigurationStaticsClass starTeamViewConfiguration = new InterOpStarTeam.StViewConfigurationStaticsClass();
            InterOpStarTeam.StViewFactory starTeamViewFactory = new InterOpStarTeam.StViewFactory();
            InterOpStarTeam.IStLabel      stLabel             = getLabelID(raw);

            // if a label has been supplied, use it to configure the view
            // otherwise use current view
            if (stLabel != null)
            {
                return(starTeamViewFactory.Create(raw, starTeamViewConfiguration.createFromLabel(stLabel.ID)));
            }
            else
            {
                return(starTeamViewFactory.Create(raw, starTeamViewConfiguration.createTip()));
            }
        }
Пример #3
0
        protected virtual InterOpStarTeam.StLabel createLabel(InterOpStarTeam.StView snapshot)
        {
            InterOpStarTeam.StLabel             newLabel;
            InterOpStarTeam.StLabelFactoryClass starTeamLabelFactory = new InterOpStarTeam.StLabelFactoryClass();

            // Create the new label and update the repository
            try {
                //default is view label
                if (_isRevision)
                {
                    newLabel = starTeamLabelFactory.CreateRevisionLabel(snapshot, _labelName, _description);
                }
                else
                {
                    newLabel = starTeamLabelFactory.CreateViewLabel(snapshot, _labelName, _description, _labelAsOfDate, _isBuildLabel);
                }
                newLabel.update();

                string sLabelType;
                if (this._isRevision)
                {
                    sLabelType = "Revision";
                }
                else
                {
                    sLabelType = (this._isBuildLabel ? "View Build" : "View");
                }

                Log(Level.Info, "Created '{0}' label '{1}'",
                    sLabelType, _labelName);

                return(newLabel);
            } catch (Exception ex) {
                throw new BuildException(string.Format("Creating label '{0}' failed.",
                                                       _labelName), Location, ex);
            }
        }
Пример #4
0
 /// <summary>
 /// This method does the work of creating the new view and checking it
 /// into Starteam.
 /// </summary>
 protected override void  ExecuteTask()
 {
     InterOpStarTeam.StView snapshot = openView();
     createLabel(snapshot);
 }
Пример #5
0
        /// <summary>
        /// Looks for versionnumber.xml at root of repository.
        /// Updates the xml in this file to correspond with properties set by user and checks in changes.
        /// A label is then created based on properties set.
        /// </summary>
        /// <remarks>
        /// Default behavior is to <see cref="IncrementBuild"/> number.
        /// If user sets <see cref="MajorVersion"/>, <see cref="MinorVersion"/>, or <see cref="BuildVersion"/> no incrementing is done
        /// and the exact version set and/or read from versionnumber.xml is used.
        /// <para>The title of the Label is the <see cref="LabelTask.Label"/> property concatenated with the version number Major.Minor.Build</para>
        /// </remarks>
        protected override void  ExecuteTask()
        {
            InterOpStarTeam.StView snapshot = openView();
            InterOpStarTeam.StFile stFile   = getVersionStFile(snapshot);

            try {
                //load xml document find versions and save incremented version
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load(stFile.FullName);
                XmlNode nodeVersion = xmlDoc.DocumentElement.SelectSingleNode("version");
                if (_versionMajor < 0)
                {
                    _versionMajor = Convert.ToInt32(nodeVersion.Attributes.GetNamedItem("major").InnerText);
                }
                if (_versionMinor < 0)
                {
                    _versionMinor = Convert.ToInt32(nodeVersion.Attributes.GetNamedItem("minor").InnerText);
                }
                if (_versionBuild < 0)
                {
                    _versionBuild = Convert.ToInt32(nodeVersion.Attributes.GetNamedItem("build").InnerText);
                }

                if (_doIncrement == true)
                {
                    if (_incrementMajor == true)
                    {
                        _versionMajor++;
                    }
                    if (_incrementMinor == true)
                    {
                        _versionMinor++;
                    }
                    if (_incrementBuild == true)
                    {
                        _versionBuild++;
                    }
                }
                nodeVersion.Attributes.GetNamedItem("major").InnerText =
                    _versionMajor.ToString(CultureInfo.InvariantCulture);
                nodeVersion.Attributes.GetNamedItem("minor").InnerText =
                    _versionMinor.ToString(CultureInfo.InvariantCulture);
                nodeVersion.Attributes.GetNamedItem("build").InnerText =
                    _versionBuild.ToString(CultureInfo.InvariantCulture);
                xmlDoc.Save(stFile.FullName);
            } catch (XmlException ex) {
                throw new BuildException("Error parsing / updating version xml",
                                         Location, ex);
            }

            stFile.checkin("version updated via stautolabel", starTeamLockTypeStatics.UNLOCKED,
                           true, true, true);
            this.Label = string.Format(CultureInfo.InvariantCulture,
                                       "{0}{1}.{2}.{3}", this.Label, _versionMajor, _versionMinor,
                                       _versionBuild);
            this.Properties["label"]        = this.Label;
            this.Properties["Version.text"] = _versionMajor.ToString(CultureInfo.InvariantCulture) + "."
                                              + _versionMinor.ToString(CultureInfo.InvariantCulture) + "."
                                              + _versionBuild.ToString(CultureInfo.InvariantCulture);
            this.Properties["Version.major"] = _versionMajor.ToString(CultureInfo.InvariantCulture);
            this.Properties["Version.minor"] = _versionMinor.ToString(CultureInfo.InvariantCulture);
            this.Properties["Version.build"] = _versionBuild.ToString(CultureInfo.InvariantCulture);

            createLabel(snapshot);
        }
Пример #6
0
 /// <summary>
 /// Derived classes must override this method to instantiate a view configured appropriately to its task.
 /// </summary>
 /// <param name="rawview">the unconfigured <code>View</code></param>
 /// <returns>the view appropriately configured.</returns>
 protected internal abstract InterOpStarTeam.StView createSnapshotView(InterOpStarTeam.StView rawview);