use of com.intellij.openapi.vfs.VirtualFile in project intellij-community by JetBrains.
the class IdeaCommitHandler method trackDeletedFile.
private void trackDeletedFile(@NotNull ProgressEvent event) {
@NonNls final String filePath = "file://" + event.getFile().getAbsolutePath().replace(File.separatorChar, '/');
VirtualFile virtualFile = ApplicationManager.getApplication().runReadAction((Computable<VirtualFile>) () -> VirtualFileManager.getInstance().findFileByUrl(filePath));
if (virtualFile != null) {
myDeletedFiles.add(virtualFile);
}
}
use of com.intellij.openapi.vfs.VirtualFile in project intellij-community by JetBrains.
the class SvnCheckinHandlerFactory method createVcsHandler.
@NotNull
@Override
protected CheckinHandler createVcsHandler(final CheckinProjectPanel panel) {
final Project project = panel.getProject();
final Collection<VirtualFile> commitRoots = panel.getRoots();
return new CheckinHandler() {
private Collection<Change> myChanges = panel.getSelectedChanges();
@Override
public RefreshableOnComponent getBeforeCheckinConfigurationPanel() {
return null;
}
@Override
public ReturnResult beforeCheckin(@Nullable CommitExecutor executor, PairConsumer<Object, Object> additionalDataConsumer) {
if (executor instanceof LocalCommitExecutor)
return ReturnResult.COMMIT;
final SvnVcs vcs = SvnVcs.getInstance(project);
final MultiMap<String, WorkingCopyFormat> copiesInfo = splitIntoCopies(vcs, myChanges);
final List<String> repoUrls = new ArrayList<>();
for (Map.Entry<String, Collection<WorkingCopyFormat>> entry : copiesInfo.entrySet()) {
if (entry.getValue().size() > 1) {
repoUrls.add(entry.getKey());
}
}
if (!repoUrls.isEmpty()) {
final String join = StringUtil.join(repoUrls, ",\n");
final int isOk = Messages.showOkCancelDialog(project, SvnBundle.message("checkin.different.formats.involved", repoUrls.size() > 1 ? 1 : 0, join), "Subversion: Commit Will Split", Messages.getWarningIcon());
return Messages.OK == isOk ? ReturnResult.COMMIT : ReturnResult.CANCEL;
}
return ReturnResult.COMMIT;
}
@Override
public void includedChangesChanged() {
myChanges = panel.getSelectedChanges();
}
@Override
public void checkinSuccessful() {
if (SvnConfiguration.getInstance(project).isAutoUpdateAfterCommit()) {
final VirtualFile[] roots = ProjectLevelVcsManager.getInstance(project).getRootsUnderVcs(SvnVcs.getInstance(project));
final List<FilePath> paths = new ArrayList<>();
for (VirtualFile root : roots) {
boolean take = false;
for (VirtualFile commitRoot : commitRoots) {
if (VfsUtilCore.isAncestor(root, commitRoot, false)) {
take = true;
break;
}
}
if (take) {
paths.add(VcsUtil.getFilePath(root));
}
}
if (paths.isEmpty())
return;
ApplicationManager.getApplication().invokeLater(() -> AutoSvnUpdater.run(new AutoSvnUpdater(project, paths.toArray(new FilePath[paths.size()])), ActionInfo.UPDATE.getActionName()), ModalityState.NON_MODAL);
}
}
};
}
use of com.intellij.openapi.vfs.VirtualFile in project intellij-community by JetBrains.
the class SvnAnnotationProvider method annotateNonExisting.
private SvnRemoteFileAnnotation annotateNonExisting(Pair<SvnChangeList, FilePath> pair, VcsFileRevision revision, Info info, Charset charset, final VirtualFile current) throws VcsException, SVNException, IOException {
final File wasFile = pair.getSecond().getIOFile();
final File root = getCommonAncestor(wasFile, info.getFile());
if (root == null) {
throw new VcsException("Can not find relative path for " + wasFile.getPath() + "@" + revision.getRevisionNumber().asString());
}
final String relativePath = FileUtil.getRelativePath(root.getPath(), wasFile.getPath(), File.separatorChar);
if (relativePath == null) {
throw new VcsException("Can not find relative path for " + wasFile.getPath() + "@" + revision.getRevisionNumber().asString());
}
Info wcRootInfo = myVcs.getInfo(root);
if (wcRootInfo == null || wcRootInfo.getURL() == null) {
throw new VcsException("Can not find relative path for " + wasFile.getPath() + "@" + revision.getRevisionNumber().asString());
}
SVNURL wasUrl = wcRootInfo.getURL();
final String[] strings = relativePath.replace('\\', '/').split("/");
for (String string : strings) {
wasUrl = wasUrl.appendPath(string, true);
}
final SVNRevision svnRevision = ((SvnRevisionNumber) revision.getRevisionNumber()).getRevision();
byte[] data = SvnUtil.getFileContents(myVcs, SvnTarget.fromURL(wasUrl), svnRevision, svnRevision);
final String contents = LoadTextUtil.getTextByBinaryPresentation(data, charset == null ? CharsetToolkit.UTF8_CHARSET : charset).toString();
final SvnRemoteFileAnnotation result = new SvnRemoteFileAnnotation(myVcs, contents, revision.getRevisionNumber(), current);
final AnnotationConsumer annotateHandler = createAnnotationHandler(ProgressManager.getInstance().getProgressIndicator(), result);
boolean calculateMergeinfo = myVcs.getSvnConfiguration().isShowMergeSourcesInAnnotate() && SvnUtil.checkRepositoryVersion15(myVcs, wasUrl.toString());
AnnotateClient client = myVcs.getFactory().createAnnotateClient();
client.annotate(SvnTarget.fromURL(wasUrl, svnRevision), SVNRevision.create(1), svnRevision, calculateMergeinfo, getLogClientOptions(myVcs), annotateHandler);
return result;
}
use of com.intellij.openapi.vfs.VirtualFile in project intellij-community by JetBrains.
the class SvnCheckoutProvider method doImport.
public static void doImport(final Project project, final File target, final SVNURL url, final Depth depth, final boolean includeIgnored, final String message) {
final Ref<String> errorMessage = new Ref<>();
final SvnVcs vcs = SvnVcs.getInstance(project);
final String targetPath = FileUtil.toSystemIndependentName(target.getAbsolutePath());
ExclusiveBackgroundVcsAction.run(project, () -> ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> {
final FileIndexFacade facade = PeriodicalTasksCloser.getInstance().safeGetService(project, FileIndexFacade.class);
ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator();
try {
progressIndicator.setText(message("progress.text.import", target.getAbsolutePath()));
final VirtualFile targetVf = SvnUtil.getVirtualFile(targetPath);
if (targetVf == null) {
errorMessage.set("Can not find file: " + targetPath);
} else {
final boolean isInContent = getApplication().runReadAction((Computable<Boolean>) () -> facade.isInContent(targetVf));
CommitEventHandler handler = new IdeaCommitHandler(progressIndicator);
boolean useFileFilter = !project.isDefault() && isInContent;
ISVNCommitHandler commitHandler = useFileFilter ? new MyFilter(LocalFileSystem.getInstance(), new SvnExcludingIgnoredOperation.Filter(project)) : null;
long revision = vcs.getFactoryFromSettings().createImportClient().doImport(target, url, depth, message, includeIgnored, handler, commitHandler);
if (revision > 0) {
StatusBar.Info.set(message("status.text.comitted.revision", revision), project);
}
}
} catch (VcsException e) {
errorMessage.set(e.getMessage());
}
}, message("message.title.import"), true, project));
if (!errorMessage.isNull()) {
showErrorDialog(message("message.text.cannot.import", errorMessage.get()), message("message.title.import"));
}
}
use of com.intellij.openapi.vfs.VirtualFile in project intellij-community by JetBrains.
the class ShareWholeProject method actionPerformed.
public void actionPerformed(AnActionEvent e) {
final MyChecker checker = new MyChecker();
checker.execute(e);
if (!checker.isEnabled())
return;
final Project project = checker.getProject();
final VirtualFile baseDir = project.getBaseDir();
if (baseDir == null)
return;
boolean success = false;
boolean excThrown = false;
try {
success = ShareProjectAction.share(project, baseDir);
} catch (VcsException exc) {
AbstractVcsHelper.getInstance(project).showError(exc, "Failed to Share Project");
excThrown = true;
} finally {
// if success = false -> either action was cancelled or exception was thrown, so also check for exception
if (success || excThrown) {
baseDir.refresh(true, true, () -> ApplicationManager.getApplication().invokeLater(() -> {
VcsDirtyScopeManager.getInstance(project).dirDirtyRecursively(project.getBaseDir());
if (checker.isHadNoMappings() && SvnUtil.seemsLikeVersionedDir(baseDir)) {
final ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(project);
vcsManager.setDirectoryMappings(Arrays.asList(new VcsDirectoryMapping("", SvnVcs.VCS_NAME)));
}
}, ModalityState.NON_MODAL, project.getDisposed()));
}
}
}
Aggregations