use of com.intellij.cvsSupport2.cvsoperations.dateOrRevision.SimpleRevision in project intellij-community by JetBrains.
the class CvsServicesImpl method getFileContent.
public byte[] getFileContent(Project project, CvsModule cvsFile) throws IOException {
final GetFileContentOperation operation = new GetFileContentOperation(new File(cvsFile.getPathInCvs()), CvsRootConfiguration.createOn(cvsFile.getRepository()), new SimpleRevision(cvsFile.getRevision()));
final CvsOperationExecutor executor = new CvsOperationExecutor(project);
executor.performActionSync(new CommandCvsHandler(CvsBundle.message("operation.name.load.file.content"), operation, false), CvsOperationExecutorCallback.EMPTY);
if (!executor.hasNoErrors())
throw new RuntimeException(executor.getFirstError());
if (operation.isDeleted())
throw new IOException(CvsBundle.message("exception.text.revision.has.been.deleted"));
return operation.getFileBytes();
}
use of com.intellij.cvsSupport2.cvsoperations.dateOrRevision.SimpleRevision 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 com.intellij.cvsSupport2.cvsoperations.dateOrRevision.SimpleRevision in project intellij-community by JetBrains.
the class CommandCvsHandler method createRestoreFileHandler.
public static CvsHandler createRestoreFileHandler(final VirtualFile parent, String name, boolean makeNewFilesReadOnly) {
final File ioFile = new File(VfsUtilCore.virtualToIoFile(parent), name);
final Entry entry = CvsEntriesManager.getInstance().getEntryFor(parent, name);
final String revision = getRevision(entry);
final CheckoutFileOperation operation = new CheckoutFileOperation(parent, new SimpleRevision(revision), name, makeNewFilesReadOnly);
final CommandCvsHandler cvsHandler = new CommandCvsHandler(CvsBundle.message("operation.name.restore"), operation, FileSetToBeUpdated.EMPTY);
operation.addFinishAction(() -> {
final List<VcsException> errors = cvsHandler.getErrors();
if (errors != null && !errors.isEmpty())
return;
if (entry != null) {
entry.setRevision(revision);
entry.setConflict(CvsUtil.formatDate(new Date(ioFile.lastModified())));
try {
CvsUtil.saveEntryForFile(ioFile, entry);
} catch (IOException e) {
LOG.error(e);
}
CvsEntriesManager.getInstance().clearCachedEntriesFor(parent);
}
});
return cvsHandler;
}
use of com.intellij.cvsSupport2.cvsoperations.dateOrRevision.SimpleRevision in project intellij-community by JetBrains.
the class CvsServicesImpl method createCvsVersionOn.
private static ComparableVcsRevisionOnOperation createCvsVersionOn(CvsModule module, Project project) {
final CvsRootConfiguration rootConfiguration = CvsApplicationLevelConfiguration.getInstance().getConfigurationForCvsRoot(module.getRepository().getStringRepresentation());
CvsConnectionSettings env = new IDEARootFormatter(rootConfiguration).createConfiguration();
GetFileContentOperation operation = new GetFileContentOperation(new File(module.getPathInCvs()), env, new SimpleRevision(module.getRevision()));
return new ComparableVcsRevisionOnOperation(operation, project);
}
use of com.intellij.cvsSupport2.cvsoperations.dateOrRevision.SimpleRevision in project intellij-community by JetBrains.
the class CvsDiffProvider method createFileContent.
public ContentRevision createFileContent(final VcsRevisionNumber revisionNumber, VirtualFile selectedFile) {
if ((revisionNumber instanceof CvsRevisionNumber)) {
final CvsConnectionSettings settings = CvsEntriesManager.getInstance().getCvsConnectionSettingsFor(selectedFile.getParent());
final File file = new File(CvsUtil.getModuleName(selectedFile));
final CvsRevisionNumber cvsRevisionNumber = ((CvsRevisionNumber) revisionNumber);
final RevisionOrDate versionInfo;
if (cvsRevisionNumber.getDateOrRevision() != null) {
versionInfo = RevisionOrDateImpl.createOn(cvsRevisionNumber.getDateOrRevision());
} else {
versionInfo = new SimpleRevision(cvsRevisionNumber.asString());
}
if (selectedFile.getFileType().isBinary()) {
return new CvsBinaryContentRevision(file, file, versionInfo, settings, myProject);
} else {
return new CvsContentRevision(file, file, versionInfo, settings, myProject);
}
} else {
return null;
}
}
Aggregations