我希望获得最新的更改以及TFS的本地工作空间和服务器版本之间的区别,因为我使用了从
here获得的此代码
private static void GetLatest(string username,string password,string path_to_download,string tf_src_path) { Uri collectionUri = new Uri(PathConstants.uri); NetworkCredential credential = new NetworkCredential(username,password); TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(new Uri(PathConstants.uri),credential); tfs.EnsureAuthenticated(); VersionControlServer vc = tfs.GetService<VersionControlServer>(); foreach (var item in vc.GetItems(PathConstants.tfsRoot + tf_src_path,VersionSpec.Latest,RecursionType.Full).Items) { string relativePath = _buildrelativePath(path_to_download,item.ServerItem); switch (item.ItemType) { case ItemType.Any: throw new ArgumentOutOfRangeException("ItemType returned was Any; expected File or Folder."); case ItemType.File: item.DownloadFile(relativePath); break; case ItemType.Folder: Directory.CreateDirectory(relativePath); break; } } }
有没有办法只下载本地和服务器版本之间的差异?例如如果我删除本地的任何文件/文件夹,它们也应该与与更改集关联的新文件一起下载,而不替换其他文件
解决方法
这应该更新所有本地工作空间中的所有文件.
private static void GetLatest(string username,string tf_src_path) { Uri collectionUri = new Uri(PathConstants.uri); NetworkCredential credential = new NetworkCredential(username,credential); tfs.EnsureAuthenticated(); VersionControlServer vc = tfs.GetService<VersionControlServer>(); foreach (Workspace workspace in vc.QueryWorkspaces(null,null,System.Environment.MachineName)) { foreach (WorkingFolder folder in workspace.Folders) { ItemSpec itemSpec = new ItemSpec(folder.ServerItem,RecursionType.Full); ItemSpec[] specs = new ItemSpec[] { itemSpec }; ExtendedItem[][] extendedItems = workspace.GetExtendedItems(specs,DeletedState.NonDeleted,ItemType.File); ExtendedItem[] extendedItem = extendedItems[0]; foreach (var item in extendedItem) { if (item.VersionLocal != item.VersionLatest) { vc.DownloadFile(item.sourceServerItem,item.LocalItem); } } } } }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。