use of com.intellij.cvsSupport2.changeBrowser.CvsChangeList in project intellij-community by JetBrains.
the class CvsCommittedChangesProvider method getOneList.
@Nullable
@Override
public Pair<CvsChangeList, FilePath> getOneList(VirtualFile file, final VcsRevisionNumber number) throws VcsException {
final File ioFile = new File(file.getPath());
final FilePath filePath = VcsContextFactory.SERVICE.getInstance().createFilePathOn(ioFile);
final VirtualFile vcsRoot = ProjectLevelVcsManager.getInstance(myProject).getVcsRootFor(filePath);
final CvsRepositoryLocation cvsLocation = getLocationFor(filePath);
if (cvsLocation == null)
return null;
final String module = CvsUtil.getModuleName(vcsRoot);
final CvsEnvironment connectionSettings = cvsLocation.getEnvironment();
if (connectionSettings.isOffline()) {
return null;
}
final CvsChangeListsBuilder builder = new CvsChangeListsBuilder(module, connectionSettings, myProject, vcsRoot);
final Ref<CvsChangeList> result = new Ref<>();
final LoadHistoryOperation operation = new LoadHistoryOperation(connectionSettings, wrapper -> {
final List<Revision> revisions = wrapper.getRevisions();
if (revisions.isEmpty())
return;
final RevisionWrapper revision = new RevisionWrapper(wrapper.getFile(), revisions.get(0), null);
result.set(builder.addRevision(revision));
}, cvsLocation.getModuleName(), number.asString());
final CvsResult executionResult = operation.run(myProject);
if (executionResult.isCanceled()) {
throw new ProcessCanceledException();
} else if (executionResult.hasErrors()) {
throw executionResult.composeError();
}
if (result.isNull()) {
return null;
}
final Date commitDate = result.get().getCommitDate();
final CvsEnvironment rootConnectionSettings = CvsEntriesManager.getInstance().getCvsConnectionSettingsFor(vcsRoot);
final long t = commitDate.getTime();
final Date dateFrom = new Date(t - CvsChangeList.SUITABLE_DIFF);
final Date dateTo = new Date(t + CvsChangeList.SUITABLE_DIFF);
final LoadHistoryOperation operation2 = new LoadHistoryOperation(rootConnectionSettings, module, dateFrom, dateTo, wrapper -> {
final List<RevisionWrapper> wrappers = builder.revisionWrappersFromLog(wrapper);
if (wrappers != null) {
for (RevisionWrapper revisionWrapper : wrappers) {
if (result.get().containsFileRevision(revisionWrapper)) {
continue;
}
builder.addRevision(revisionWrapper);
}
}
});
final CvsResult cvsResult = operation2.run(myProject);
if (cvsResult.hasErrors()) {
throw cvsResult.composeError();
}
return Pair.create(result.get(), filePath);
}
use of com.intellij.cvsSupport2.changeBrowser.CvsChangeList in project intellij-community by JetBrains.
the class CvsCommittedChangesProvider method isDifferentBranch.
private static boolean isDifferentBranch(final FilePath filePath, final CvsChangeList changeList) {
final String localTag;
final CvsEntriesManager cvsEntriesManager = CvsEntriesManager.getInstance();
final VirtualFile parent = filePath.getVirtualFileParent();
if (parent != null) {
final Entry entry = cvsEntriesManager.getEntryFor(parent, filePath.getName());
if (entry != null) {
localTag = entry.getStickyTag();
} else {
localTag = getDirectoryTag(parent);
}
} else {
final VirtualFile validParent = ChangesUtil.findValidParentAccurately(filePath);
if (validParent == null)
return false;
localTag = getDirectoryTag(validParent);
}
final String remoteTag = changeList.getBranch();
if (!Comparing.equal(localTag, remoteTag)) {
if (LOG.isDebugEnabled())
LOG.info(filePath + ": local tag " + localTag + ", remote tag " + remoteTag);
return true;
}
return false;
}
use of com.intellij.cvsSupport2.changeBrowser.CvsChangeList in project intellij-community by JetBrains.
the class CvsCommittedChangesProvider method isChangeLocallyAvailable.
public boolean isChangeLocallyAvailable(final FilePath filePath, @Nullable VcsRevisionNumber localRevision, VcsRevisionNumber changeRevision, final CvsChangeList changeList) {
if (localRevision instanceof CvsRevisionNumber && changeRevision instanceof CvsRevisionNumber) {
final CvsRevisionNumber cvsLocalRevision = (CvsRevisionNumber) localRevision;
final CvsRevisionNumber cvsChangeRevision = (CvsRevisionNumber) changeRevision;
final int[] localSubRevisions = cvsLocalRevision.getSubRevisions();
final int[] changeSubRevisions = cvsChangeRevision.getSubRevisions();
if (localSubRevisions != null && changeSubRevisions != null) {
if (localSubRevisions.length != changeSubRevisions.length) {
// local is trunk, change is branch / vice versa
return true;
}
for (int i = 2; i < localSubRevisions.length; i += 2) {
if (localSubRevisions[i] != changeSubRevisions[i]) {
// local is one branch, change is a different branch
return true;
}
}
}
}
return isDifferentBranch(filePath, changeList) || (localRevision != null && localRevision.compareTo(changeRevision) >= 0);
}
use of com.intellij.cvsSupport2.changeBrowser.CvsChangeList in project intellij-community by JetBrains.
the class CvsCommittedChangesProvider method loadCommittedChanges.
public void loadCommittedChanges(ChangeBrowserSettings settings, RepositoryLocation location, int maxCount, final AsynchConsumer<CommittedChangeList> consumer) throws VcsException {
try {
final CvsRepositoryLocation cvsLocation = (CvsRepositoryLocation) location;
final String module = cvsLocation.getModuleName();
final CvsEnvironment connectionSettings = cvsLocation.getEnvironment();
if (connectionSettings.isOffline()) {
return;
}
final CvsChangeListsBuilder builder = new CvsChangeListsBuilder(module, connectionSettings, myProject, cvsLocation.getRootFile());
final Date dateTo = settings.getDateBeforeFilter();
Date dateFrom = settings.getDateAfterFilter();
if (dateFrom == null) {
final Calendar calendar = Calendar.getInstance();
calendar.set(1970, Calendar.MARCH, 2);
dateFrom = calendar.getTime();
}
final ChangeBrowserSettings.Filter filter = settings.createFilter();
final Set<CvsChangeList> controlSet = new HashSet<>();
final LoadHistoryOperation operation = new LoadHistoryOperation(connectionSettings, module, dateFrom, dateTo, wrapper -> {
final List<RevisionWrapper> wrappers = builder.revisionWrappersFromLog(wrapper);
if (wrappers != null) {
for (RevisionWrapper revisionWrapper : wrappers) {
final CvsChangeList changeList = builder.addRevision(revisionWrapper);
if (controlSet.contains(changeList))
continue;
controlSet.add(changeList);
if (filter.accepts(changeList)) {
consumer.consume(changeList);
}
}
}
});
final CvsResult executionResult = operation.run(myProject);
if (executionResult.isCanceled()) {
throw new ProcessCanceledException();
} else if (executionResult.hasErrors()) {
throw executionResult.composeError();
}
} finally {
consumer.finished();
}
}
Aggregations