SCM versus API
using SCM I can use the compare subcommand to display the incoming changes between a snapshot and a stream;
but is it possible to do the same thing using the API, I suppose yes but how?
Eric
scm compare snapshot "GENERATED FOR RE7 on 20110919-14:15" stream CICSRE7 -r https://localhost:9443/ccm -r Administrator -I wfs -D "EEE, d MMM yyyy HH:mm:ss Z"
but is it possible to do the same thing using the API, I suppose yes but how?
Eric
4 answers
Yup, there is, but it's certainly more involved. You can use the following to query for a snapshot:
Then use this code to get the current baseline for a component in the workspace:
Then this to generate a comparison report:
The IChangeHistorySyncReport class has all the methods to pull diff changesets. Getting a full changeset is very easy, and the class is uncomplicated:
Hope this helps.
IBaselineSetSearchCriteria query = IBaselineSetSearchCriteria.FACTORY.newInstance();
query.setExactName(name);
IWorkspaceManager client = ...
List<IBaselineSetHandle> results = client.findBaselineSets(query, Integer.MAX_VALUE, null);
if (results.size() > 0) {
IBaselineSet snapshot = (IBaselineSet)itemManager.fetchCompleteItem(
results.get(0),
IItemManager.DEFAULT,
null);
return snapshot;
}
Then use this code to get the current baseline for a component in the workspace:
IWorkspaceConnection conn = ...
IHistoricBaselineIterator history = conn.getBaselinesInHistory(componentHandle, 1, null);
if (history == null || history.getBaselines().size() == 0)
return null;
IBaseline baseline = (IBaseline)itemManager.fetchCompleteItem(history.getBaselines().get(0), IItemManager.DEFAULT, null);
Then this to generate a comparison report:
IWorkspaceManager mgr = ...
IBaselineConnection baselineConn = mgr.getBaselineConnection(baseline, null);
IChangeHistorySyncReport report = baselineConn.compareTo(otherBaselineHandle, null);
The IChangeHistorySyncReport class has all the methods to pull diff changesets. Getting a full changeset is very easy, and the class is uncomplicated:
IChangeSet cs = (IChangeSet)itemManager.fetchCompleteItem(handle, IItemManager.DEFAULT, null);
Hope this helps.