Reputation: 48
I'm developing the Plastic SCM plugin for IDEA and I'm having a hard time figuring out how to refresh the Version Control Local Changes window (Alt+9) each time a file gets saved. I successfully implemented the ChangeProvider
interface to update the changelists using the method
void getChanges(VcsDirtyScope, ChangelistBuilder, ProgressIndicator, ChangelistManagerGate)
I checked that bringing the IDEA window to foreground triggers this method, as well as clicking on the refresh button in the Version Control window. Both scenarios successfully refresh the changelists and the Version Control window reflects the current workspace status.
However, saving a modified document also triggers the ChangeProvider.getChanges
method but it doesn't update the changelists in the window. I checked that my changes are being properly retrieved from Plastic SCM and added to the changelists by using method
void ChangelistBuilder.processChange(Change, VcsKey)
This is not enough for IDEA to acknowledge the new changes for some reason, so users still need to manually refresh the Version Control window. The lack of documentation doesn't help either :-/
What am I missing? Any tips on this issue will be more than appreciated!
EDITED
This is how Change
objects are being created:
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());
}
}
The ProjectStatus
class is a PlasticSCM one which stores the results of the cm status
command.
It ocurred to me that there can be an issue in the returned beforeRevision
object, since it's the parent revision and it uses a custom 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;
}
}
Upvotes: 1
Views: 290
Reputation: 48
So, I finally figured out what this "mystery" was about... The SCM provider (a Plastic SCM CLI parser) was returning Windows absolute paths with a lower-case drive letter. That didn't match with the stored IDEA data, which performs a case-sensitive comparison. The result was that no changes were detected, as the changes coming from the SCM didn't correspond to any actual files on disk.
Yes. Shame on me.
Upvotes: 0