use of org.netbeans.lib.cvsclient.command.log.Revision in project intellij-community by JetBrains.
the class CvsHistoryProvider method createRevisions.
private List<VcsFileRevision> createRevisions(final CvsEnvironment connectionSettings, final File lightweightFileForFile) {
final LocalPathIndifferentLogOperation logOperation = new LocalPathIndifferentLogOperation(connectionSettings);
logOperation.addFile(lightweightFileForFile);
final CvsOperationExecutor executor = new CvsOperationExecutor(myProject);
final ArrayList<VcsFileRevision> result = new ArrayList<>();
executor.performActionSync(new CommandCvsHandler(CvsBundle.message("operation.name.load.file.content"), logOperation), new DefaultCvsOperationExecutorCallback() {
@Override
public void executionFinishedSuccessfully() {
final LogInformation firstLogInformation = logOperation.getFirstLogInformation();
if (firstLogInformation != null) {
final List<Revision> revisionList = firstLogInformation.getRevisionList();
for (Revision revision : revisionList) {
result.add(new CvsFileRevisionImpl(revision, lightweightFileForFile, firstLogInformation, connectionSettings, myProject));
}
}
}
});
Collections.sort(result, Collections.reverseOrder(VcsFileRevisionComparator.INSTANCE));
return result;
}
use of org.netbeans.lib.cvsclient.command.log.Revision in project intellij-community by JetBrains.
the class CvsChangeList method getChanges.
public Collection<Change> getChanges() {
if (myChanges == null) {
myChanges = new ArrayList<>();
for (RevisionWrapper wrapper : myRevisions) {
final Revision revision = wrapper.getRevision();
final String state = revision.getState();
String path = wrapper.getFile();
final File localFile;
if (myRootFile != null) {
final String directorySuffix = myRootFile.isDirectory() ? "/" : "";
if (StringUtil.startsWithConcatenation(path, myRootPath, directorySuffix)) {
path = path.substring(myRootPath.length() + directorySuffix.length());
localFile = new File(myRootFile.getPresentableUrl(), path);
} else {
localFile = new File(wrapper.getFile());
}
} else {
localFile = new File(wrapper.getFile());
}
final boolean added = isAdded(revision);
final ContentRevision beforeRevision = added ? null : new CvsContentRevision(new File(wrapper.getFile()), localFile, new SimpleRevision(new CvsRevisionNumber(revision.getNumber()).getPrevNumber().asString()), myEnvironment, myProject);
final ContentRevision afterRevision = (!added && DEAD_STATE.equals(state)) ? null : new CvsContentRevision(new File(wrapper.getFile()), localFile, new SimpleRevision(revision.getNumber()), myEnvironment, myProject);
myChanges.add(new Change(beforeRevision, afterRevision));
}
}
return myChanges;
}
use of org.netbeans.lib.cvsclient.command.log.Revision 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 org.netbeans.lib.cvsclient.command.log.Revision in project intellij-community by JetBrains.
the class RevisionWrapper method readFromStream.
public static RevisionWrapper readFromStream(final DataInput stream) throws IOException {
final String file = stream.readUTF();
final String number = stream.readUTF();
final Revision revision = new Revision(number);
final long time = stream.readLong();
revision.setDate(new Date(time));
revision.setAuthor(stream.readUTF());
revision.setState(stream.readUTF());
final String lines = stream.readUTF();
if (lines.length() > 0) {
revision.setLines(lines);
}
revision.setMessage(stream.readUTF());
final String branches = stream.readUTF();
if (branches.length() > 0) {
revision.setBranches(branches);
}
final String branch = stream.readUTF();
return new RevisionWrapper(file, revision, branch.length() > 0 ? branch : null);
}
use of org.netbeans.lib.cvsclient.command.log.Revision in project intellij-community by JetBrains.
the class CvsChangeListsBuilder method addRevision.
public CvsChangeList addRevision(RevisionWrapper revisionWrapper) {
final Revision revision = revisionWrapper.getRevision();
final CvsChangeList version = findOrCreateVersionFor(revision.getMessage(), revisionWrapper.getTime(), revision.getAuthor(), revisionWrapper.getBranch(), revisionWrapper.getFile());
version.addFileRevision(revisionWrapper);
return version;
}
Aggregations