我正在为IDEA开发塑料SCM插件,而且每次保存文件时,我都很难弄清楚如何刷新版本控制本地更改窗口(Alt+9)。我成功地实现了ChangeProvider接口,以使用该方法更新变更列表。
void getChanges(VcsDirtyScope, ChangelistBuilder, ProgressIndicator, ChangelistManagerGate)我检查了将IDEA窗口带到前台是否会触发此方法,以及单击版本控制窗口中的刷新按钮。这两种方案都成功地刷新了变更列表,而版本控制窗口则反映了当前的工作区状态。
但是,保存修改后的文档也会触发ChangeProvider.getChanges方法,但它不会更新窗口中的更改符。我检查了是否从塑料SCM中正确地检索了我的更改,并使用方法将其添加到变更列表中。
void ChangelistBuilder.processChange(Change, VcsKey)由于某些原因,这还不足以让IDEA承认新的更改,因此用户仍然需要手动刷新版本控制窗口。缺乏文件也于事无补:
我遗漏了什么?任何有关这个问题的建议都将不胜感激!
编辑的
Change对象是这样创建的:
private void addChangedFiles(ChangelistBuilder builder, ProjectStatus status) {
Set<String> modified = new HashSet<String>(status.CheckedOut);
modified.removeAll(status.Added);
modified.addAll(status.Changed);
modified.addAll(status.Moved);
modified.addAll(status.Copied);
for (String path : modified)
{
ContentRevision beforeRevision = PlasticContentRevision.createParentRevision(
mPlasticVcs.getProject(), path, false);
ContentRevision afterRevision = PlasticContentRevision.createRevision(
mPlasticVcs.getProject(), path, null, false);
Change ch = new Change(beforeRevision, afterRevision, FileStatus.MODIFIED);
builder.processChange(ch, mPlasticVcs.getKeyInstanceMethod());
}
}ProjectStatus类是一个存储cm status命令结果的PlasticSCM类。
这提醒我返回的beforeRevision对象可能存在问题,因为它是父版本,并且使用自定义VcsRevisionNumber:
class PlasticVcsParentRevisionNumber implements VcsRevisionNumber {
private PlasticFile mPlasticFile;
public PlasticVcsParentRevisionNumber(PlasticFile plasticFile) {
mPlasticFile = plasticFile;
}
public String asString() {
return "parent revision";
}
public int compareTo(VcsRevisionNumber other) {
if (other == this) {
return 0;
long parentRevId = mPlasticFile.getRevisionInfo().getParentRevId();
if (!(other instanceof PlasticVcsParentRevisionNumber))
return -1;
PlasticVcsParentRevisionNumber plasticRevNumber =
(PlasticVcsParentRevisionNumber)other;
long otherParentRevId =
plasticRevNumber.mPlasticFile.getRevisionInfo().getParentRevId();
if (parentRevId > otherParentRevId)
return 1;
if (parentRevId == otherParentRevId)
return 0;
return -1;
}
}发布于 2017-10-24 12:24:49
所以,我终于弄明白这个“神秘”是关于什么的.SCM提供程序(一个塑料的SCM CLI解析器)返回带有小写驱动器的Windows绝对路径。这与存储的IDEA数据不匹配,后者执行区分大小写的比较。结果是没有检测到任何更改,因为来自SCM的更改并不对应于磁盘上的任何实际文件。
是。以我为耻。
https://stackoverflow.com/questions/40306474
复制相似问题