Skip to content

Commit

Permalink
Further fixing for #213. This also has an impact on the changelist ma…
Browse files Browse the repository at this point in the history
…pping in the IDE.
  • Loading branch information
groboclown committed Jun 8, 2020
1 parent 9c2b4e8 commit a6834aa
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
### Details

* Bug fixes
* Fix for Local Changed Diff View for Edited File Generates "null file spec in arguments" (#213).
* Fix for Local Changed Diff View for Edited File Generates "null file spec in arguments" (#213). This same bug seems to be also the source of many issues around


## ::v0.10.16::
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ public GetFileContentsQuery(@NotNull FilePath localPath, int rev) {
this.rev = rev;
}

@Override
public String toString() {
if (depotPath != null) {
return "GetFileContents(" + depotPath + ")";
} else {
return "GetFileContents(" + localPath + "#" + rev + ")";
}
}

@NotNull
@Override
public Class<? extends GetFileContentsResult> getResultType() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,8 @@ public P4CommandRunner.QueryAnswer<GetFileContentsResult> getFileContents(
locations = FileSpecBuildUtil.escapedForFilePathRev(localFile, rev);
} else {
// #213 - replaceDepotRevisions can discover a null if the depot path is null.
// So this is switched to replaceBestPathRevisions to avoid that null.
// This ends up to be because there's a request for a file for the wrong client.
MessageStatusUtil.throwIfError(locations);
locations = FileSpecBuildUtil.replaceBestPathRevisions(locations, "#" + rev);
}
if (LOG.isDebugEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.perforce.p4java.core.file.IFileSpec;
import com.perforce.p4java.exception.P4JavaException;
import com.perforce.p4java.exception.RequestException;
import com.perforce.p4java.server.IServer;
import com.perforce.p4java.server.IServerMessage;

import java.util.ArrayList;
Expand Down Expand Up @@ -66,6 +67,39 @@ public static void throwIfMessageOrEmpty(String operation, List<? extends IFileS
}
}

public static List<IServerMessage> getAllMessages(Collection<IFileSpec> specs) {
return getMessages(specs, true, true, true);
}

public static List<IServerMessage> getMessages(Collection<IFileSpec> specs,
boolean errors, boolean warnings, boolean infos) {
List<IServerMessage> messages = new ArrayList<>(specs.size());
for (IFileSpec spec : specs) {
IServerMessage msg = spec.getStatusMessage();
if (
msg != null && (
(errors && msg.isError()) ||
(infos && msg.isInfo()) ||
(warnings && msg.isWarning())
)
) {
messages.add(msg);
}
}
return messages;
}

public static List<IFileSpec> filterOutMessages(Collection<IFileSpec> specs) {
List<IFileSpec> ret = new ArrayList<>(specs.size());
for (IFileSpec spec : specs) {
IServerMessage msg = spec.getStatusMessage();
if (msg == null) {
ret.add(spec);
}
}
return ret;
}

public static StringBuilder getMessages(StringBuilder sb, Collection<IFileSpec> specs, String separator) {
if (sb == null) {
sb = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public static List<IFileSpec> replaceBestPathRevisions(@NotNull List<IFileSpec>
if (path == null) {
path = file.getOriginalPathString();
if (path == null) {
throw new IllegalArgumentException("null file spec in arguments");
throw new IllegalArgumentException("null file spec (" + file + ") in arguments: " + files);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -457,8 +458,27 @@ private void updateFileCache(ClientConfig config, Set<FilePath> dirty,
}


// #213: the files passed in can be in multiple clients; however, this needs to filter out the files
// to instead be only in the requested client. Without this, all kinds of weird things happen with the
// changelist mapping.
private void updateLocalFileCache(ClientConfig config, List<P4LocalFile> files,
IdeChangelistMap changes, ChangelistBuilder builder) {
// Collect only the files that are in the client.
updateLocalFileCacheForClient(
config,
changes,
builder,
files.stream().filter((f) ->
f != null &&
f.getChangelistId() != null &&
Objects.equals(config.getClientname(), f.getChangelistId().getClientname())
).collect(Collectors.toList())
);
}

private void updateLocalFileCacheForClient(ClientConfig config,
IdeChangelistMap changes, ChangelistBuilder builder,
List<P4LocalFile> files) {
final Map<P4LocalFile, P4LocalFile> moved = findMovedFiles(files);
final Set<P4LocalFile> unprocessedDeletedMovedFiles = new HashSet<>(moved.values());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

package net.groboclown.p4plugin.revision;

import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.vcs.VcsException;
import net.groboclown.p4.server.api.commands.HistoryContentLoader;
import net.groboclown.p4.server.api.config.ClientConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

package net.groboclown.p4plugin.util;

import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.VcsException;
Expand Down
2 changes: 1 addition & 1 deletion plugin-v3/src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<change-notes><![CDATA[
<ul>
<li><em>0.10.17</em><ul>
<li>Fix "null file spec in arguments" from diff view</li>
<li>Fix "null file spec in arguments" from diff view, which may also fix issues around the changelist mapping</li>
</ul></li>
<li><em>0.10.16</em><ul
<li>Removed a duplicate event registration, which on Android Studio causes the plugin not to load.</li>
Expand Down

0 comments on commit a6834aa

Please sign in to comment.