How to get IChangeHandle
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
1. IChangeSetHandle csHandle = workspaceConnection.getCurrentChangeSet(comp);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.
==>But this way only get a null object.
2. IChangeSetHandle csHandle1 = workspaceConnection.createChangeSet(comp, null);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.
==>But this way thow follow Excpection: com.ibm.team.scm.common.InvalidStreamOperationException: Change sets cannot be created on a stream