private void GetFromTfs(string path) { var item = new ItemSpec(_remote.TfsRepositoryPath + "/" + path, RecursionType.None); _workspace.Get(new GetRequest(item, (int) _contextVersion.ChangesetId), GetOptions.Overwrite | GetOptions.GetAll); }
public ChangeRequest(string path, string target, RequestType requestType, ItemType itemType) { this.item = new ItemSpec(path, RecursionType.None); this.target = target; this.requestType = requestType; this.itemType = itemType; }
public override void Run() { if (Arguments.Length < 3) { Console.WriteLine("Usage: tf label <label> <itemSpec>"); Environment.Exit((int)ExitCode.Failure); } string labelName = Arguments[0]; string itemPath = Path.GetFullPath(Arguments[2]); // parse arguments LabelChildOption childOption = (LabelChildOption) Enum.Parse(typeof(LabelChildOption), OptionChild, true); RecursionType rtype = OptionRecursive ? RecursionType.Full : RecursionType.None; ItemSpec itemSpec = new ItemSpec(itemPath, rtype); VersionControlLabel label = new VersionControlLabel(VersionControlServer, labelName, OwnerFromString(OptionOwner), null, OptionComment); List<LabelItemSpec> labelItemSpecs = new List<LabelItemSpec>(); Workspace workspace = GetWorkspaceFromCache(); labelItemSpecs.Add(new LabelItemSpec(itemSpec, new WorkspaceVersionSpec(workspace), false)); LabelResult[] results = VersionControlServer.CreateLabel(label, labelItemSpecs.ToArray(), childOption); foreach (LabelResult result in results) { Console.WriteLine("{0} label {1}@{2}", result.Status, result.Label, result.Scope); } }
protected async override void LoadChildren() { if (Item == null || Item.ItemType == ItemType.File) return; ItemSet itemSet = null; await Task.Run(() => { ItemSpec spec = new ItemSpec(Item.ServerItem, RecursionType.OneLevel); itemSet = TfsShared.Instance.Vcs.GetItems(spec, VersionSpec.Latest, DeletedState.Any, ItemType.Any, GetItemsOptions.IncludeBranchInfo); }); foreach (Item item in itemSet.Items.OrderByDescending(f => f.ItemType == ItemType.Folder)) { if (item.ItemId == this.Item.ItemId) continue; SourceControlItem srcItem = new SourceControlItem(item); if (item.ItemType == ItemType.File) srcItem.IsExpanded = true; base.Children.Add(srcItem); } ScanFullSize(); }
public ChangeRequest(string path, RequestType requestType, ItemType itemType, RecursionType recursion, LockLevel lockLevel) { this.item = new ItemSpec(path, recursion); this.requestType = requestType; this.itemType = itemType; this.lockLevel = lockLevel; }
private Microsoft.TeamFoundation.VersionControl.Client.Item[] ItemsForPath(string path) { ItemSpec itemSpec = new ItemSpec (path, RecursionType.OneLevel); ItemSet itemSet = driver.VersionControlServer.GetItems (itemSpec, VersionSpec.Latest, DeletedState.NonDeleted, ItemType.Any, false); return itemSet.Items; }
public async Task ScanFullSize() { this.Size = " - Calculating size..."; await Task.Run(() => { ItemSpec spec = new ItemSpec(Item.ServerItem, RecursionType.Full); ItemSet itemSet = TfsShared.Instance.Vcs.GetItems(spec, VersionSpec.Latest, DeletedState.Any,ItemType.Any, false); this.Size = string.Format(new FileSizeFormatProvider(), " - Size: {0:fs}", itemSet.Items.Sum(i => i.ContentLength)); return; }); }
public static string GetDeploymentItems(string teamProjectName, string buildType) { string workspaceDirectory = SourceCodeControlHelper.GetWorkspaceDirectory("TFSDeployerConfiguration2"); TeamProject teamProject = GetTeamProject(teamProjectName); ItemSpec configurationFileItemSpec = new ItemSpec(string.Format(ConfigurationFileLocation,teamProject.ServerItem,buildType),RecursionType.Full); VersionSpec version = VersionSpec.Latest; GetRequest[] request = new GetRequest[] { new GetRequest(configurationFileItemSpec, version) }; string directoryToPlaceFiles = string.Format(ConfigurationFileLocation, teamProject.ServerItem, buildType); TraceHelper.TraceInformation(TraceSwitches.TfsDeployer, "Getting file from {0} to {1}",workspaceDirectory,directoryToPlaceFiles); SourceCodeControlHelper.GetLatestFromSourceCodeControl(directoryToPlaceFiles, workspaceDirectory, request); return workspaceDirectory; }
public override void Run() { string path = Environment.CurrentDirectory; if (Arguments.Length > 0) path = Path.GetFullPath(Arguments[0]); char[] charsToTrim = { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar}; string fxdPath = path.TrimEnd(charsToTrim); string itemPath = Path.Combine(path, "*"); Workspace workspace = GetWorkspaceFromCache(); workspace.RefreshMappings(); string serverPath = workspace.GetServerItemForLocalItem(fxdPath); // pull item list based on WorkspaceVersion. otherwise might get // new items on server that haven't been pulled yet in the list returned WorkspaceVersionSpec version = new WorkspaceVersionSpec(workspace); // process command options ItemSpec itemSpec = new ItemSpec(itemPath, RecursionType.Full); ItemSet itemSet = VersionControlServer.GetItems(itemSpec, version, DeletedState.NonDeleted, ItemType.Any, true); Item[] items = itemSet.Items; SortedList<string, bool > itemList = new SortedList<string, bool >(PathComparer); foreach (Item item in items) { string serverItem = item.ServerItem.Remove(0, serverPath.Length+1); string fname = Path.Combine(path, serverItem); //Console.WriteLine(serverItem + " : " + fname); itemList.Add(fname, true); } DirectoryInfo dir = new DirectoryInfo(path); foreach (FileInfo file in dir.GetFiles("*", SearchOption.AllDirectories)) { if (!itemList.ContainsKey(file.FullName)) { if (OptionPreview) Console.WriteLine(file.FullName); else DeleteReadOnlyFile(file.FullName); } } }
public override void Run() { string path = Environment.CurrentDirectory; if (Arguments.Length > 0) path = Arguments[0]; if (!VersionControlPath.IsServerItem(path)) path = Path.GetFullPath(path); // process command options RecursionType rtype = OptionRecursive ? RecursionType.Full : RecursionType.OneLevel; DeletedState dstate = OptionDeleted ? DeletedState.Any : DeletedState.NonDeleted; ItemSpec itemSpec = new ItemSpec(path, rtype); ItemSet itemSet = VersionControlServer.GetItems(itemSpec, VersionFromString(OptionVersion), dstate, ItemType.Any, false); Item[] items = itemSet.Items; foreach (Item item in items) { Console.Write(item.ServerItem); if ((item.ItemType == ItemType.Folder) && (!item.ServerItem.EndsWith(Path.DirectorySeparatorChar.ToString()))) Console.Write("/"); Console.WriteLine(); } Console.WriteLine(items.Length + " item(s)"); }
public LabelItemSpec(ItemSpec itemSpec, VersionSpec version, bool exclude) { this.itemSpec = itemSpec; this.version = version; this.exclude = exclude; }
/// <summary> /// gestore branch /// </summary> public static void VersionControl(String tfsName) { using (var tfs = new TfsTeamProjectCollection(new Uri(tfsName), Cred)) { var vc = tfs.GetService<VersionControlServer>(); ItemSpec[] itemSpec = new ItemSpec[1]; itemSpec[0] = new ItemSpec( @"$/Formazione ALM/", RecursionType.Full); BranchHistoryTreeItem[][] branchHistoryTree = vc.GetBranchHistory(new ItemSpec[] { new ItemSpec(@"$/Formazione ALM/", RecursionType.Full) }, LatestVersionSpec.Latest); foreach (BranchHistoryTreeItem[] tia in branchHistoryTree) { foreach (BranchHistoryTreeItem ti in tia) { Console.WriteLine(ti.Relative.ToString()); } } } }
/// <summary> /// accesso alle solution c# del progetto /// </summary> /// <param name="server"> /// server TFS /// </param> /// <param name="project"> /// progetto in oggetto /// </param> /// <returns> /// lista di item relativi alle solution /// </returns> public static List<ExtendedItem> Button1_Click(TfsTeamProjectCollection server, string project) { try { // get project folder structure var path = "$/" + project; var sourceControl = (VersionControlServer)server.GetService(typeof(VersionControlServer)); var pattern = "*.sln"; var miItemSpec = new ItemSpec[] { new ItemSpec(path + "/" + pattern, RecursionType.Full) }; // Get the latest version of the information for the items. var items = sourceControl.GetExtendedItems(miItemSpec, DeletedState.NonDeleted, ItemType.File)[0]; return items.ToList(); } catch (Exception exception) { Console.WriteLine(exception.Message); Logger.Fatal(new LogInfo(System.Reflection.MethodBase.GetCurrentMethod(), "INT", string.Format("errore in fase di cancellazione Workspace: {0}", exception.Message))); throw exception; } }
public Item GetItem(string path, VersionSpec versionSpec, int deletionId, bool includeDownloadInfo) { ItemSpec itemSpec = new ItemSpec(path, RecursionType.None); ItemSet itemSet = GetItems(itemSpec, versionSpec, DeletedState.NonDeleted, ItemType.Any, includeDownloadInfo); Item[] items = itemSet.Items; if (items.Length > 0) return items[0]; return null; }
public ItemSet GetItems(ItemSpec itemSpec, VersionSpec versionSpec, DeletedState deletedState, ItemType itemType, bool includeDownloadInfo) { List<ItemSpec> itemSpecs = new List<ItemSpec>(); itemSpecs.Add(itemSpec); ItemSet[] itemSet = GetItems(itemSpecs.ToArray(), versionSpec, deletedState, itemType, includeDownloadInfo); return itemSet[0]; }
public ChangeRequest(string path, RequestType requestType, ItemType itemType) { this.item = new ItemSpec(path, RecursionType.None); this.requestType = requestType; this.itemType = itemType; }
public void Workspace_GetItems1() { // need TFS_ envvars for this test if (String.IsNullOrEmpty(tfsUrl)) return; TeamFoundationServer tfs = new TeamFoundationServer(tfsUrl, credentials); VersionControlServer vcs = (VersionControlServer) tfs.GetService(typeof(VersionControlServer)); string itemPath = String.Format("$/{0}/*", Environment.GetEnvironmentVariable("TFS_PROJECT")); ItemSpec itemSpec = new ItemSpec(itemPath, RecursionType.OneLevel); ItemSet itemSet = vcs.GetItems(itemSpec, VersionSpec.Latest, DeletedState.NonDeleted, ItemType.Any, true); Item[] items = itemSet.Items; foreach (Item item in items) { Assert.IsNotNull(item.ServerItem); } }
public LabelResult[] UnlabelItem(string labelName, string labelScope, ItemSpec[] itemSpecs, VersionSpec version) { Workspace workspace = GetWorkspace(itemSpecs[0].Item); return repository.UnlabelItem(workspace, labelName, labelScope, itemSpecs, version); }
public ChangesetMerge[] QueryMerges(string sourcePath, VersionSpec sourceVersion, string targetPath, VersionSpec targetVersion, VersionSpec versionFrom, VersionSpec versionTo, RecursionType recursion) { string workspaceName = String.Empty; string workspaceOwner = String.Empty; if (!VersionControlPath.IsServerItem(targetPath)) { WorkspaceInfo info = Workstation.Current.GetLocalWorkspaceInfo(targetPath); if (info != null) { workspaceName = info.Name; workspaceOwner = info.OwnerName; } } ItemSpec sourceItem = null; if (!String.IsNullOrEmpty(sourcePath)) sourceItem = new ItemSpec(sourcePath, recursion); ItemSpec targetItem = new ItemSpec(targetPath, recursion); ChangesetMerge[] merges = repository.QueryMerges(workspaceName, workspaceOwner, sourceItem, sourceVersion, targetItem, targetVersion, versionFrom, versionTo, Int32.MaxValue); return merges; }
public IEnumerable QueryHistory(string path, VersionSpec version, int deletionId, RecursionType recursion, string user, VersionSpec versionFrom, VersionSpec versionToOrig, int maxCount, bool includeChanges, bool slotMode, bool includeDownloadInfo) { ItemSpec itemSpec = new ItemSpec(path, recursion, deletionId); string workspaceName = String.Empty; string workspaceOwner = String.Empty; if (!VersionControlPath.IsServerItem(itemSpec.Item)) { WorkspaceInfo info = Workstation.Current.GetLocalWorkspaceInfo(itemSpec.Item); if (info != null) { workspaceName = info.Name; workspaceOwner = info.OwnerName; } } List<Changeset> changes = new List<Changeset>(); int total = maxCount; VersionSpec versionTo = versionToOrig; while (total > 0) { int batchMax = Math.Min(256, total); int batchCnt = repository.QueryHistory(workspaceName, workspaceOwner, itemSpec, version, user, versionFrom, versionTo, batchMax, includeChanges, slotMode, includeDownloadInfo, ref changes); if (batchCnt < batchMax) break; total -= batchCnt; Changeset lastChangeset = changes[changes.Count - 1]; versionTo = new ChangesetVersionSpec(lastChangeset.ChangesetId - 1); } return changes.ToArray(); }
public ItemSet[] GetItems(ItemSpec[] itemSpecs, VersionSpec versionSpec, DeletedState deletedState, ItemType itemType, bool includeDownloadInfo) { if (itemSpecs.Length == 0) return null; string workspaceName = String.Empty; string workspaceOwner = String.Empty; string item = itemSpecs[0].Item; if (!VersionControlPath.IsServerItem(item)) { WorkspaceInfo info = Workstation.Current.GetLocalWorkspaceInfo(item); if (info != null) { workspaceName = info.Name; workspaceOwner = info.OwnerName; } } return repository.QueryItems(workspaceName, workspaceOwner, itemSpecs, versionSpec, deletedState, itemType, includeDownloadInfo); }
public LabelResult[] UnlabelItem(Workspace workspace, string labelName, string labelScope, ItemSpec[] itemSpecs, VersionSpec version) { Message msg = new Message(GetWebRequest (new Uri(Url)), "UnlabelItem"); msg.Body.WriteElementString("workspaceName", workspace.Name); msg.Body.WriteElementString("workspaceOwner", workspace.OwnerName); msg.Body.WriteElementString("labelName", labelName); if (!String.IsNullOrEmpty(labelScope)) msg.Body.WriteElementString("labelScope", labelScope); msg.Body.WriteStartElement("items"); foreach (ItemSpec itemSpec in itemSpecs) { itemSpec.ToXml(msg.Body, "ItemSpec"); } msg.Body.WriteEndElement(); version.ToXml(msg.Body, "version"); List<LabelResult> labelResults = new List<LabelResult>(); List<Failure> faillist = new List<Failure>(); using (HttpWebResponse response = Invoke(msg)) { XmlReader results = msg.ResponseReader(response); while (results.Read()) { if (results.NodeType == XmlNodeType.Element) { switch (results.Name) { case "LabelResult": labelResults.Add(LabelResult.FromXml(this, results)); break; case "Failure": faillist.Add(Failure.FromXml(this, results)); break; } } } } foreach (Failure failure in faillist) { versionControlServer.OnNonFatalError(workspace, failure); } return labelResults.ToArray(); }
public bool TryWorkspaceUnshelve(Workspace workspace, out Shelveset shelveset, string shelvesetName, string shelvesetOwner, ItemSpec[] items = null) { try { shelveset = _teamPilgrimTfsService.WorkspaceUnshelve(workspace, shelvesetName, shelvesetOwner, items); return true; } catch (Exception ex) { this.Logger().DebugException(ex); LastException = ex; } shelveset = null; return false; }
public GetOperation[] UndoPendingChanges(string workspaceName, string ownerName, ItemSpec[] itemSpecs) { Message msg = new Message(GetWebRequest (new Uri(Url)), "UndoPendingChanges"); msg.Body.WriteElementString("workspaceName", workspaceName); msg.Body.WriteElementString("ownerName", ownerName); msg.Body.WriteStartElement("items"); foreach (ItemSpec item in itemSpecs) { item.ToXml(msg.Body, "ItemSpec"); } msg.Body.WriteEndElement(); List<GetOperation> operations = new List<GetOperation>(); using (HttpWebResponse response = Invoke(msg)) { XmlReader results = msg.ResponseReader(response); while (results.Read()) { if (results.NodeType == XmlNodeType.Element && results.Name == "GetOperation") operations.Add(GetOperation.FromXml(ItemUrl, results)); } } return operations.ToArray(); }
public bool TryWorkspaceQueryShelvedChanges(Workspace workspace, out PendingSet[] pendingSets, string shelvesetName, string shelvesetOwner, ItemSpec[] itemSpecs) { try { pendingSets = _teamPilgrimTfsService.WorkspaceQueryShelvedChanges(workspace, shelvesetName, shelvesetOwner, itemSpecs); return true; } catch (ShelvesetNotFoundException) { pendingSets = null; return true; } catch (Exception ex) { this.Logger().DebugException(ex); LastException = ex; } pendingSets = null; return false; }
public ItemSet GetItems(string path, VersionSpec versionSpec, RecursionType recursionType) { ItemSpec itemSpec = new ItemSpec(path, recursionType); return GetItems(itemSpec, versionSpec, DeletedState.NonDeleted, ItemType.Any, false); }
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"); // Create Label Item Spec. ItemSpec itemSpec = new ItemSpec(this.ProjectPath, RecursionType.Full); LabelItemSpec[] labelItemSpec = new LabelItemSpec[] { new LabelItemSpec(itemSpec, this.WorkingVersion, false) }; this.SourceControl.CreateLabel(label, labelItemSpec, LabelChildOption.Replace); } }
public void Item_DownloadFile() { // need TFS_ envvars for this test // this test also assumes the $TFS_PROJECT contains at least one file in // the top level directory which is non-zero in length if (String.IsNullOrEmpty(tfsUrl)) return; TeamFoundationServer tfs = new TeamFoundationServer(tfsUrl, credentials); VersionControlServer vcs = (VersionControlServer) tfs.GetService(typeof(VersionControlServer)); string itemPath = String.Format("$/{0}/*", Environment.GetEnvironmentVariable("TFS_PROJECT")); ItemSpec itemSpec = new ItemSpec(itemPath, RecursionType.OneLevel); ItemSet itemSet = vcs.GetItems(itemSpec, VersionSpec.Latest, DeletedState.NonDeleted, ItemType.File, true); int i = 0; Item[] items = itemSet.Items; foreach (Item item in items) { if (item.ContentLength == 0) continue; i++; string fname = Path.GetTempFileName(); item.DownloadFile(fname); FileInfo fileInfo = new FileInfo(fname); Assert.IsTrue(fileInfo.Length > 0); File.Delete(fname); // limit how many files we pull here if (i == 3) break; } }
protected override void PopulateRowChildren(TreeIter iter) { string path = store.GetValue(iter, ColumnIndex.Path).ToString(); string url = String.Empty; Workspace workspace = null; TreeIter iterParent; TreeIter current = iter; while (store.IterParent(out iterParent, current)) current = iterParent; url = store.GetValue(current, ColumnIndex.Url).ToString(); workspace = store.GetValue(current, ColumnIndex.Workspace) as Workspace; ICredentials credentials = credentialsProvider.GetCredentials(new Uri(url), null); TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer(url, credentials); VersionControlServer versionControlServer = tfs.GetService(typeof(VersionControlServer)) as VersionControlServer; int indx = 0; ItemSpec itemSpec = new ItemSpec(path, RecursionType.OneLevel); ItemSet itemSet = versionControlServer.GetItems(itemSpec, VersionSpec.Latest, DeletedState.NonDeleted, ItemType.Folder, false); foreach (Microsoft.TeamFoundation.VersionControl.Client.Item item in itemSet.Items) { if (item.ServerItem == path) continue; string shortPath = item.ServerItem.Substring(item.ServerItem.LastIndexOf('/') + 1); bool mapped = workspace.IsServerPathMapped(item.ServerItem); Gtk.TreeIter child = SetRowValue(store, iter, indx, Images.Folder, shortPath, url, item.ServerItem, workspace, mapped); store.AppendValues(child, null, "", "", "", null, true); indx++; } // we didn't add anything! if (indx == 0) { TreeIter citer; store.IterChildren(out citer, iter); store.Remove(ref citer); } }
public BranchHistoryTreeItem[][] GetBranchHistory(ItemSpec[] itemSpecs, VersionSpec version) { if (itemSpecs.Length == 0) return null; string workspaceName = String.Empty; string workspaceOwner = String.Empty; string item = itemSpecs[0].Item; if (!VersionControlPath.IsServerItem(item)) { WorkspaceInfo info = Workstation.Current.GetLocalWorkspaceInfo(item); if (info != null) { workspaceName = info.Name; workspaceOwner = info.OwnerName; } } return repository.QueryBranches(workspaceName, workspaceOwner, itemSpecs, version); }
public ExtendedItem[][] GetExtendedItems(ItemSpec[] itemSpecs, DeletedState deletedState, ItemType itemType) { return Repository.QueryItemsExtended(Name, OwnerName, itemSpecs, deletedState, itemType); }
public ChangesetMerge[] QueryMerges(string workspaceName, string workspaceOwner, ItemSpec source, VersionSpec versionSource, ItemSpec target, VersionSpec versionTarget, VersionSpec versionFrom, VersionSpec versionTo, int maxChangesets) { Message msg = new Message(GetWebRequest(new Uri(Url)), "QueryMerges"); if (!String.IsNullOrEmpty(workspaceName)) { msg.Body.WriteElementString("workspaceName", workspaceName); } if (!String.IsNullOrEmpty(workspaceOwner)) { msg.Body.WriteElementString("workspaceOwner", workspaceOwner); } if (source != null) { source.ToXml(msg.Body, "source"); } if (versionSource != null) { versionSource.ToXml(msg.Body, "versionSource"); } target.ToXml(msg.Body, "target"); versionTarget.ToXml(msg.Body, "versionTarget"); if (versionFrom != null) { versionFrom.ToXml(msg.Body, "versionFrom"); } if (versionTo != null) { versionTo.ToXml(msg.Body, "versionTo"); } msg.Body.WriteElementString("maxChangesets", Convert.ToString(maxChangesets)); List <ChangesetMerge> merges = new List <ChangesetMerge>(); Dictionary <int, Changeset> changesets = new Dictionary <int, Changeset>(); using (HttpWebResponse response = Invoke(msg)) { XmlReader results = msg.ResponseReader(response); while (results.Read()) { if (results.NodeType != XmlNodeType.Element) { continue; } if (results.Name == "ChangesetMerge") { merges.Add(ChangesetMerge.FromXml(this, results)); } else if (results.Name == "Changeset") { Changeset changeset = Changeset.FromXml(this, results); changesets.Add(changeset.ChangesetId, changeset); } } } foreach (ChangesetMerge merge in merges) { Changeset changeset; if (changesets.TryGetValue(merge.TargetVersion, out changeset)) { merge.TargetChangeset = changeset; } } return(merges.ToArray()); }