create a stream from the snap shot of another stream
4 answers
![](http://jazz.net/_images/myphoto/b6d4ddaf0b7ffcd61e76f5106e997cd7.jpg)
I suggest having a look at the source for:
com.ibm.team.filesystem.ui.changes.actions.ReplaceWithSnapshotAction
It does the following (showing only the relevant bits, and slightly refactored):
com.ibm.team.filesystem.ui.changes.actions.ReplaceWithSnapshotAction
It does the following (showing only the relevant bits, and slightly refactored):
IBaselineSet snapshot = ... // snapshot you're starting with
// fetch the baselines in the snapshot
List<IBaselineHandle> baselineHandles = snapshot.getBaselines();
List<IBaseline> baselines = snapshot.getRepository().itemManager().fetchCompleteItems(baselineHandles, IItemManager.DEFAULT, progress.newChild(5));
// create replace operations for each baseline
List<IComponentOp> ops = new ArrayList<IComponentOp>(missingComponentsInSource.size());
for (IBaseline baseline : baselines) {
IBaselineConnection baselineConnection = workspaceManager.getBaselineConnection(baseline, loopProgress.newChild(1));
IComponentHandle component = baseline.getComponent();
ops.add(workspaceConnection.componentOpFactory().addComponent(component, baselineConnection, true));
}
// apply the operations atomically
IUpdateReport report = workspaceConnection.applyComponentOperations(ops, progress.newChild(5));