Getting and accepting incoming change sets via Java API
for (IComponentHandle componentHandle : components) {
try {
IComponent component = (IComponent) itemManager.fetchCompleteItem(componentHandle, IItemManager.DEFAULT, new NullProgressMonitor());
consoleOut.println("Processing component " + component.getName());
IChangeSetSourcesPage changeSetPage = conn.fetchFromAcceptQueue(component, 0, 500,
new NullProgressMonitor());
processChangeSets(changeSetPage.getChangeSetSources());
while (changeSetPage.hasNextPage()) {
changeSetPage = conn.fetchFromAcceptQueue(changeSetPage.getPageDescriptor(),
new NullProgressMonitor());
processChangeSets(changeSetPage.getChangeSetSources());
}
} catch (TeamRepositoryException e) {
consoleOut.println("Error while getting change sets: " + e.getMessage());
e.printStackTrace();
}
}
Accepted answer
In general, I suggest using the CLI: either run 'scm accept' to grab all of the change sets that are incoming, or use 'scm show status' to get a listing of the incoming changes so you can cherry pick the ones you want.
If you have your heart set on using the Java API, I suggest you explore IFlowNodeConnection.compareTo() which will provide you with the differences between the workspace/stream then use com.ibm.team.filesystem.client.IOperationFactory.getWorkspaceUpdateOperation() to get an operation that will do the accept for you. So long as the sandbox(es) of the loaded workspace have been registered, they will be updated during the accept.