use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.
the class GetFileFromRepositoryAction method getCvsHandler.
protected CvsHandler getCvsHandler(CvsContext context) {
CvsLightweightFile[] cvsLightweightFiles = context.getSelectedLightweightFiles();
Project project = context.getProject();
if (cvsLightweightFiles != null) {
boolean makeNewFilesReadOnly = project != null && CvsConfiguration.getInstance(project).MAKE_NEW_FILES_READONLY;
return CommandCvsHandler.createGetFileFromRepositoryHandler(cvsLightweightFiles, makeNewFilesReadOnly);
}
final FilePath[] filePaths = context.getSelectedFilePaths();
if (filePaths != null) {
CvsConfiguration cvsConfiguration = CvsConfiguration.getInstance(project);
// do not use -j's
final UpdateSettingsOnCvsConfiguration updateSettings = new UpdateSettingsOnCvsConfiguration(cvsConfiguration, cvsConfiguration.CLEAN_COPY, cvsConfiguration.RESET_STICKY);
return CommandCvsHandler.createUpdateHandler(filePaths, updateSettings, project, UpdatedFiles.create());
}
return CvsHandler.NULL;
}
use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.
the class RemoveLocallyFileOrDirectoryAction method getCvsHandler.
private static CvsHandler getCvsHandler(final Project project, final Collection<File> filesToRemove, final boolean showDialog) {
final ArrayList<File> files = new ArrayList<>();
for (final File file : filesToRemove) {
if (CvsUtil.fileIsLocallyAdded(file)) {
CvsUtil.removeEntryFor(file);
} else {
files.add(file);
}
}
if (files.isEmpty())
return CvsHandler.NULL;
Collection<FilePath> filesToBeRemoved = filesToFilePaths(files);
if (showDialog) {
final AbstractVcsHelper vcsHelper = AbstractVcsHelper.getInstance(project);
filesToBeRemoved = vcsHelper.selectFilePathsToProcess(filesToFilePaths(files), CvsBundle.message("dialog.title.delete.files.from.cvs"), null, CvsBundle.message("dialog.title.delete.file.from.cvs"), CvsBundle.message("confirmation.text.delete.file.from.cvs"), VcsShowConfirmationOption.STATIC_SHOW_CONFIRMATION, CvsBundle.message("button.text.delete.from.cvs"), CommonBundle.getCancelButtonText());
if (filesToBeRemoved == null || filesToBeRemoved.isEmpty())
return CvsHandler.NULL;
}
return CommandCvsHandler.createRemoveFilesHandler(project, ChangesUtil.filePathsToFiles(filesToBeRemoved));
}
use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.
the class CvsAnnotationProvider method annotate.
public FileAnnotation annotate(VirtualFile cvsVirtualFile, String revision, CvsEnvironment environment) throws VcsException {
// the VirtualFile has a full path if annotate is called from history (when we have a real file on disk),
// and has the path equal to a CVS module name if annotate is called from the CVS repository browser
// (when there's no real path)
boolean hasLocalFile = false;
File cvsFile = new File(cvsVirtualFile.getPath());
if (cvsFile.isAbsolute()) {
hasLocalFile = true;
cvsFile = new File(CvsUtil.getModuleName(cvsVirtualFile));
}
final boolean binary = annotateBinary(cvsVirtualFile, environment);
final AnnotateOperation annotateOperation = executeOperation(cvsFile, revision, environment, binary, true);
final Annotation[] lineAnnotations = annotateOperation.getLineAnnotations();
final List<VcsFileRevision> revisions;
if (hasLocalFile) {
final FilePath filePath = VcsContextFactory.SERVICE.getInstance().createFilePathOn(cvsVirtualFile);
revisions = myCvsHistoryProvider.createRevisions(filePath);
// in annotation cvs returns only 8 symbols of username
// try to find usernames in history and use them
adjustAnnotation(revisions, lineAnnotations);
} else {
// imitation
revisions = new ArrayList<>();
final Set<String> usedRevisions = new HashSet<>();
for (Annotation annotation : lineAnnotations) {
if (!usedRevisions.contains(annotation.getRevision())) {
revisions.add(new RevisionPresentation(annotation.getRevision(), annotation.getUserName(), annotation.getDate()));
usedRevisions.add(annotation.getRevision());
}
}
}
return new CvsFileAnnotation(annotateOperation.getContent(), lineAnnotations, revisions, cvsVirtualFile, revision, myProject);
}
use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.
the class BranchAction method getCvsHandler.
protected CvsHandler getCvsHandler(CvsContext context) {
final FilePath[] selectedFiles = context.getSelectedFilePaths();
final Project project = context.getProject();
final CreateTagDialog dialog = new CreateTagDialog(selectedFiles, project, false);
if (!dialog.showAndGet()) {
return CvsHandler.NULL;
}
final boolean makeNewFilesReadOnly = CvsConfiguration.getInstance(project).MAKE_NEW_FILES_READONLY;
return CommandCvsHandler.createBranchHandler(selectedFiles, dialog.getTagName(), dialog.switchToThisBranch(), dialog.getOverrideExisting(), makeNewFilesReadOnly, project);
}
use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.
the class CvsCheckinEnvironment method commit.
public List<VcsException> commit(List<Change> changes, String preparedComment, @NotNull NullableFunction<Object, Object> parametersHolder, Set<String> feedback) {
final Collection<FilePath> filesList = ChangesUtil.getPaths(changes);
FilePath[] files = filesList.toArray(new FilePath[filesList.size()]);
final CvsOperationExecutor executor = new CvsOperationExecutor(myProject);
executor.setShowErrors(false);
final List<File> dirsToPrune = new ArrayList<>();
for (Change c : changes) {
if (c.getType() == Change.Type.DELETED) {
final ContentRevision contentRevision = c.getBeforeRevision();
assert contentRevision != null;
final FilePath path = contentRevision.getFile();
final FilePath parentPath = path.getParentPath();
if (parentPath != null) {
dirsToPrune.add(parentPath.getIOFile());
}
}
}
final CvsConfiguration cvsConfiguration = CvsConfiguration.getInstance(myProject);
CvsHandler handler = CommandCvsHandler.createCommitHandler(files, preparedComment, CvsBundle.message("operation.name.commit.file", files.length), cvsConfiguration.MAKE_NEW_FILES_READONLY, myProject, cvsConfiguration.TAG_AFTER_PROJECT_COMMIT, cvsConfiguration.TAG_AFTER_PROJECT_COMMIT_NAME, dirsToPrune);
executor.performActionSync(handler, CvsOperationExecutorCallback.EMPTY);
return executor.getResult().getErrorsAndWarnings();
}
Aggregations