Comparing two baselines in RTC / Jazz with plain java

I am trying to compare two snapshots from the same stream programmatically in simple java ...

Step 1: getting my thread (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: get baselines (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 (doesn't work)

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 ChangeHistorySyncReport ...

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

      

also the report is empty ...

so how do i generate the correct report? or how can I compare the two original lines? (what am I doing wrong?

report.getAffectedComponents()

returns an empty array as well report.getModifiedComponents()

UPDATE as far as I know, now I have to check 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 a better CompareFlags?

+3


source to share


1 answer


GOD it took me ages ...

but first first: it was perfectly correct to use IChangeHistorySyncReport

instead IUpdateReport

...

so what happened?

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);

      

simple 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 looked at 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 at first glance - but digging deeper I found out that I was just asking report.outgoingChangeSets()

, which gives out a large amount of (expected) changes ...

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

then

  • report.outgoingChangeSets()

    empty and
  • report.incomingChangeSets()

    brings the right results!

update:

enter image description here

using the compare-compare method, I can now ensure full scatter across multiple components.

+3


source







All Articles