4

我尝试在纯 java 中以编程方式比较来自一个流的两个快照......

第 1 步:获取我的流(工作)

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

第 2 步:获取基线(工作)

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

第3步:相互比较(不工作)

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

我的报告是空的……--烦人--

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

我还尝试获取 ChangeHistorySyncReport ......

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

报告也是空的...

那么如何创建正确的报告呢?或者我如何比较两个基线?(我究竟做错了什么?

report.getAffectedComponents()返回一个空数组,也一样report.getModifiedComponents()

更新 据我所知,我必须检查 ChangeHistorySyncReport ......当我打印我的报告时,它说:

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

这让我的问题更深了——如何设置更好的 CompareFlags?

4

1 回答 1

4

天哪,我花了好几年时间......

但首先要做的事情是:使用IChangeHistorySyncReport而不是 IUpdateReport...是完全正确的

那怎么了?

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

一个简单的代码更改解决了问题

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

顺便说一句,当我浏览报告时,还有另一个棘手的部分:

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 []

乍一看看起来很空洞 - 但深入挖掘我发现我只需要询问report.outgoingChangeSets()哪些会带来大量(预期的)变化......

但是当我交换基线workspaceManager.compareBaselineSets(bl1, bl0, null, monitor);

  • report.outgoingChangeSets()是空的并且
  • report.incomingChangeSets()带来正确的结果!!

更新:

在此处输入图像描述

使用比较基线方法,我现在可以提供几个组件的完整差异!!!

于 2014-09-25T11:16:53.377 回答