Skip to content

Commit

Permalink
Fix a minor issue with the default changelist mapping.
Browse files Browse the repository at this point in the history
  • Loading branch information
groboclown committed Mar 9, 2015
1 parent 463f5e7 commit 8383340
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 24 deletions.
10 changes: 10 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# IDEA Community VCS Integration for Perforce


## ::v0.4.1::

### Overview

* Minor bug fix with changelist association with the default changelist.

### Details



## ::v0.4.0::

### Overview
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ project with a Perforce repository through IDEA's built-in VCS support.
GitHub on your local computer. You'll need a copy of
p4d (or p4s for Windows) to run the tests. The code comes with
copies of the correct dependent libraries.
*Note: the GitHub sources use a remote repository to host the
large IntelliJ dependent Jar files.*
1. Copy the `local.properties.template` to `local.properties`
in the source root directory, and edit the values to
match your configuration.
Expand Down
10 changes: 5 additions & 5 deletions plugin/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@
<category>VCS Integration</category>
<change-notes><![CDATA[
<ol>
<li><em>0.4.1</em>
<ol>
<li>Minor changelist handling bug fixes.</li>
</ol>
</li>
<li><em>0.4.0</em>
<ol>
<li>Major refactoring to the management of changelists.</li>
<li>Bug fixes with connection settings.</li>
<li>Bug fixes with threading.</li>
</ol>
</li>
<li><em>0.3.3</em>
<ol>
<li>Add support for all versions between 13.5 to 14.1</li>
</ol>
</li>
</ol>
]]></change-notes>
<description><![CDATA[
Expand Down
37 changes: 18 additions & 19 deletions plugin/src/net/groboclown/idea/p4ic/changes/P4ChangelistCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,11 @@ public void reloadCache(final Client client) throws VcsException {
final Set<P4FileInfo> files = new HashSet<P4FileInfo>(
client.getServer().loadOpenFiles(client.getRoots().toArray(new VirtualFile[client.getRoots().size()])));
final List<IChangelistSummary> summaries = client.getServer().getPendingClientChangelists();
P4ChangeList defaultChange = null;

// For each changelist, create the P4ChangeList object and remove the
// found files.
for (IChangelistSummary summary : summaries) {
if (summary.getId() < 0) {
LOG.error("`p4 changes` returned a negative changelist ID");
} else {
if (summary.getId() > 0) {
Set<P4FileInfo> changelistFiles = new HashSet<P4FileInfo>();
Iterator<P4FileInfo> iter = files.iterator();
while (iter.hasNext()) {
Expand All @@ -167,33 +164,35 @@ public void reloadCache(final Client client) throws VcsException {
}
P4ChangeList change = new P4ChangeList(new P4ChangeListIdImpl(client, summary), changelistFiles,
summary.getDescription(), summary.getUsername());
if (change.getId().isDefaultChangelist()) {
if (defaultChange != null) {
LOG.error("`p4 changes` returned multiple default changelists");
} else {
defaultChange = change;
}
} else {
serverCache.add(change);
}
serverCache.add(change);
}
}

// The remaining files are expected to be in default changelists.
P4ChangeList defaultChange;
Set<P4FileInfo> defaultChangeFiles = new HashSet<P4FileInfo>();
final Iterator<P4FileInfo> iter = files.iterator();
while (iter.hasNext()) {
final P4FileInfo next = iter.next();
if (next.getChangelist() <= P4_DEFAULT) {
iter.remove();
defaultChangeFiles.add(next);
}
}
defaultChange = new P4ChangeList(new P4ChangeListIdImpl(client, P4_DEFAULT),
defaultChangeFiles, null, null);

// If there are left over files, then that could be an error.
if (! files.isEmpty()) {
LOG.error("`p4 opeend` returned files that are not in opened changelists: " +
LOG.error("`p4 opened` returned files that are not in opened changelists: " +
files);
}


lock.writeLock().lock();
try {
numberedCache.put(client.getConfig().getServiceName(), serverCache);
if (defaultChange == null) {
defaultCache.remove(getClientServerId(client));
} else {
defaultCache.put(getClientServerId(client), defaultChange);
}
defaultCache.put(getClientServerId(client), defaultChange);
} finally {
lock.writeLock().unlock();
}
Expand Down

0 comments on commit 8383340

Please sign in to comment.