How to get changeset information from tfs using Java tfs-sdk
I tried with the below code
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();
}
But eveytime is getting this error: no work folder mapping for D: \ WorkSpace \ test-workspace \ tfsplay.game \ http: ******** \ tfs \ SpectaTestCollection.
where "D: \ WorkSpace \ test -workspace \ tfsplay.game" is my local workspace.
can anyone help me in the right direction for this?
source to share
Do not pass url to method queryHistory
, pass server path or local path.
You are getting this error because you passed in a path that is not a server path (does not start with $/
), so the system is trying to figure out which server path you mapped to http://...etc
. Since this url is also not a local path, you got this error.
If you want to view the entire history, go to the server path $/
.
source to share
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());
}
}
}
}
source to share