It's all about the answers!

Ask a question

compare component with baseline across stream for shared component.

vikrant kamble (1321592) | asked Apr 25 '16, 9:26 a.m.
 I have below scenario of stream in my project area

Demo Stream 6
Shared_Comp_1(5: Snap_1)

Demo Stream 7
Shared_Comp_1(4: Snap_3)

"Shared_Comp_1"  is shared in Demo Stream 6 and Demo Stream 7

There are no change sets in comparison when "Shared_Comp_1"  is compared with Snap_1 for Demo Stream 6.
However when I compare "Shared_Comp_1"  from Demo Stream 6 with Snap_3 baseline of "Shared_Comp_1"  from Demo Stream 7, there are change sets.
I am doing above comparison in eclipse client(client version is 5.0.2)

I want to compare "Shared_Comp_1" component from Demo Stream 6 with latest baseline Snap_3 of "Shared_Comp_1" from Demo Stream 7.

When I do it using java api it shows me no change sets, because instead of fetching Snap_3 as latest baseline from "Shared_Comp_1" of Demo Stream 7, it fetches Snap_1 as latest baseline form "Shared_Comp_1".

How can I fetch Snap_3 as latest baseline from "Shared_Comp_1" of Demo Stream 7 and compare it with "Shared_Comp_1" component of Demo Stream 6 using java client API

One answer

permanent link
David Lafreniere (4.8k7) | answered May 18 '16, 10:21 a.m.
Here is how you get the last baseline (known as the 'basis') of a component in a workspace or stream.

// Fetch a handle to the last baseline (basis)

ITeamRepository repo = <repo_of_the_stream>;

IWorkspaceManager manager = SCMPlatform.getWorkspaceManager(repo);

IWorkspaceHandle workspaceHandle = <this_is_the_handle_for_the_stream> ;

IWorkspaceConnection wc = manager.getWorkspaceConnection(workspaceHandle , monitor);

IComponentHandle component = <this_is_the_component_you_care_about> ;

IBaselineHandle basisHandle = wc.getComponentInfo(component).basis();

// Repeat the above for the other stream.
// Compare the two baselines (it sounds like you know how to do that already though)

//Fetch the full baseline (if you want the name of the baseline etc, etc.)

IFetchResult fetchResult =  repo.itemManager().fetchCompleteItemsPermissionAware(Collections.singletonList(basisHandle), ItemManager.DEFAULT, monitor);

IBaseline fetchedBaseline;

if (fetchResult.getRetrievedItems().size() == 1) {

   fetchedBaseline = fetchResult.getRetrievedItems().get(0);


vikrant kamble commented May 25 '16, 12:49 a.m. | edited May 25 '16, 12:59 a.m.

 Hi David,

Above solution worked to fetch latest baseline,
However I have a bit complex scenario for comparison of baseline, where I cannot get correct change sets.
I am comparing component of Demo Stream 6 i.e. Shared_Comp_1 with with latest baseline of Shared_Comp_1 of Demo Stream 7. 
I can not get correct results.
I can explain scenario in details if needed, please let me know.

Your answer

Register or to post your answer.