It's all about the answers!

Ask a question

Getting and accepting incoming change sets via Java API

Stefan Winkler (611) | asked Dec 01 '14, 10:10 a.m.
edited Aug 02 '16, 8:00 p.m. by David Lafreniere (4.0k7)
 Hi all,

I want to write an Eclipse Plugin with a command to check and accept incoming change sets one by one using the Java API in RTC 5.0.2.

This is what I have so far:

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());


while (changeSetPage.hasNextPage()) {

changeSetPage = conn.fetchFromAcceptQueue(changeSetPage.getPageDescriptor(),

new NullProgressMonitor());



} catch (TeamRepositoryException e) {

consoleOut.println("Error while getting change sets: " + e.getMessage());




But, somehow, fetchFromAcceptQueue() seems not to be what I am looking for. Because, the above code works without throwing an exception, but always returns zero change sets, even though my workspace shows incoming change sets in the "Pending Changes" view. Is there another method I should be using?

Accepted answer

permanent link
Evan Hughes (2.4k1018) | answered Dec 01 '14, 11:25 a.m.
fetchFromAcceptQueue() is specific to the new merge-gaps workflow: a component in a workspace can be in a conflicted state where it has a gap, and a number of items to merge into it. The fetch looks like it pulls the next change set that is to be merged. Using our API is a bit more complex: you need to compare the the workspace and its flow target, then run an accept on it.

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 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.
David Lafreniere selected this answer as the correct answer

Your answer

Register or to post your answer.