How to compare snapshot with stream using client java API
Accepted answer
![](http://jazz.net/_images/myphoto/c6a90d99c0eec12c2b693d9a080c0bd2.jpg)
Hi Vikrant,
There is no plain java client API to compare a snapshot with a stream. As you mentioned there is only an API to compare two snapshots.
One option is to create a snapshot (aka baseline set) and compare the two snapshots. This could create alot of unnecessary snapshots and baselines if this code is invoked frequently.
Another option is to use the SCM CLI to compare the snapshot with the stream (lscm help diff). Note that it will give file content diffs and not the list of change sets. I'm not sure if that is sufficient for your case.
Finally, the compare can be done (carefully, to avoid performance problems with the server) yourself. You can fetch the change history of each baseline in a snapshot (IBaselineSet.getBaselines(), IWorkspaceManager.fetchCompleteItem(), IWorkspaceManager.getBaselineConnection()) using IBaselineConnection.changeHistory() and then use that change history to compare with the matching component change history using IWorkspaceConnection.changeHistory(). It will be good to put limits in place to avoid walking back into very large histories.
I hope that this helps,
Chris
There is no plain java client API to compare a snapshot with a stream. As you mentioned there is only an API to compare two snapshots.
One option is to create a snapshot (aka baseline set) and compare the two snapshots. This could create alot of unnecessary snapshots and baselines if this code is invoked frequently.
Another option is to use the SCM CLI to compare the snapshot with the stream (lscm help diff). Note that it will give file content diffs and not the list of change sets. I'm not sure if that is sufficient for your case.
Finally, the compare can be done (carefully, to avoid performance problems with the server) yourself. You can fetch the change history of each baseline in a snapshot (IBaselineSet.getBaselines(), IWorkspaceManager.fetchCompleteItem(), IWorkspaceManager.getBaselineConnection()) using IBaselineConnection.changeHistory() and then use that change history to compare with the matching component change history using IWorkspaceConnection.changeHistory(). It will be good to put limits in place to avoid walking back into very large histories.
I hope that this helps,
Chris
One other answer
![](http://jazz.net/_images/myphoto/c6a90d99c0eec12c2b693d9a080c0bd2.jpg)
Try this: http://lmgtfy.com/?q=compare+snaphot+java+api+site%3Ajazz.net
First answer from the top.
First answer from the top.
Comments
![](http://jazz.net/_images/myphoto/c6a90d99c0eec12c2b693d9a080c0bd2.jpg)
Hi Ralph,
I already visited that link. I used IWorkspaceManager.compareBaselineSets(parameters) this method to compare two snapshot. It worked when I passed two IBaselineSetHandle objects.
But I want to compare a snapshot with stream. This method does not work when I cast IWorkspaceHandle into IBaselineSetHandle and pass it as parameter into this method
![](http://jazz.net/_images/myphoto/c6a90d99c0eec12c2b693d9a080c0bd2.jpg)
In fact I cannot cast object of IWorkspaceHandle into IBaselineSetHandle
Comments
vikrant kamble
Oct 13 '15, 2:10 a.m.I know how to fetch IWorkspaceHandle and IBaselineSetHandle and complete item out of handle, I want to know about method to compare snapshot with stream. If there is not any direct method then how do we do it.
vikrant kamble
Oct 14 '15, 3:04 a.m.could anyone please tell me?