It's all about the answers!

Ask a question

How to get IChangeHandle


Tifa Tan (1835) | asked Nov 24 '14, 6:52 a.m.
retagged Nov 24 '14, 10:21 a.m. by Evan Hughes (2.4k1318)

I'm trying to get the IChangeHandle object in follow two ways:

1. IChangeSetHandle csHandle = workspaceConnection.getCurrentChangeSet(comp);
 ==>But this way only get a null object.

2. IChangeSetHandle csHandle1 = workspaceConnection.createChangeSet(comp, null);

==>But this way thow follow Excpection:

com.ibm.team.scm.common.InvalidStreamOperationException: Change sets cannot be created on a stream
 at com.ibm.team.scm.client.internal.WorkspaceConnection.createChangeSet(WorkspaceConnection.java:399)
 at com.ibm.team.scm.client.internal.WorkspaceConnection.createChangeSet(WorkspaceConnection.java:368)
 at main.MainTest2.deliverChangeSets(MainTest2.java:328)

Is there any one can help ? I want to use it to deliver a local change onto stream.

lcm.refreshChanges(new ISandbox[]{sbox}, RefreshType.TRAVERSE_ALL_WITH_RECOMPUTE_OF_KNOWN, null);
ILocalChange[] localChanges = lcm.getPendingChanges(new IShareable[]{shareable}, null);

//get the IChangeHandle(csHandle) object here

checkInOp.requestCheckin(localChanges, csHandle, "testing comment", null);

IChangeHistorySyncReport sync = workspaceConnection.compareTo(workspaceConnection, WorkspaceComparisonFlags.CHANGE_SET_COMPARISON_ONLY, Collections.EMPTY_LIST, null);
   workspaceConnection.deliver(workspaceConnection, sync, workspaceConnection.getBaselineSets(null), Arrays.asList(localChanges), null);

Accepted answer


permanent link
Evan Hughes (2.4k1318) | answered Nov 24 '14, 10:20 a.m.
JAZZ DEVELOPER
1. IChangeSetHandle csHandle = workspaceConnection.getCurrentChangeSet(comp);
 ==>But this way only get a null object.
getCurrentChangeSet() returns null if there is not an active change set for the given workspace/component pair. From your later questions, it sounds like your IWorkspaceConnection may have been created on a stream. Streams can't have active change sets, so this is expected behaviour.

2. IChangeSetHandle csHandle1 = workspaceConnection.createChangeSet(comp, null);
==>But this way thow follow Excpection: com.ibm.team.scm.common.InvalidStreamOperationException: Change sets cannot be created on a stream
This exception is thrown when createChangeSet() is called on an IWorkspaceHandle that corresponds to a stream. Make sure that you're calling this on a workspace connection that has been created from a workspace. Be aware that the IWorkspace object can be used to refer to a workspace or a stream. The difference is revealed by calling isStream() . For most read methods you can use workspaces and streams interchangeably, but only workspaces can be committed to.
Tifa Tan selected this answer as the correct answer

Comments
1
Tifa Tan commented Nov 25 '14, 6:41 a.m.

Hi Evan Hughes, Many thanks your help on this issue.

Your answer


Register or to post your answer.