private StarTeam CreateStarTeam() { StarTeam starTeam = new StarTeam(); NetReflector.Read(ST_XML, starTeam); return(starTeam); }
/// <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()); } }
/// <summary> Implements base-class abstract function to perform the checkout /// operation on the files in each folder of the tree.</summary> /// <param name="starteamFolder">the StarTeam folder from which files to be checked out</param> /// <param name="targetFolder">the local mapping of rootStarteamFolder</param> protected override void visit(InterOpStarTeam.StFolder starteamFolder, FileInfo targetFolder) { try { if (null == _rootLocalFolder) { Log(Level.Info, "Folder: {0} (Default folder: {1})", starteamFolder.Name, targetFolder); } else { Log(Level.Info, "Folder: {0} (Local folder: {1})", starteamFolder.Name, targetFolder); } System.Collections.Hashtable localFiles = listLocalFiles(targetFolder); // For all Files in this folder, we need to check // if there have been modifications. foreach(InterOpStarTeam.StFile stFile in starteamFolder.getItems("File")) { string filename = stFile.Name; FileInfo localFile = new FileInfo(Path.Combine(targetFolder.FullName,filename)); delistLocalFile(localFiles, localFile); // If the file doesn't pass the include/exclude tests, skip it. if (!IsIncluded(filename)) { continue; } list(stFile, localFile); } // Now we recursively call this method on all sub folders in this // folder unless recursive attribute is off. foreach(InterOpStarTeam.StFolder stFolder in starteamFolder.SubFolders) { FileInfo targetSubfolder = new FileInfo(stFolder.Path); delistLocalFile(localFiles, targetSubfolder); if (this.recursive) { visit(stFolder, targetSubfolder); } } } catch (IOException ex) { throw new BuildException(ex.Message, Location, ex); } }
/// <summary> Adds the file or directpry to the repository.</summary> /// <param name="parentFolder">StarTeam folder underwhich items will be added.</param> /// <param name="file">the file or directory to add</param> /// <returns>true if the file was successfully added otherwise false.</returns> private bool add(InterOpStarTeam.StFolder parentFolder, FileInfo file) { // If the current file is a Directory, we need to process all of its children as well. if (Directory.Exists(file.FullName)) { if(!_createFolders) { Log(Level.Info, "Could not add new folder as createfolders is disabled: {0}", file.FullName); return false; } Log(Level.Info, "Adding new folder to repository: {0}", file.FullName); InterOpStarTeam.StFolder newFolder = starteamFolderFactory.Create(parentFolder); newFolder.Name = file.Name; newFolder.update(); // now visit this new folder to take care of adding any files or subfolders within it. if (this.recursive) { visit(newFolder, file); } } else { Log(Level.Info, "Adding new file to repository: {0}", file.FullName); InterOpStarTeam.StFile newFile = starteamFileFactory.Create(parentFolder); newFile.Add(file.FullName, file.Name, null, _comment, starTeamLockTypeStatics.UNLOCKED, true, true); _updateLabel(newFile); } return true; }
/// <summary> Implements base-class abstract function to perform the checkin operation on the files in each folder of the tree.</summary> /// <param name="starteamFolder">the StarTeam folder to which files will be checked in</param> /// <param name="targetFolder">local folder from which files will be checked in</param> protected override void visit(InterOpStarTeam.StFolder starteamFolder, FileInfo targetFolder) { int notProcessed = 0; int notMatched = 0; try { System.Collections.Hashtable localFiles = listLocalFiles(targetFolder); // If we have been told to create the working folders // For all Files in this folder, we need to check // if there have been modifications. foreach(InterOpStarTeam.StFile stFile in starteamFolder.getItems("File")) { string filename = stFile.Name; FileInfo localFile = new FileInfo(Path.Combine(targetFolder.FullName, filename)); delistLocalFile(localFiles, localFile); // If the file doesn't pass the include/exclude tests, skip it. if (!IsIncluded(filename)) { if(this.Verbose) { Log(Level.Info, "Skipping : {0}",localFile.ToString()); } notMatched++; continue; } // If forced is not set then we may save ourselves some work by looking at the status flag. // Otherwise, we care nothing about these statuses. if (!this.Forced) { int fileStatus = (stFile.Status); // We try to update the status once to give StarTeam another chance. if (fileStatus == starTeamStatusStatics.merge || fileStatus == starTeamStatusStatics.UNKNOWN) { stFile.updateStatus(true, true); fileStatus = (stFile.Status); } if(fileStatus == starTeamStatusStatics.merge) { Log(Level.Info, "Not processing {0} as it needs Merging and Forced is not on.",stFile.toString()); continue; } if (fileStatus == starTeamStatusStatics.CURRENT) { //count files not processed so we can inform later notProcessed++; continue; } } //may want to offer this to be surpressed but usually it is a good idea to have //in the build log what changed for that build. Log(Level.Info, "Checking In: {0}", localFile.ToString()); //check in anything else stFile.checkinFrom(localFile.FullName, _comment, _lockStatus, true, true, true); _updateLabel(stFile); //track files affected for non-verbose output _filesAffected++; } //if we are being verbose emit count of files not processed if(this.Verbose) { if(notProcessed > 0) Log(Level.Info, "{0} : {1} files not processed because they were current.", targetFolder.FullName, notProcessed.ToString()); if(notMatched > 0) Log(Level.Info, "{0} : {1} files not processed because they did not match includes/excludes.", targetFolder.FullName, notMatched.ToString()); } // Now we recursively call this method on all sub folders in this // folder unless recursive attribute is off. foreach (InterOpStarTeam.StFolder stFolder in starteamFolder.SubFolders) { FileInfo targetSubfolder = new FileInfo(stFolder.Path); delistLocalFile(localFiles, targetSubfolder); if (this.recursive) { visit(stFolder, targetSubfolder); } } if (_addUncontrolled) { addUncontrolledItems(localFiles, starteamFolder); } } catch (IOException ex) { throw new BuildException(ex.Message, Location, ex); } }
/// <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);
/// <summary> /// Override of base-class abstract function creates an appropriately configured view. /// For labels this a view configured as of this.lastBuild. /// </summary> /// <param name="raw">the unconfigured <code>View</code></param> /// <returns>the snapshot <code>View</code> appropriately configured.</returns> protected internal override InterOpStarTeam.StView createSnapshotView(InterOpStarTeam.StView raw) { InterOpStarTeam.StView starTeamView; InterOpStarTeam.StViewFactory starTeamViewFactory = new InterOpStarTeam.StViewFactory(); InterOpStarTeam.StViewConfigurationStaticsClass starTeamViewConfiguration = new InterOpStarTeam.StViewConfigurationStaticsClass(); if(_isAsOfDateSet && !_isRevision) { starTeamView = starTeamViewFactory.Create(raw, starTeamViewConfiguration.createFromTime(_labelAsOfDate)); } else { starTeamView = starTeamViewFactory.Create(raw, starTeamViewConfiguration.createTip()); } return starTeamView; }
/// <summary> Derived classes must override this class to define actual processing to be performed on each folder in the tree defined for the task</summary> /// <param name="rootStarteamFolder">the StarTeam folderto be visited</param> /// <param name="rootLocalFolder">the local mapping of rootStarteamFolder</param> protected abstract void visit(InterOpStarTeam.StFolder rootStarteamFolder, FileInfo rootLocalFolder);
private bool getReleaseDataFile(String project, String view, out StarTeam.Item item) { if (project == "" || project == null) { item = null; return false; } Project stProject = m_server.FindProject(project); if (view == "" || view == null) { item = null; return false; } StarTeam.View targetView = findView(stProject, view); if (targetView == null) { item = null; return false; } item = FindInView(m_server, stProject, targetView, "releasedata.xml"); if (item != null) return true; return false; }
private StarTeam.Label[] getLabelFromSubview(StarTeam.View stView, String viewName) { // get a list of labels StarTeam.Label[] Labels = null; if (stView.Name == viewName) { Labels = stView.Labels; } StarTeam.View[] subViews = stView.DerivedViews; if (subViews.Length > 0) { // For each view ... foreach (StarTeam.View subView in subViews) { if (subView.Name == viewName) { Labels = subView.Labels; } } } return Labels; }
private StarTeam.View findSubView(StarTeam.View stView, String viewName) { foreach (StarTeam.View subView in stView.DerivedViews) { if (subView.Name == viewName) return subView; return findSubView(subView, viewName); } return null; }
private StarTeam.Item FindItem(Server stServer, Project stProject, StarTeam.View stView, Item.Type stType, Folder stFolder, Item stItem, String fileName) { StarTeam.Item item = null; File temp = (File)stItem; if (temp.Name == fileName) item = stItem; if (stItem.ToString() == fileName) item = stItem; return item; }
private StarTeam.Item FindInFolder(Server stServer, Project stProject, StarTeam.View stView, Item.Type stType, Folder stFolder, String fileName) { StarTeam.Item item = null; // For each item of the appropriate type ... foreach (Item stItem in stFolder.GetItems(stType)) { item = FindItem(stServer, stProject, stView, stType, stFolder, stItem, fileName); if (item != null) return item; } if (m_bRecursive) { // For each subfolder ... foreach (Folder stSubFolder in stFolder.SubFolders) { item = FindInFolder(stServer, stProject, stView, stType, stSubFolder, fileName); if (item != null && item.ToString() == fileName) return item; } } return item; }
/// <summary> /// Implements base-class abstract function to perform the checkout operation on the files in each folder of the tree. /// </summary> /// <param name="starteamFolder">the StarTeam folder from which files to be checked out</param> /// <param name="targetFolder">the local mapping of the starteam folder</param> protected override void visit(InterOpStarTeam.StFolder starteamFolder, FileInfo targetFolder) { int notProcessed = 0; int notMatched = 0; try { System.Collections.Hashtable localFiles = listLocalFiles(targetFolder); // If we have been told to create the working folders if (_createDirs) { // Create if it doesn't exist bool tmpBool; if (File.Exists(targetFolder.FullName)) tmpBool = true; else tmpBool = Directory.Exists(targetFolder.FullName); if (!tmpBool) { Directory.CreateDirectory(targetFolder.FullName); } } // For all Files in this folder, we need to check // if there have been modifications. foreach(InterOpStarTeam.StFile stFile in starteamFolder.getItems("File")) { string filename = stFile.Name; FileInfo localFile = new FileInfo(Path.Combine(targetFolder.FullName, filename)); delistLocalFile(localFiles, localFile); // If the file doesn't pass the include/exclude tests, skip it. if (!IsIncluded(filename)) { Log(Level.Verbose, "Skipping '{0}'", localFile.ToString()); notMatched++; continue; } // If forced is not set then we may save ourselves some work by // looking at the status flag. // Otherwise, we care nothing about these statuses. if (!this.Forced) { int fileStatus = (stFile.Status); // We try to update the status once to give StarTeam // another chance. if (fileStatus == starTeamStatusStatics.merge || fileStatus == starTeamStatusStatics.UNKNOWN) { stFile.updateStatus(true, true); fileStatus = (stFile.Status); } if(fileStatus == starTeamStatusStatics.merge || fileStatus == starTeamStatusStatics.Modified) { Log(Level.Info, "Not processing '{0}' as it is" + " modified or needs merging and \"forced\"" + " attribute is not set.", stFile.toString()); continue; } if (fileStatus == starTeamStatusStatics.CURRENT) { //count files not processed so we can inform later notProcessed++; continue; } //TODO merged files get processed. We may want to provide a flag to allow merges to be skipped as well //this would help prevent accidental overwrites } // <wisdom source="from the Ant"> // Check out anything else. // Just a note: StarTeam has a status for NEW which implies // that there is an item on your local machine that is not // in the repository. These are the items that show up as // NOT IN VIEW in the Starteam GUI. // One would think that we would want to perhaps checkin the // NEW items (not in all cases! - Steve Cohen 15 Dec 2001) // Unfortunately, the sdk doesn't really work, and we can't // actually see anything with a status of NEW. That is why // we can just check out everything here without worrying // about losing anything. // </wisdom> //may want to offer this to be surpressed but usually it is a good idea to have //in the build log what changed for that build. //debug to skip build files- remove this after include/exclude is added if(localFile.FullName.IndexOf(".build") > 0) continue; Log(Level.Info, "Checking out '{0}'", localFile.ToString()); stFile.checkoutTo(localFile.FullName, _lockStatus, true, true, true); _filesAffected++; } //if we are being verbose emit count of files not processed if(this.Verbose) { if(notProcessed > 0) Log(Level.Info, "{0} : {1} files not processed because they were current.", targetFolder.FullName, notProcessed.ToString()); if(notMatched > 0) Log(Level.Info, "{0} : {1} files not processed because they did not match includes/excludes.", targetFolder.FullName,notMatched.ToString()); } // Now we recursively call this method on all sub folders in this // folder unless recursive attribute is off. foreach (InterOpStarTeam.StFolder stFolder in starteamFolder.SubFolders) { FileInfo targetSubfolder = new FileInfo(stFolder.Path); delistLocalFile(localFiles, targetSubfolder); if (this.recursive) { visit(stFolder, targetSubfolder); } } if (_deleteUncontrolled) { deleteUncontrolledItems(localFiles); } } catch (IOException e) { throw new BuildException(e.Message,Location,e); } }
/// <summary> /// Creates the versionumber.xml file in the repository. /// </summary> /// <param name="stFolder">StarTeam folder desired to put the versionnumber.xml files into</param> /// <returns>StarTeam File handle to the created file.</returns> private InterOpStarTeam.StFile createVersionStFile(InterOpStarTeam.StFolder stFolder) { // instantiated here as they are only necessary when adding InterOpStarTeam.StFileFactoryClass starteamFileFactory = new InterOpStarTeam.StFileFactoryClass(); string versionFilePath = stFolder.getFilePath(_versionFile); // create xml and save to local file try { StreamWriter s = new StreamWriter(versionFilePath, false, System.Text.ASCIIEncoding.ASCII); XmlTextWriter xmlWriter = new XmlTextWriter(s); xmlWriter.WriteStartDocument(false); xmlWriter.WriteStartElement("stautolabel"); xmlWriter.WriteStartElement("version"); xmlWriter.WriteAttributeString("major","1"); xmlWriter.WriteAttributeString("minor","0"); xmlWriter.WriteAttributeString("build","0"); xmlWriter.WriteEndElement(); xmlWriter.WriteEndElement(); xmlWriter.Close(); } catch (System.Security.SecurityException ex) { throw new BuildException(string.Format(CultureInfo.InvariantCulture, "You do not have access to '{0}'.", versionFilePath), Location, ex); } catch (IOException ex) { throw new BuildException(string.Format(CultureInfo.InvariantCulture, "Version filepath '{0}' is invalid.", versionFilePath), Location, ex); } //add local file to starteam InterOpStarTeam.StFile newFile = starteamFileFactory.Create(stFolder); string comment = "version number xml created by stautonumber NAnt task"; newFile.Add(versionFilePath, _versionFile, comment, comment, starTeamLockTypeStatics.UNLOCKED, true, true); return newFile; }
/// <summary> /// Helper method calls on the StarTeam API to retrieve an ID number for the specified view, corresponding to this.label. /// </summary> /// <returns>The Label identifier or <c>-1</c> if no label was provided.</returns> protected virtual InterOpStarTeam.IStLabel getLabelID(InterOpStarTeam.StView stView) { if (null != _label) { foreach(InterOpStarTeam.IStLabel stLabel in stView.Labels) { System.Diagnostics.Trace.WriteLine(stLabel.Name); if (stLabel.Name == _label) { return stLabel; } } throw new BuildException("Error: label " + _label + " does not exist in view",Location); } return null; }
private bool getRevisionFile(String project, String view, out StarTeam.View stView, out StarTeam.Item item) { if (project == "" || project == null) { item = null; stView = null; return false; } Project stProject = m_server.FindProject(project); if ( view == "" || view == null) { item = null; stView = null; return false; } StarTeam.View targetView = stProject.FindView(view); if (targetView == null) { item = null; stView = null; return false; } stView = targetView; item = FindInView(m_server, stProject, targetView, "revision.txt"); if (item != null) return true; return false; }
protected internal virtual void list(InterOpStarTeam.StFile reposFile, FileInfo localFile) { System.Text.StringBuilder b = new System.Text.StringBuilder(); if (null == _rootLocalFolder) { InterOpStarTeam.StStatusStaticsClass starTeamStatus = new InterOpStarTeam.StStatusStaticsClass(); // status is irrelevant to us if we have specified a // root local folder. b.Append(pad(starTeamStatus.Name(reposFile.Status), 12) + " "); } b.Append( pad(getUserName(reposFile.Locker), 20) + " " + reposFile.ModifiedTime.ToShortDateString() + rpad(reposFile.LocalSize.ToString(), 9) + " " + reposFile.Name); Log(Level.Info, b.ToString()); }
private StarTeam.View getRootMarketView(Project stProject, StarTeam.View stView) { StarTeam.View temp = stView.ParentView; StarTeam.View last = stView; while (temp.Name != stProject.DefaultView.Name) { last = temp; temp = last.ParentView; } return last; }
private List<String> getSubviews(StarTeam.View stView) { List<String> list = new List<String>(); if (stView.DerivedViews.Length > 0) { // For each Item Type ... foreach (StarTeam.View v in stView.DerivedViews) { list.Add(" " + v.Name); if (v.DerivedViews.Length > 0) { List<String> subList = new List<String>(); subList = getSubviews(v); } } } return list; }
private bool moveFileToView(StarTeam.Item file, StarTeam.View targetView) { StarTeam.Folder rootFolder = targetView.RootFolder; StarTeam.Folder docFolder = rootFolder.FindSubFolder("documents"); file.MoveTo(docFolder); return false; }
protected void SetUp() { starteam = CreateStarTeam(); }
// ---------------------------------------------------------------------------- // Searches the given folder. // ---------------------------------------------------------------------------- private StarTeam.Item RunFolder(Server stServer, Project stProject, StarTeam.View stView, Item.Type stType, Folder stFolder) { StarTeam.Item item = null; // For each item of the appropriate type ... foreach (Item stItem in stFolder.GetItems(stType)) { item = RunItem(stServer, stProject, stView, stType, stFolder, stItem); if (item != null) return item; } if (m_bRecursive) { // For each subfolder ... foreach (Folder stSubFolder in stFolder.SubFolders) { item = RunFolder(stServer, stProject, stView, stType, stSubFolder); if (item != null && item.ToString() == "revision.txt") return item; } } return item; }
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); } }
// ---------------------------------------------------------------------------- // Processes the given Item. // ---------------------------------------------------------------------------- private StarTeam.Item RunItem(Server stServer, Project stProject, StarTeam.View stView, Item.Type stType, Folder stFolder, Item stItem) { StarTeam.Item item = null; File temp = (File)stItem; if (temp.Name == "revision.txt") item = stItem; if (stItem.ToString() == "revision.txt") item = stItem; return item; }
/// <summary> /// Override of base-class abstract function creates an appropriately configured view. For checkins this is /// always the current or "tip" view. /// </summary> /// <param name="raw">the unconfigured <code>View</code></param> /// <returns>the snapshot <code>View</code> appropriately configured.</returns> protected internal override InterOpStarTeam.StView createSnapshotView(InterOpStarTeam.StView raw) { InterOpStarTeam.StView snapshot; InterOpStarTeam.StViewConfigurationStaticsClass starTeamViewConfiguration = new InterOpStarTeam.StViewConfigurationStaticsClass(); InterOpStarTeam.StViewFactory starTeamViewFactory = new InterOpStarTeam.StViewFactory(); snapshot = starTeamViewFactory.Create(raw, starTeamViewConfiguration.createTip()); if(_label != string.Empty) { _stLabel = this.getLabelID(snapshot); } return snapshot; }
// ---------------------------------------------------------------------------- // Searches the given view for all relevant items of the given type. // ---------------------------------------------------------------------------- private StarTeam.Item RunType(Server stServer, Project stProject, StarTeam.View stView, Item.Type stType) { StarTeam.Item item = null; // By default, start searching from the root folder. Folder stFolder = stView.RootFolder; // If a specfic path was specified, search for it. if (m_strFolder != null) { Folder stTempFolder = stFolder.FindSubFolder(m_strFolder); if (stTempFolder == null) { string strMessage = "Folder \""; strMessage += m_strFolder; strMessage += "\" not found in view \""; strMessage += stView.Name; strMessage += "\" of project \""; strMessage += stProject.Name; strMessage += "\"."; System.Windows.Forms.MessageBox.Show(strMessage, "Folder Not Found", MessageBoxButtons.OK); return null; } stFolder = stTempFolder; } // Pre-fetch the item properties and cache them. int depth = (m_bRecursive ? -1 : 0); stFolder.Populate(stType, depth); // Now, search for items in the selected folder. RunFolder(stServer, stProject, stView, stType, stFolder); // Free up the memory used by the cached items. stFolder.DiscardItems(stType, depth); // Now, search for items in the selected folder. item = RunFolder(stServer, stProject, stView, stType, stFolder); // Free up the memory used by the cached items. stFolder.DiscardItems(stType, depth); return item; }
/// <summary> Adds to the StarTeam repository everything on the local machine that is not currently in the repository.</summary> /// <param name="localFiles">Hasttable containing files missing in the repository for the current folder</param> /// <param name="folder">StarTeam folder to which these items are to be added.</param> private void addUncontrolledItems(System.Collections.Hashtable localFiles, InterOpStarTeam.StFolder folder) { try { foreach(string fileName in localFiles.Keys) { FileInfo file = new FileInfo(fileName); add(folder, file); } } //TODO: Move security catch into add() catch (System.Security.SecurityException e) { Log(Level.Error, "Error adding file: {0}", e.Message); } }
// ---------------------------------------------------------------------------- // Searches the given view. // ---------------------------------------------------------------------------- private StarTeam.Item RunView(Server stServer, Project stProject, StarTeam.View stView) { StarTeam.Item item = null; // For each Item Type ... foreach (DictionaryEntry e in m_stItemTypes) { Item.Type stType = (Item.Type)e.Value; item = RunType(stServer, stProject, stView, stType); } return item; }
private void _updateLabel(InterOpStarTeam.StFile stFile) { //if user defined a label attach the item checked to that label if (_stLabel != null) { _stLabel.moveLabelToItem((InterOpStarTeam.StItem)stFile); _stLabel.update(); } }
/// <summary> /// Locate the <c>versionnumber.xml</c> file in the repository. If it /// is not present, the file is created. The file is checked out /// exclusively for editing. /// </summary> /// <param name="snapshot">StarTeam view we are working with.</param> /// <returns> /// StarTeam file handle containing version xml. /// </returns> private InterOpStarTeam.StFile getVersionStFile(InterOpStarTeam.StView snapshot) { InterOpStarTeam.StFile stVersionFile = null; //connect to starteam and get root folder InterOpStarTeam.StFolder starTeamRootFolder = snapshot.RootFolder; //get contents of root folder and look for version file //this is weird as I cannot see how to ask StarTeam for an individual file foreach(InterOpStarTeam.StFile stFile in starTeamRootFolder.getItems("File")) { if (stFile.Name == _versionFile) { stVersionFile = stFile; break; } } if (stVersionFile == null) { stVersionFile = createVersionStFile(starTeamRootFolder); } else { stVersionFile.checkout(starTeamLockTypeStatics.EXCLUSIVE, true, true, true); } return stVersionFile; }