gpt4 book ai didi

java - 将 RTC/Jazz 中的两个基线与纯 Java 进行比较

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:46:48 24 4
gpt4 key购买 nike

我尝试在纯 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

第三步:相互比较(无效)

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?

最佳答案

上帝我花了很长时间....

但首先要做的是:使用 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() 带来正确的结果!!

更新:

enter image description here

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

关于java - 将 RTC/Jazz 中的两个基线与纯 Java 进行比较,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26016569/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com