Accepting baseline update using java api
5 answers
How do you accept a baseline update using the java api?
I have a stream which flows to a workspace....
IWorkspaceConnection.accept() accepts a list of baselines as an argument. Choose the 1 baseline per component that you want to accept, put it in a list, and pass it in.
From my experiments, you can have multiple incoming baselines for the same component, but you can only accept them one at a time.
See also: http://jazz.net/forums/viewtopic.php?t=12242
IChangeHistorySyncReport sync = workspace.compareTo
(stream,WorkspaceComparisonFlags.INCLUDE_BASELINE_INFO |
WorkspaceComparisonFlags.INCLUDE_EMPTY_BASELINES,
Collections.EMPTY_LIST, MONITOR);
List a = sync.incomingBaselines();
for (Iterator b = a.iterator(); b.hasNext();) {
IBaselineHandle base = (IBaselineHandle) b.next();
workspace.accept(AcceptFlags.DEFAULT,null, sync,
Collections.singletonList(base), sync.incomingChangeSets(),MONITOR);
}
(stream,WorkspaceComparisonFlags.INCLUDE_BASELINE_INFO |
WorkspaceComparisonFlags.INCLUDE_EMPTY_BASELINES,
Collections.EMPTY_LIST, MONITOR);
List a = sync.incomingBaselines();
for (Iterator b = a.iterator(); b.hasNext();) {
IBaselineHandle base = (IBaselineHandle) b.next();
workspace.accept(AcceptFlags.DEFAULT,null, sync,
Collections.singletonList(base), sync.incomingChangeSets(),MONITOR);
}
IChangeHistorySyncReport sync = workspace.compareTo
(stream,WorkspaceComparisonFlags.INCLUDE_BASELINE_INFO |
WorkspaceComparisonFlags.INCLUDE_EMPTY_BASELINES,
Collections.EMPTY_LIST, MONITOR);
List a = sync.incomingBaselines();
for (Iterator b = a.iterator(); b.hasNext();) {
IBaselineHandle base = (IBaselineHandle) b.next();
workspace.accept(AcceptFlags.DEFAULT,stream , sync,
Collections.singletonList(base), sync.incomingChangeSets(),MONITOR);
(stream,WorkspaceComparisonFlags.INCLUDE_BASELINE_INFO |
WorkspaceComparisonFlags.INCLUDE_EMPTY_BASELINES,
Collections.EMPTY_LIST, MONITOR);
List a = sync.incomingBaselines();
for (Iterator b = a.iterator(); b.hasNext();) {
IBaselineHandle base = (IBaselineHandle) b.next();
workspace.accept(AcceptFlags.DEFAULT,
Collections.singletonList(base), sync.incomingChangeSets(),MONITOR);
I had something similar but there are some problems:
1) incomingChangeSets() gives ALL the Change Sets even those pointed by baselines so you get a strange situation with accepted change set coming from accepted baselines appearing again as outgoing. You must use changeHistorySyncReport.incomingChangeSetsAfterBasis()
2) Iterating on all baselines solve the issue of accepting 1 baseline per component but in this way you keep on accepting all the change set at every iteration. So I've a cycle in which I accept 1 baseline at a time (in reverse order because I want to accept first oldest baselines) and finally I accept all change sets on top of the baselines