|
Lines 10-22
Link Here
|
| 10 |
*******************************************************************************/ |
10 |
*******************************************************************************/ |
| 11 |
package org.eclipse.team.internal.ccvs.ui.mappings; |
11 |
package org.eclipse.team.internal.ccvs.ui.mappings; |
| 12 |
|
12 |
|
| 13 |
import java.util.ArrayList; |
13 |
import java.util.*; |
| 14 |
import java.util.Arrays; |
|
|
| 15 |
import java.util.HashSet; |
| 16 |
import java.util.Iterator; |
| 17 |
import java.util.List; |
| 18 |
import java.util.Set; |
| 19 |
|
14 |
|
|
|
15 |
import org.eclipse.core.resources.IFile; |
| 20 |
import org.eclipse.core.resources.IResource; |
16 |
import org.eclipse.core.resources.IResource; |
| 21 |
import org.eclipse.core.runtime.*; |
17 |
import org.eclipse.core.runtime.*; |
| 22 |
import org.eclipse.core.runtime.jobs.Job; |
18 |
import org.eclipse.core.runtime.jobs.Job; |
|
Lines 29-37
Link Here
|
| 29 |
import org.eclipse.team.core.variants.IResourceVariant; |
25 |
import org.eclipse.team.core.variants.IResourceVariant; |
| 30 |
import org.eclipse.team.internal.ccvs.core.*; |
26 |
import org.eclipse.team.internal.ccvs.core.*; |
| 31 |
import org.eclipse.team.internal.ccvs.core.mapping.CVSCheckedInChangeSet; |
27 |
import org.eclipse.team.internal.ccvs.core.mapping.CVSCheckedInChangeSet; |
|
|
28 |
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; |
| 32 |
import org.eclipse.team.internal.ccvs.core.resources.RemoteResource; |
29 |
import org.eclipse.team.internal.ccvs.core.resources.RemoteResource; |
| 33 |
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; |
30 |
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; |
| 34 |
import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; |
31 |
import org.eclipse.team.internal.ccvs.ui.*; |
| 35 |
import org.eclipse.team.internal.ccvs.ui.Policy; |
32 |
import org.eclipse.team.internal.ccvs.ui.Policy; |
| 36 |
import org.eclipse.team.internal.ccvs.ui.operations.RemoteLogOperation.LogEntryCache; |
33 |
import org.eclipse.team.internal.ccvs.ui.operations.RemoteLogOperation.LogEntryCache; |
| 37 |
import org.eclipse.team.internal.ccvs.ui.subscriber.CVSChangeSetCollector; |
34 |
import org.eclipse.team.internal.ccvs.ui.subscriber.CVSChangeSetCollector; |
|
Lines 110-116
Link Here
|
| 110 |
private final Subscriber subscriber; |
107 |
private final Subscriber subscriber; |
| 111 |
|
108 |
|
| 112 |
private HashSet updatedSets; |
109 |
private HashSet updatedSets; |
| 113 |
|
110 |
private VersionCollator versionCollator = new VersionCollator(); |
|
|
111 |
|
| 114 |
public CheckedInChangeSetCollector(ISynchronizePageConfiguration configuration, Subscriber subscriber) { |
112 |
public CheckedInChangeSetCollector(ISynchronizePageConfiguration configuration, Subscriber subscriber) { |
| 115 |
this.configuration = configuration; |
113 |
this.configuration = configuration; |
| 116 |
this.subscriber = subscriber; |
114 |
this.subscriber = subscriber; |
|
Lines 354-366
Link Here
|
| 354 |
// remote. |
352 |
// remote. |
| 355 |
addRemoteChange(info, null, null); |
353 |
addRemoteChange(info, null, null); |
| 356 |
} else { |
354 |
} else { |
| 357 |
for (int i = 0; i < logEntries.length; i++) { |
355 |
// Sort the log entries by revision so we can determine which to prune, if any |
|
|
356 |
Arrays.sort(logEntries, new Comparator() { |
| 357 |
public int compare(Object o1, Object o2) { |
| 358 |
return versionCollator.compare(((ILogEntry)o1).getRevision(),((ILogEntry)o2).getRevision()); |
| 359 |
} |
| 360 |
}); |
| 361 |
int i = 0; |
| 362 |
if (shouldPruneFirst(info, logEntries)) { |
| 363 |
i = 1; |
| 364 |
} |
| 365 |
for (; i < logEntries.length; i++) { |
| 358 |
ILogEntry entry = logEntries[i]; |
366 |
ILogEntry entry = logEntries[i]; |
| 359 |
addRemoteChange(info, remoteResource, entry); |
367 |
addRemoteChange(info, remoteResource, entry); |
| 360 |
} |
368 |
} |
| 361 |
} |
369 |
} |
| 362 |
} |
370 |
} |
| 363 |
|
371 |
|
|
|
372 |
private boolean shouldPruneFirst(SyncInfo info, ILogEntry[] logEntries) { |
| 373 |
// We only prune when comparing |
| 374 |
if (subscriber instanceof CVSCompareSubscriber) { |
| 375 |
// If there is only, then show it |
| 376 |
if (logEntries.length == 1) |
| 377 |
return false; |
| 378 |
// Prune the first if the revisions are in sequence and the first is the local revision or has the tag |
| 379 |
if (ResourceSyncInfo.isLaterRevision(logEntries[1].getRevision(), logEntries[0].getRevision()) |
| 380 |
&& (isLocalRevision(info.getLocal(), logEntries[0].getRevision())) |
| 381 |
|| (hasQueryTag(logEntries[0]))) |
| 382 |
return true; |
| 383 |
} |
| 384 |
return false; |
| 385 |
} |
| 386 |
|
| 387 |
private boolean hasQueryTag(ILogEntry logEntry) { |
| 388 |
if (subscriber instanceof CVSCompareSubscriber) { |
| 389 |
CVSCompareSubscriber ccs = (CVSCompareSubscriber) subscriber; |
| 390 |
CVSTag tag = ccs.getTag(); |
| 391 |
if (tag.getType() == CVSTag.VERSION) { |
| 392 |
CVSTag[] tags = logEntry.getTags(); |
| 393 |
// TODO: Tags are not fetched!! so just prune it |
| 394 |
if (tags.length == 0) |
| 395 |
return true; |
| 396 |
for (int i = 0; i < tags.length; i++) { |
| 397 |
CVSTag entryTag = tags[i]; |
| 398 |
if (entryTag.equals(tag)) { |
| 399 |
return true; |
| 400 |
} |
| 401 |
} |
| 402 |
} |
| 403 |
} |
| 404 |
return false; |
| 405 |
} |
| 406 |
|
| 407 |
private boolean isLocalRevision(IResource local, String revision) { |
| 408 |
ICVSFile file = CVSWorkspaceRoot.getCVSFileFor((IFile)local); |
| 409 |
try { |
| 410 |
byte[] bytes = file.getSyncBytes(); |
| 411 |
if (bytes == null) |
| 412 |
return false; |
| 413 |
return ResourceSyncInfo.getRevision(bytes).equals(revision); |
| 414 |
} catch (CVSException e) { |
| 415 |
CVSUIPlugin.log(e); |
| 416 |
} |
| 417 |
return false; |
| 418 |
} |
| 419 |
|
| 364 |
private boolean isDeletedRemotely(SyncInfo info) { |
420 |
private boolean isDeletedRemotely(SyncInfo info) { |
| 365 |
int kind = info.getKind(); |
421 |
int kind = info.getKind(); |
| 366 |
if(kind == (SyncInfo.INCOMING | SyncInfo.DELETION)) return true; |
422 |
if(kind == (SyncInfo.INCOMING | SyncInfo.DELETION)) return true; |
|
Lines 404-410
Link Here
|
| 404 |
} |
460 |
} |
| 405 |
} |
461 |
} |
| 406 |
|
462 |
|
| 407 |
private SyncInfoToDiffConverter getConverter() { |
463 |
private SyncInfoToDiffConverter getConverter() { |
| 408 |
SyncInfoToDiffConverter converter = (SyncInfoToDiffConverter)Utils.getAdapter(subscriber, SyncInfoToDiffConverter.class); |
464 |
SyncInfoToDiffConverter converter = (SyncInfoToDiffConverter)Utils.getAdapter(subscriber, SyncInfoToDiffConverter.class); |
| 409 |
if (converter == null) |
465 |
if (converter == null) |
| 410 |
converter = SyncInfoToDiffConverter.getDefault(); |
466 |
converter = SyncInfoToDiffConverter.getDefault(); |