我想从 TFS 获取最新更改以及本地工作区和服务器版本之间的差异,因为我使用了从这里获得的代码
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;
}
}
}
但是此代码从源代码下载所有文件并替换本地工作区中的现有文件。
有没有办法只下载本地和服务器版本之间的差异?例如,如果我删除本地上的任何文件/文件夹,它们也应该与与变更集关联的新文件一起下载,而无需替换其他文件