4

I try to compare two snapshots from one stream programamtically in plain java...

Step 1: getting my stream (working)

IWorkspaceConnection stream = null;
List<IWorkspaceConnection> list = RtcAdapter.inst().getStreams(); //my library
for (IWorkspaceConnection connection: list){
    if (connection.getName().equalsIgnoreCase("myStreamName") ){
        stream = connection;
        break;
    }
}//now we have found our stream

Step 2: getting base lines (working)

List<IBaselineSet> snapShotList = 
    RtcAdapter.inst().getSnapShotsFromStream(stream);

IBaselineSet snapShot0 = null;
IBaselineSet snapShot1 = null;

for (IBaselineSet snapShot: snapShotList){
    if (snapShot.getName().equalsIgnoreCase("mySnapShotName0") ){
        snapShot0 = snapShot;
    }
    if (snapShot.getName().equalsIgnoreCase("mySnapShotName1") ){
        snapShot1 = snapShot;
    }
}//now we've got also my two snapShots

Step 3: comparing each other (not working)

IUpdateReport report = 
    workspaceManager.compareBaselineSetConfigurations(
        snapShot0, snapShot0, stream.getComponents(), monitor);

my report is empty... --annoying--

report=com.ibm.team.scm.common.internal.dto.impl.UpdateReportImpl@1de5a20 (stateBefore: <unset>, stateAfter: <unset>)

i also tried to get the ChangeHistorySyncReport...

IChangeHistorySyncReport report = 
    workspaceManager.compareBaselineSets(
        snapShot0, snapShot1, componentList(stream), monitor);

also the report is empty...

so how do I create a proper report? or how can I compare two baselines? (what am I doing wrong?

report.getAffectedComponents() returns an empty array, as well does report.getModifiedComponents()

UPDATE as far a s i know now i must inspect the ChangeHistorySyncReport... and when i print my report it says:

com.ibm.team.scm.common.internal.dto.impl.ChangeHistorySyncReportImpl@150f091 (localTime: <unset>, remoteTime: <unset>, compareFlags: <unset>)

this makes my question deeper - how can i set better CompareFlags?

Martin Frank
  • 3,445
  • 1
  • 27
  • 47
  • 1
    The only example of `IChangeHistorySyncReportImpl` (not `ChangeHistorySyncReportImpl`) I see is at https://jazz.net/forum/questions/91050/how-to-list-all-outgoing-changesets-using-plain-java-api – VonC Sep 25 '14 at 11:02
  • Hello @VonC i found out the solution, it was hidden in an chinese or hindu-like website (i lost the link, sorry)... but i found a solution now!! i'm so glad!!! – Martin Frank Sep 25 '14 at 11:20

1 Answers1

4

GOD it took me ages....

but first things first: it was totally right to use the IChangeHistorySyncReport instead of IUpdateReport...

so what was wrong?

IWorkspaceConnection stream; //is not null, already instantiated somewhere else
IBaselineSet bl0 = (IBaselineSet) 
    itemManager.fetchCompleteItem(baseLineHandle0, IItemManager.DEFAULT, monitor);
IBaselineSet bl1 = (IBaselineSet)
    itemManager.fetchCompleteItem(baseLineHandle1, IItemManager.DEFAULT, monitor);
IChangeHistorySyncReport report = 
    workspaceManager.compareBaselineSets(bl0, bl1, getComponentHandles(stream), monitor);

a simply code change solves the problem

//have a close look: 3.rd param is now null!!
IChangeHistorySyncReport report = 
    workspaceManager.compareBaselineSets(bl0, bl1, null, monitor); 

by the way, there was another tricky part, when i browsed up the report:

System.out.println("report: "+report );    
System.out.println("incoming: "+report.incomingChangeSets() );

output:
report = com.ibm.team.scm.common.internal.dto.impl.ChangeHistorySyncReportImpl@127c1ae (localTime: <unset>, remoteTime: <unset>, compareFlags: <unset>)
incoming []

looked empty ot first sight - but digging deeper i found out that i simply had to ask for report.outgoingChangeSets() which brings out a great sum of (expected) changes...

but when i exchange the baseline workspaceManager.compareBaselineSets(bl1, bl0, null, monitor); then

  • report.outgoingChangeSets() is empty and
  • report.incomingChangeSets() brings the correct results!!

update:

enter image description here

using the compare baseline method i can now provide a full diff on several components!!!

Martin Frank
  • 3,445
  • 1
  • 27
  • 47
  • i don't know why this works - especially when i'm using the proper List / List on the method but works **WITHOUT** ... i'm confused and happy! – Martin Frank Sep 25 '14 at 11:22
  • 1
    Fantastic! +1. Great find. – VonC Sep 25 '14 at 11:24
  • thanks for your support - even if you didn't provide some code today i was glad somebody listened to my problem!!! – Martin Frank Sep 25 '14 at 11:25
  • 1
    Impressive multi-component comparison. Is there any chance to have the java sources of that GUI opened-source somewhere? – VonC Oct 07 '14 at 13:35
  • oh - i compare several streams, each having several components.. all in all its a sum of our discussion on RTC... i'll see what i can offer, right now i'm already at home ^^ – Martin Frank Oct 07 '14 at 13:37
  • 1
    Ok (I didn't mean "a chance to see the java sources right this second" ;) ) – VonC Oct 07 '14 at 13:38