我尝试使用下面的代码
TFSTeamProjectCollection tpc =
new TFSTeamProjectCollection(URIUtils.newURI(COLLECTION_URL), credentials );
VersionControlClient srcctrl = tpc.getVersionControlClient();
Changeset[] chngset;
try {
chngset = srcctrl.queryHistory("http://******/tfs/SpectaTestCollection/", LatestVersionSpec.INSTANCE, 0, RecursionType.FULL, null, new DateVersionSpec("6/10/2014"), LatestVersionSpec.INSTANCE, Integer.MAX_VALUE, false, true, false, true);
for(Changeset ch : chngset)
{
System.out.println("Change Set ID : "+ ch.getChangesetID());
System.out.println("Owner : "+ ch.getOwner());
}
} catch (ServerPathFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}但是每次都会得到这样的错误:没有D:\WorkSpace\test-workspace\tfsplay.game\http:********\tfs\SpectaTestCollection.的工作文件夹映射
其中"D:\ workspace \test -workspace\tfsplay.game“是我的本地工作区。
有没有人能帮我找到正确的方法?
发布于 2014-11-06 22:52:43
不要将URL传递给queryHistory方法,而是传递服务器路径或本地路径。
之所以会出现此错误,是因为您传递的路径不是服务器路径(不是以$/开头),因此系统正在尝试了解您映射到http://...etc的服务器路径。由于该URL也不是本地路径,因此您会得到该错误。
如果您想查看所有历史记录,请传递服务器路径$/。
发布于 2015-07-22 00:21:14
public class TestTfsExample {
public static void main(String[] args)
{
Credentials cred=new UsernamePasswordCredentials("username","password") ;
TFSTeamProjectCollection tpc =new TFSTeamProjectCollection(URIUtils.newURI("Application_Collection_url")
, cred);
WorkItemClient workItemClient = tpc.getWorkItemClient();
Changeset[] chngset=null;
LabelSpec lable=new LabelSpec("tfs_start_Label", null);
LabelSpec lable1=new LabelSpec("tfs_end_label", null);
try {
chngset = tpc.getVersionControlClient().queryHistory("$project_directory", LatestVersionSpec.INSTANCE, 0,
RecursionType.FULL, null,new LabelVersionSpec(lable1), new LabelVersionSpec(lable), Integer.MAX_VALUE, true, true, false, true);
} catch (ServerPathFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
for(Changeset ch : chngset)
{
System.out.println("Change Set ID : "+ ch.getChangesetID());
System.out.println("Owner : "+ ch.getOwner());
Change changes[]=ch.getChanges();
System.out.println("Date : "+ new Date(ch.getDate().getTimeInMillis()));
for(Change chang:changes)
{
System.out.println(chang.getItem().getServerItem());;
//System.out.println("Owner : "+ chang.getItem().getItemType().toString());
}
}
}
}https://stackoverflow.com/questions/26779508
复制相似问题