Convert anonymous to lambda in [svn4idea]

This commit is contained in:
Konstantin Kolosovsky
2017-03-07 14:11:05 +03:00
parent ac469de826
commit 68bdb1d9c6
124 changed files with 1911 additions and 3186 deletions
@@ -32,24 +32,20 @@ import org.tmatesoft.svn.core.SVNException;
public abstract class RepeatSvnActionThroughBusy {
public static final int REPEAT = 10;
public static final Processor<Exception> ourBusyExceptionProcessor = new Processor<Exception>() {
@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
@Override
public boolean process(Exception e) {
if (e instanceof SVNException) {
final SVNErrorCode errorCode = ((SVNException)e).getErrorMessage().getErrorCode();
if (SVNErrorCode.WC_LOCKED.equals(errorCode)) {
return true;
}
else if (SVNErrorCode.SQLITE_ERROR.equals(errorCode)) {
Throwable cause = ((SVNException)e).getErrorMessage().getCause();
if (cause instanceof SqlJetException) {
return SqlJetErrorCode.BUSY.equals(((SqlJetException)cause).getErrorCode());
}
public static final Processor<Exception> ourBusyExceptionProcessor = e -> {
if (e instanceof SVNException) {
final SVNErrorCode errorCode = ((SVNException)e).getErrorMessage().getErrorCode();
if (SVNErrorCode.WC_LOCKED.equals(errorCode)) {
return true;
}
else if (SVNErrorCode.SQLITE_ERROR.equals(errorCode)) {
Throwable cause = ((SVNException)e).getErrorMessage().getCause();
if (cause instanceof SqlJetException) {
return SqlJetErrorCode.BUSY.equals(((SqlJetException)cause).getErrorCode());
}
}
return false;
}
return false;
};
protected int myCnt = REPEAT;
@@ -57,14 +57,12 @@ public class RootsToWorkingCopies implements VcsListener {
myRootMapping = new HashMap<>();
myUnversioned = new HashSet<>();
myVcs = vcs;
myRechecker = new Runnable() {
public void run() {
final VirtualFile[] roots = ProjectLevelVcsManager.getInstance(myProject).getRootsUnderVcs(myVcs);
synchronized (myLock) {
clear();
for (VirtualFile root : roots) {
addRoot(root);
}
myRechecker = () -> {
final VirtualFile[] roots = ProjectLevelVcsManager.getInstance(myProject).getRootsUnderVcs(myVcs);
synchronized (myLock) {
clear();
for (VirtualFile root : roots) {
addRoot(root);
}
}
};
@@ -59,13 +59,7 @@ public class SvnChangeProvider implements ChangeProvider {
private static final Logger LOG = Logger.getInstance("#org.jetbrains.idea.svn.SvnChangeProvider");
public static final String PROPERTY_LAYER = "Property";
private static final NotNullFactory<Map<String, File>> NAME_TO_FILE_MAP_FACTORY = new NotNullFactory<Map<String, File>>() {
@NotNull
@Override
public Map<String, File> create() {
return ContainerUtil.newHashMap();
}
};
private static final NotNullFactory<Map<String, File>> NAME_TO_FILE_MAP_FACTORY = () -> ContainerUtil.newHashMap();
@NotNull private final SvnVcs myVcs;
@NotNull private final VcsContextFactory myFactory;
@@ -176,12 +170,7 @@ public class SvnChangeProvider implements ChangeProvider {
}
}
return new ISVNStatusFileProvider() {
@Override
public Map<String, File> getChildrenFiles(File parent) {
return result.get(parent.getAbsolutePath());
}
};
return parent -> result.get(parent.getAbsolutePath());
}
private void processCopiedAndDeleted(@NotNull SvnChangeProviderContext context, @Nullable VcsDirtyScope dirtyScope) throws SVNException {
@@ -285,12 +274,10 @@ public class SvnChangeProvider implements ChangeProvider {
final Change change = context
.createMovedChange(createBeforeRevision(deletedFile, true), CurrentContentRevision.create(oldPath), copiedStatus,
deletedFile.getStatus());
final boolean isUnder = dirtyScope == null ? true : ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
@Override
public Boolean compute() {
return ChangeListManagerImpl.isUnder(change, dirtyScope);
}
});
final boolean isUnder = dirtyScope == null
? true
: ApplicationManager.getApplication()
.runReadAction((Computable<Boolean>)() -> ChangeListManagerImpl.isUnder(change, dirtyScope));
if (isUnder) {
context.getBuilder().removeRegisteredChangeFor(oldPath);
context.getBuilder().processChangeInList(change, clName, SvnVcs.getKey());
@@ -44,12 +44,9 @@ public class SvnChangelistListener implements ChangeListListener {
public SvnChangelistListener(@NotNull SvnVcs vcs) {
myVcs = vcs;
myUnderSvnCondition = new Condition<FilePath>() {
@Override
public boolean value(@NotNull FilePath path) {
final AbstractVcs vcs = ProjectLevelVcsManager.getInstance(myVcs.getProject()).getVcsFor(path);
return vcs != null && SvnVcs.VCS_NAME.equals(vcs.getName());
}
myUnderSvnCondition = path -> {
final AbstractVcs vcs1 = ProjectLevelVcsManager.getInstance(myVcs.getProject()).getVcsFor(path);
return vcs1 != null && SvnVcs.VCS_NAME.equals(vcs1.getName());
};
}
@@ -20,7 +20,6 @@ import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.MessageType;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.vcs.ui.VcsBalloonProblemNotifier;
import com.intellij.openapi.vfs.VirtualFile;
@@ -55,30 +54,21 @@ public class SvnCompatibilityChecker {
myCounter = 0;
++ myInvocationCounter;
final Application application = ApplicationManager.getApplication();
application.executeOnPooledThread(new Runnable() {
public void run() {
final List<VirtualFile> suspicious = new ArrayList<>();
for (VirtualFile vf : result) {
if (SvnUtil.seemsLikeVersionedDir(vf)) {
suspicious.add(vf);
}
}
if (! suspicious.isEmpty()) {
final String message = (suspicious.size() == 1) ?
"Root '" + suspicious.get(0).getPresentableName() + "' is likely to be of unsupported Subversion format" :
"Some roots are likely to be of unsupported Subversion format";
application.invokeLater(new Runnable() {
public void run() {
new VcsBalloonProblemNotifier(myProject, message, MessageType.WARNING).run();
}
}, ModalityState.NON_MODAL, new Condition() {
@Override
public boolean value(Object o) {
return (! myProject.isOpen()) || myProject.isDisposed();
}
});
application.executeOnPooledThread(() -> {
final List<VirtualFile> suspicious = new ArrayList<>();
for (VirtualFile vf : result) {
if (SvnUtil.seemsLikeVersionedDir(vf)) {
suspicious.add(vf);
}
}
if (!suspicious.isEmpty()) {
final String message = (suspicious.size() == 1)
? "Root '" + suspicious.get(0).getPresentableName() + "' is likely to be of unsupported Subversion format"
: "Some roots are likely to be of unsupported Subversion format";
application
.invokeLater(() -> new VcsBalloonProblemNotifier(myProject, message, MessageType.WARNING).run(), ModalityState.NON_MODAL,
o -> (!myProject.isOpen()) || myProject.isDisposed());
}
});
}
}
@@ -37,7 +37,6 @@ import com.intellij.ui.MultiLineTooltipUI;
import com.intellij.ui.components.JBCheckBox;
import com.intellij.ui.components.JBRadioButton;
import com.intellij.ui.components.labels.LinkLabel;
import com.intellij.ui.components.labels.LinkListener;
import com.intellij.util.Consumer;
import com.intellij.util.net.HttpProxyConfigurable;
import com.intellij.util.ui.UIUtil;
@@ -51,10 +50,6 @@ import org.jetbrains.idea.svn.svnkit.SvnKitManager;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.io.File;
public class SvnConfigurable implements Configurable {
@@ -96,79 +91,52 @@ public class SvnConfigurable implements Configurable {
public SvnConfigurable(Project project) {
myProject = project;
myWithCommandLineClient.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
enableCommandLineClientOptions();
}
});
myWithCommandLineClient.addItemListener(e -> enableCommandLineClientOptions());
enableCommandLineClientOptions();
myUseDefaultCheckBox.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
boolean enabled = !myUseDefaultCheckBox.isSelected();
myConfigurationDirectoryText.setEnabled(enabled);
myConfigurationDirectoryText.setEditable(enabled);
myConfigurationDirectoryLabel.setEnabled(enabled);
SvnConfiguration configuration = SvnConfiguration.getInstance(myProject);
String path = configuration.getConfigurationDirectory();
if (!enabled || path == null) {
myConfigurationDirectoryText.setText(IdeaSubversionConfigurationDirectory.getPath());
}
else {
myConfigurationDirectoryText.setText(path);
}
myUseDefaultCheckBox.addActionListener(e -> {
boolean enabled = !myUseDefaultCheckBox.isSelected();
myConfigurationDirectoryText.setEnabled(enabled);
myConfigurationDirectoryText.setEditable(enabled);
myConfigurationDirectoryLabel.setEnabled(enabled);
SvnConfiguration configuration = SvnConfiguration.getInstance(myProject);
String path = configuration.getConfigurationDirectory();
if (!enabled || path == null) {
myConfigurationDirectoryText.setText(IdeaSubversionConfigurationDirectory.getPath());
}
else {
myConfigurationDirectoryText.setText(path);
}
});
myCommandLineClient.addBrowseFolderListener("Subversion", "Select path to Subversion executable (1.7+)", project,
FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor());
myClearAuthButton.addActionListener(new ActionListener(){
public void actionPerformed(final ActionEvent e) {
SvnAuthenticationNotifier.clearAuthenticationCache(myProject, myComponent, myConfigurationDirectoryText.getText());
}
});
myClearAuthButton.addActionListener(
e -> SvnAuthenticationNotifier.clearAuthenticationCache(myProject, myComponent, myConfigurationDirectoryText.getText()));
myConfigurationDirectoryText.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
@NonNls String path = myConfigurationDirectoryText.getText().trim();
selectConfigurationDirectory(path, new Consumer<String>() {
@Override
public void consume(String s) {
myConfigurationDirectoryText.setText(s);
}
}, myProject, myComponent);
}
myConfigurationDirectoryText.addActionListener(e -> {
@NonNls String path = myConfigurationDirectoryText.getText().trim();
selectConfigurationDirectory(path, s -> myConfigurationDirectoryText.setText(s), myProject, myComponent);
});
myConfigurationDirectoryLabel.setLabelFor(myConfigurationDirectoryText);
myUseCommonProxy.setText(SvnBundle.message("use.idea.proxy.as.default", ApplicationNamesInfo.getInstance().getProductName()));
myNavigateToCommonProxyLink.setListener(new LinkListener<Object>() {
@Override
public void linkSelected(LinkLabel aSource, Object aLinkData) {
Settings settings = Settings.KEY.getData(DataManager.getInstance().getDataContext(myComponent));
myNavigateToCommonProxyLink.setListener((aSource, aLinkData) -> {
Settings settings = Settings.KEY.getData(DataManager.getInstance().getDataContext(myComponent));
if (settings != null) {
settings.select(settings.find(HttpProxyConfigurable.class));
}
if (settings != null) {
settings.select(settings.find(HttpProxyConfigurable.class));
}
}, null);
myEditProxiesButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final SvnConfigureProxiesDialog dialog = new SvnConfigureProxiesDialog(myProject);
dialog.show();
myHttpTimeout.setValue(Long.valueOf(SvnConfiguration.getInstance(myProject).getHttpTimeout() / 1000));
}
myEditProxiesButton.addActionListener(e -> {
final SvnConfigureProxiesDialog dialog = new SvnConfigureProxiesDialog(myProject);
dialog.show();
myHttpTimeout.setValue(Long.valueOf(SvnConfiguration.getInstance(myProject).getHttpTimeout() / 1000));
});
myMaximumNumberOfRevisionsCheckBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
myNumRevsInAnnotations.setEnabled(myMaximumNumberOfRevisionsCheckBox.isSelected());
}
});
myMaximumNumberOfRevisionsCheckBox
.addActionListener(e -> myNumRevsInAnnotations.setEnabled(myMaximumNumberOfRevisionsCheckBox.isSelected()));
myNumRevsInAnnotations.setEnabled(myMaximumNumberOfRevisionsCheckBox.isSelected());
final ButtonGroup bg = new ButtonGroup();
@@ -17,7 +17,6 @@
package org.jetbrains.idea.svn;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.components.*;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Comparing;
@@ -374,12 +373,7 @@ public class SvnConfiguration implements PersistentStateComponent<SvnConfigurati
if (myAuthManager == null) {
// reloaded when configuration directory changes
myAuthManager = new SvnAuthenticationManager(svnVcs, new File(getConfigurationDirectory()));
Disposer.register(svnVcs.getProject(), new Disposable() {
@Override
public void dispose() {
myAuthManager = null;
}
});
Disposer.register(svnVcs.getProject(), () -> myAuthManager = null);
getInteractiveManager(svnVcs);
// to init
myAuthManager.setAuthenticationProvider(new SvnAuthenticationProvider(svnVcs, myInteractiveProvider, myAuthManager));
@@ -17,7 +17,6 @@ package org.jetbrains.idea.svn;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.util.RequestsMerger;
import com.intellij.util.Consumer;
import com.intellij.util.concurrency.Semaphore;
public class SvnCopiesRefreshManager {
@@ -28,24 +27,12 @@ public class SvnCopiesRefreshManager {
public SvnCopiesRefreshManager(final SvnFileUrlMappingImpl mapping) {
mySemaphore = new Semaphore();
// svn mappings refresh inside also uses asynchronous pass -> we need to pass callback that will ping our "single-threaded" executor here
myMappingCallback = new Runnable() {
@Override
public void run() {
mySemaphore.up();
}
};
myRequestsMerger = new RequestsMerger(new Runnable() {
@Override
public void run() {
mySemaphore.down();
mapping.realRefresh(myMappingCallback);
mySemaphore.waitFor();
}
}, new Consumer<Runnable>() {
public void consume(final Runnable runnable) {
ApplicationManager.getApplication().executeOnPooledThread(runnable);
}
});
myMappingCallback = () -> mySemaphore.up();
myRequestsMerger = new RequestsMerger(() -> {
mySemaphore.down();
mapping.realRefresh(myMappingCallback);
mySemaphore.waitFor();
}, runnable -> ApplicationManager.getApplication().executeOnPooledThread(runnable));
}
public void asynchRequest() {
@@ -40,7 +40,6 @@ import org.jetbrains.idea.svn.info.InfoConsumer;
import org.jetbrains.idea.svn.properties.PropertyValue;
import org.jetbrains.idea.svn.status.Status;
import org.jetbrains.idea.svn.status.StatusType;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.wc.SVNRevision;
import org.tmatesoft.svn.core.wc2.SvnTarget;
@@ -118,18 +117,15 @@ public class SvnDiffProvider extends DiffProviderEx implements DiffProvider, Dif
@NotNull
private static InfoConsumer createInfoHandler(@NotNull final Map<VirtualFile, VcsRevisionNumber> revisionMap,
@NotNull final Map<String, VirtualFile> fileMap) {
return new InfoConsumer() {
@Override
public void consume(Info info) throws SVNException {
if (info != null) {
VirtualFile file = fileMap.get(info.getFile().getAbsolutePath());
return info -> {
if (info != null) {
VirtualFile file = fileMap.get(info.getFile().getAbsolutePath());
if (file != null) {
revisionMap.put(file, getRevision(info));
}
else {
LOG.info("Could not find virtual file for path " + info.getFile().getAbsolutePath());
}
if (file != null) {
revisionMap.put(file, getRevision(info));
}
else {
LOG.info("Could not find virtual file for path " + info.getFile().getAbsolutePath());
}
}
};
@@ -40,7 +40,6 @@ import com.intellij.openapi.vfs.LocalFileOperationsHandler;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.newvfs.RefreshQueue;
import com.intellij.util.Processor;
import com.intellij.util.ThrowableConsumer;
import com.intellij.util.containers.Convertor;
import com.intellij.util.containers.MultiMap;
@@ -359,22 +358,19 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp
private static void copyUnversionedMembersOfDirectory(final File src, final File dst) throws SvnBindException {
if (src.isDirectory()) {
final SvnBindException[] exc = new SvnBindException[1];
FileUtil.processFilesRecursively(src, new Processor<File>() {
@Override
public boolean process(File file) {
String relativePath = FileUtil.getRelativePath(src, file);
File newFile = new File(dst, relativePath);
if (!newFile.exists()) {
try {
FileUtil.copyFileOrDir(src, dst);
}
catch (IOException e) {
exc[0] = new SvnBindException(e);
return false;
}
FileUtil.processFilesRecursively(src, file -> {
String relativePath = FileUtil.getRelativePath(src, file);
File newFile = new File(dst, relativePath);
if (!newFile.exists()) {
try {
FileUtil.copyFileOrDir(src, dst);
}
catch (IOException e) {
exc[0] = new SvnBindException(e);
return false;
}
return true;
}
return true;
});
if (exc[0] != null) {
throw exc[0];
@@ -709,15 +705,13 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp
// if refresh asynchronously, local changes would also be notified that they are dirty asynchronously,
// and commit could be executed while not all changes are visible
filterOutInvalid(myFilesToRefresh);
RefreshQueue.getInstance().refresh(true, true, new Runnable() {
public void run() {
if (project.isDisposed()) return;
filterOutInvalid(toRefreshFiles);
filterOutInvalid(toRefreshDirs);
RefreshQueue.getInstance().refresh(true, true, () -> {
if (project.isDisposed()) return;
filterOutInvalid(toRefreshFiles);
filterOutInvalid(toRefreshDirs);
final VcsDirtyScopeManager vcsDirtyScopeManager = VcsDirtyScopeManager.getInstance(project);
vcsDirtyScopeManager.filesDirty(toRefreshFiles, toRefreshDirs);
}
final VcsDirtyScopeManager vcsDirtyScopeManager = VcsDirtyScopeManager.getInstance(project);
vcsDirtyScopeManager.filesDirty(toRefreshFiles, toRefreshDirs);
}, myFilesToRefresh);
myFilesToRefresh.clear();
}
@@ -748,18 +742,15 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp
// Current method could be invoked under write action (for instance, during project import). So we explicitly use
// Application.invokeLater() in such cases to prevent deadlocks (while accessing vcs root mappings) and also not to show dialog under
// write action.
runNotUnderWriteAction(project, new Runnable() {
@Override
public void run() {
final AbstractVcsHelper vcsHelper = AbstractVcsHelper.getInstance(project);
final Collection<VirtualFile> filesToProcess = promptAboutAddition(vcs, addedVFiles, value, vcsHelper);
if (filesToProcess != null && !filesToProcess.isEmpty()) {
final List<VcsException> exceptions = new ArrayList<>();
runInBackground(project, "Adding files to Subversion",
createAdditionRunnable(project, vcs, copyFromMap, filesToProcess, exceptions));
if (!exceptions.isEmpty()) {
vcsHelper.showErrors(exceptions, SvnBundle.message("add.files.errors.title"));
}
runNotUnderWriteAction(project, () -> {
final AbstractVcsHelper vcsHelper = AbstractVcsHelper.getInstance(project);
final Collection<VirtualFile> filesToProcess = promptAboutAddition(vcs, addedVFiles, value, vcsHelper);
if (filesToProcess != null && !filesToProcess.isEmpty()) {
final List<VcsException> exceptions = new ArrayList<>();
runInBackground(project, "Adding files to Subversion",
createAdditionRunnable(project, vcs, copyFromMap, filesToProcess, exceptions));
if (!exceptions.isEmpty()) {
vcsHelper.showErrors(exceptions, SvnBundle.message("add.files.errors.title"));
}
}
});
@@ -789,44 +780,41 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp
final Map<VirtualFile, File> copyFromMap,
final Collection<VirtualFile> filesToProcess,
final List<VcsException> exceptions) {
return new Runnable() {
@Override
public void run() {
for(VirtualFile file: filesToProcess) {
final File ioFile = new File(file.getPath());
try {
final File copyFrom = copyFromMap.get(file);
if (copyFrom != null) {
try {
new ActionWithTempFile(ioFile) {
protected void executeInternal() throws VcsException {
// not recursive
new RepeatSvnActionThroughBusy() {
@Override
protected void executeImpl() throws VcsException {
vcs.getFactory(copyFrom).createCopyMoveClient().copy(copyFrom, ioFile, true, false);
}
}.execute();
}
}.execute();
}
catch (VcsException e) {
exceptions.add(e);
}
}
else {
new RepeatSvnActionThroughBusy() {
@Override
protected void executeImpl() throws VcsException {
vcs.getFactory(ioFile).createAddClient().add(ioFile, null, false, false, true, null);
return () -> {
for (VirtualFile file : filesToProcess) {
final File ioFile = new File(file.getPath());
try {
final File copyFrom = copyFromMap.get(file);
if (copyFrom != null) {
try {
new ActionWithTempFile(ioFile) {
protected void executeInternal() throws VcsException {
// not recursive
new RepeatSvnActionThroughBusy() {
@Override
protected void executeImpl() throws VcsException {
vcs.getFactory(copyFrom).createCopyMoveClient().copy(copyFrom, ioFile, true, false);
}
}.execute();
}
}.execute();
}
VcsDirtyScopeManager.getInstance(project).fileDirty(file);
catch (VcsException e) {
exceptions.add(e);
}
}
catch (VcsException e) {
exceptions.add(e);
else {
new RepeatSvnActionThroughBusy() {
@Override
protected void executeImpl() throws VcsException {
vcs.getFactory(ioFile).createAddClient().add(ioFile, null, false, false, true, null);
}
}.execute();
}
VcsDirtyScopeManager.getInstance(project).fileDirty(file);
}
catch (VcsException e) {
exceptions.add(e);
}
}
};
@@ -907,12 +895,7 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp
if (!filesToProcess.isEmpty()) {
runInBackground(project, "Deleting files from Subversion", createDeleteRunnable(project, vcs, filesToProcess, exceptions));
}
final List<FilePath> deletedFilesFiles = ObjectsConvertor.convert(deletedFiles, new Convertor<Pair<FilePath, WorkingCopyFormat>, FilePath>() {
@Override
public FilePath convert(Pair<FilePath, WorkingCopyFormat> o) {
return o.getFirst();
}
});
final List<FilePath> deletedFilesFiles = ObjectsConvertor.convert(deletedFiles, o -> o.getFirst());
for (FilePath file : deletedFilesFiles) {
final FilePath parent = file.getParentPath();
if (parent != null) {
@@ -936,25 +919,23 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp
final SvnVcs vcs,
final Collection<FilePath> filesToProcess,
final List<VcsException> exceptions) {
return new Runnable() {
public void run() {
for(FilePath file: filesToProcess) {
VirtualFile vFile = file.getVirtualFile(); // for deleted directories
final File ioFile = new File(file.getPath());
try {
createDeleteAction(vcs, ioFile, true).execute();
if (vFile != null && vFile.isValid() && vFile.isDirectory()) {
vFile.refresh(true, true);
VcsDirtyScopeManager.getInstance(project).dirDirtyRecursively(vFile);
}
else {
VcsDirtyScopeManager.getInstance(project).fileDirty(file);
}
return () -> {
for (FilePath file : filesToProcess) {
VirtualFile vFile = file.getVirtualFile(); // for deleted directories
final File ioFile = new File(file.getPath());
try {
createDeleteAction(vcs, ioFile, true).execute();
if (vFile != null && vFile.isValid() && vFile.isDirectory()) {
vFile.refresh(true, true);
VcsDirtyScopeManager.getInstance(project).dirDirtyRecursively(vFile);
}
catch (VcsException e) {
exceptions.add(e);
else {
VcsDirtyScopeManager.getInstance(project).fileDirty(file);
}
}
catch (VcsException e) {
exceptions.add(e);
}
}
};
}
@@ -963,13 +944,7 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp
SvnVcs vcs,
VcsShowConfirmationOption.Value value,
AbstractVcsHelper vcsHelper) {
final Convertor<Pair<FilePath, WorkingCopyFormat>, FilePath> convertor =
new Convertor<Pair<FilePath, WorkingCopyFormat>, FilePath>() {
@Override
public FilePath convert(Pair<FilePath, WorkingCopyFormat> o) {
return o.getFirst();
}
};
final Convertor<Pair<FilePath, WorkingCopyFormat>, FilePath> convertor = o -> o.getFirst();
Collection<FilePath> filesToProcess;
if (value == VcsShowConfirmationOption.Value.DO_ACTION_SILENTLY) {
filesToProcess = ObjectsConvertor.convert(deletedFiles, convertor);
@@ -1016,14 +991,12 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp
private void processMovedFiles(final Project project) {
if (myMovedFiles.isEmpty()) return;
final Runnable runnable = new Runnable() {
public void run() {
for (Iterator<MovedFileInfo> iterator = myMovedFiles.iterator(); iterator.hasNext();) {
MovedFileInfo movedFileInfo = iterator.next();
if (movedFileInfo.myProject == project) {
doMove(SvnVcs.getInstance(project), movedFileInfo.mySrc, movedFileInfo.myDst);
iterator.remove();
}
final Runnable runnable = () -> {
for (Iterator<MovedFileInfo> iterator = myMovedFiles.iterator(); iterator.hasNext(); ) {
MovedFileInfo movedFileInfo = iterator.next();
if (movedFileInfo.myProject == project) {
doMove(SvnVcs.getInstance(project), movedFileInfo.mySrc, movedFileInfo.myDst);
iterator.remove();
}
}
};
@@ -165,18 +165,16 @@ public class SvnNativeCallsTranslator {
}
static {
ourAdvices.put(-25293, new Convertor<NativeLogReader.CallInfo, String>() {
@Override
public String convert(NativeLogReader.CallInfo callInfo) {
if (! SystemInfo.isMac) return null;
final Trinity<String, String, String> trinity = MacParser.macMessages.get(callInfo.getResultCode());
if (trinity == null) return null;
return MessageFormat.format(ourGenericAdvice, callInfo.getFunctionName(),
new StringBuilder().append(callInfo.getResultCode()).append(" ( ").append(trinity.getFirst())
.append(" - ").append(trinity.getSecond()).append(")").append("\nYou are likely to have modified ")
.append(ApplicationInfo.getInstance().getVersionName()).append(" bundle.\n")
.append("Please try to reinstall ").append(ApplicationInfo.getInstance().getVersionName()).toString());
}
ourAdvices.put(-25293, callInfo -> {
if (!SystemInfo.isMac) return null;
final Trinity<String, String, String> trinity = MacParser.macMessages.get(callInfo.getResultCode());
if (trinity == null) return null;
return MessageFormat.format(ourGenericAdvice, callInfo.getFunctionName(),
new StringBuilder().append(callInfo.getResultCode()).append(" ( ").append(trinity.getFirst())
.append(" - ").append(trinity.getSecond()).append(")").append("\nYou are likely to have modified ")
.append(ApplicationInfo.getInstance().getVersionName()).append(" bundle.\n")
.append("Please try to reinstall ").append(ApplicationInfo.getInstance().getVersionName())
.toString());
});
}
@@ -129,12 +129,9 @@ public class SvnRecursiveStatusWalker {
}
public boolean isIgnoredByVcs(@NotNull final VirtualFile vFile) {
return ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
@Override
public Boolean compute() {
if (myVcs.getProject().isDisposed()) throw new ProcessCanceledException();
return myVcsManager.isIgnored(vFile);
}
return ApplicationManager.getApplication().runReadAction((Computable<Boolean>)() -> {
if (myVcs.getProject().isDisposed()) throw new ProcessCanceledException();
return myVcsManager.isIgnored(vFile);
});
}
@@ -204,48 +201,33 @@ public class SvnRecursiveStatusWalker {
final Processor<File> processor;
final Processor<File> directoryFilter;
final Ref<File> lastIgnored = new Ref<>();
final Processor<File> checkDirProcessor = new Processor<File>() {
@Override
public boolean process(File file) {
FilePath path = VcsUtil.getFilePath(file, true);
VirtualFile vf = VfsUtil.findFileByIoFile(file, true);
if (vf != null && isIgnoredIdeaLevel(vf)) {
lastIgnored.set(file);
myReceiver.processIgnored(vf);
}
else if (file.isDirectory() && new File(file, SVNFileUtil.getAdminDirectoryName()).exists()) {
myQueue.add(createItem(path, newDepth, true));
}
else if (vf != null) {
myReceiver.processUnversioned(vf);
}
return true;
final Processor<File> checkDirProcessor = file -> {
FilePath path = VcsUtil.getFilePath(file, true);
VirtualFile vf = VfsUtil.findFileByIoFile(file, true);
if (vf != null && isIgnoredIdeaLevel(vf)) {
lastIgnored.set(file);
myReceiver.processIgnored(vf);
}
else if (file.isDirectory() && new File(file, SVNFileUtil.getAdminDirectoryName()).exists()) {
myQueue.add(createItem(path, newDepth, true));
}
else if (vf != null) {
myReceiver.processUnversioned(vf);
}
return true;
};
if (Depth.EMPTY.equals(newDepth)) {
// just process immediate children - so only root directory itself should satisfy filter
directoryFilter = new Processor<File>() {
@Override
public boolean process(File file) {
return FileUtil.filesEqual(ioFile, file);
}
};
processor = new Processor<File>() {
@Override
public boolean process(File file) {
// TODO: check if we should still call checkDirProcessor() here - or we really could not check ignore settings but just call
// TODO: myReceiver.processUnversioned() for all immediate children
// here we deal only with immediate children - so ignored on IDEA level for children is not important
return FileUtil.filesEqual(ioFile, file) || checkDirProcessor.process(file);
}
directoryFilter = file -> FileUtil.filesEqual(ioFile, file);
processor = file -> {
// TODO: check if we should still call checkDirProcessor() here - or we really could not check ignore settings but just call
// TODO: myReceiver.processUnversioned() for all immediate children
// here we deal only with immediate children - so ignored on IDEA level for children is not important
return FileUtil.filesEqual(ioFile, file) || checkDirProcessor.process(file);
};
} else {
directoryFilter = new Processor<File>() {
@Override
public boolean process(File file) {
return ! Comparing.equal(lastIgnored, file) && (myQueue.isEmpty() || ! FileUtil.filesEqual(myQueue.getLast().getPath().getIOFile(), file));
}
};
directoryFilter = file -> !Comparing.equal(lastIgnored, file) &&
(myQueue.isEmpty() || !FileUtil.filesEqual(myQueue.getLast().getPath().getIOFile(), file));
processor = checkDirProcessor;
}
FileUtil.processFilesRecursively(ioFile, processor, directoryFilter);
@@ -16,17 +16,13 @@
package org.jetbrains.idea.svn;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vcs.ObjectsConvertor;
import com.intellij.openapi.vcs.changes.ChangeListManager;
import com.intellij.openapi.vcs.changes.InvokeAfterUpdateMode;
import com.intellij.openapi.vcs.changes.VcsDirtyScopeManager;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.Consumer;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.Convertor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.idea.svn.status.Status;
@@ -94,11 +90,7 @@ public class SvnRootsDetector {
}
private void addNestedRoots(final boolean clearState, final Runnable callback) {
final List<VirtualFile> basicVfRoots = ObjectsConvertor.convert(myResult.myTopRoots, new Convertor<RootUrlInfo, VirtualFile>() {
public VirtualFile convert(final RootUrlInfo real) {
return real.getVirtualFile();
}
});
final List<VirtualFile> basicVfRoots = ObjectsConvertor.convert(myResult.myTopRoots, real -> real.getVirtualFile());
final ChangeListManager clManager = ChangeListManager.getInstance(myVcs.getProject());
@@ -106,38 +98,34 @@ public class SvnRootsDetector {
// clear what was reported before (could be for currently-not-existing roots)
myNestedCopiesHolder.getAndClear();
}
clManager.invokeAfterUpdate(new Runnable() {
public void run() {
final List<RootUrlInfo> nestedRoots = new ArrayList<>();
clManager.invokeAfterUpdate(() -> {
final List<RootUrlInfo> nestedRoots = new ArrayList<>();
for (NestedCopyInfo info : myNestedCopiesHolder.getAndClear()) {
if (NestedCopyType.external.equals(info.getType()) || NestedCopyType.switched.equals(info.getType())) {
RootUrlInfo topRoot = findTopRoot(VfsUtilCore.virtualToIoFile(info.getFile()));
for (NestedCopyInfo info : myNestedCopiesHolder.getAndClear()) {
if (NestedCopyType.external.equals(info.getType()) || NestedCopyType.switched.equals(info.getType())) {
RootUrlInfo topRoot = findTopRoot(VfsUtilCore.virtualToIoFile(info.getFile()));
if (topRoot != null) {
// TODO: Seems that type is not set in ForNestedRootChecker as we could not determine it for sure. Probably, for the case
// TODO: (or some other cases) when vcs root from settings belongs is in externals of some other working copy upper
// TODO: the tree (I did not check this). Leave this setter for now.
topRoot.setType(info.getType());
continue;
}
if (!refreshPointInfo(info)) {
continue;
}
if (topRoot != null) {
// TODO: Seems that type is not set in ForNestedRootChecker as we could not determine it for sure. Probably, for the case
// TODO: (or some other cases) when vcs root from settings belongs is in externals of some other working copy upper
// TODO: the tree (I did not check this). Leave this setter for now.
topRoot.setType(info.getType());
continue;
}
if (!refreshPointInfo(info)) {
continue;
}
registerRootUrlFromNestedPoint(info, nestedRoots);
}
myResult.myTopRoots.addAll(nestedRoots);
myMapping.applyDetectionResult(myResult);
callback.run();
registerRootUrlFromNestedPoint(info, nestedRoots);
}
}, InvokeAfterUpdateMode.SILENT_CALLBACK_POOLED, null, new Consumer<VcsDirtyScopeManager>() {
public void consume(VcsDirtyScopeManager vcsDirtyScopeManager) {
if (clearState) {
vcsDirtyScopeManager.filesDirty(null, basicVfRoots);
}
myResult.myTopRoots.addAll(nestedRoots);
myMapping.applyDetectionResult(myResult);
callback.run();
}, InvokeAfterUpdateMode.SILENT_CALLBACK_POOLED, null, vcsDirtyScopeManager -> {
if (clearState) {
vcsDirtyScopeManager.filesDirty(null, basicVfRoots);
}
}, null);
}
@@ -185,22 +173,12 @@ public class SvnRootsDetector {
@Nullable
private RootUrlInfo findTopRoot(@NotNull final File file) {
return ContainerUtil.find(myResult.myTopRoots, new Condition<RootUrlInfo>() {
@Override
public boolean value(RootUrlInfo topRoot) {
return FileUtil.filesEqual(topRoot.getIoFile(), file);
}
});
return ContainerUtil.find(myResult.myTopRoots, topRoot -> FileUtil.filesEqual(topRoot.getIoFile(), file));
}
@Nullable
private RootUrlInfo findAncestorTopRoot(@NotNull final VirtualFile file) {
return ContainerUtil.find(myResult.myTopRoots, new Condition<RootUrlInfo>() {
@Override
public boolean value(RootUrlInfo topRoot) {
return VfsUtilCore.isAncestor(topRoot.getVirtualFile(), file, true);
}
});
return ContainerUtil.find(myResult.myTopRoots, topRoot -> VfsUtilCore.isAncestor(topRoot.getVirtualFile(), file, true));
}
private static class RepositoryRoots {
@@ -41,7 +41,6 @@ import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.openapi.wm.impl.status.StatusBarUtil;
import com.intellij.util.ArrayUtil;
import com.intellij.util.NotNullFunction;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.Convertor;
import com.intellij.util.containers.MultiMap;
@@ -55,7 +54,6 @@ import org.jetbrains.idea.svn.api.ProgressEvent;
import org.jetbrains.idea.svn.api.ProgressTracker;
import org.jetbrains.idea.svn.branchConfig.SvnBranchConfigurationManager;
import org.jetbrains.idea.svn.branchConfig.SvnBranchConfigurationNew;
import org.jetbrains.idea.svn.browse.DirectoryEntry;
import org.jetbrains.idea.svn.browse.DirectoryEntryConsumer;
import org.jetbrains.idea.svn.commandLine.SvnBindException;
import org.jetbrains.idea.svn.dialogs.LockDialog;
@@ -67,7 +65,6 @@ import org.tmatesoft.sqljet.core.internal.table.ISqlJetBtreeSchemaTable;
import org.tmatesoft.sqljet.core.internal.table.SqlJetBtreeSchemaTable;
import org.tmatesoft.sqljet.core.table.ISqlJetOptions;
import org.tmatesoft.sqljet.core.table.SqlJetDb;
import org.tmatesoft.sqljet.core.table.engine.ISqlJetEngineSynchronized;
import org.tmatesoft.sqljet.core.table.engine.SqlJetEngine;
import org.tmatesoft.svn.core.SVNErrorCode;
import org.tmatesoft.svn.core.SVNErrorMessage;
@@ -224,27 +221,25 @@ public class SvnUtil {
}
};
Runnable command = new Runnable() {
public void run() {
ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
Runnable command = () -> {
ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
try {
try {
if (progress != null) {
progress.setText(SvnBundle.message("progress.text.locking.files"));
}
for (File ioFile : ioFiles) {
if (progress != null) {
progress.setText(SvnBundle.message("progress.text.locking.files"));
progress.checkCanceled();
}
for (File ioFile : ioFiles) {
if (progress != null) {
progress.checkCanceled();
}
if (progress != null) {
progress.setText2(SvnBundle.message("progress.text2.processing.file", ioFile.getName()));
}
activeVcs.getFactory(ioFile).createLockClient().lock(ioFile, force, lockMessage, eventHandler);
if (progress != null) {
progress.setText2(SvnBundle.message("progress.text2.processing.file", ioFile.getName()));
}
activeVcs.getFactory(ioFile).createLockClient().lock(ioFile, force, lockMessage, eventHandler);
}
catch (VcsException e) {
exception[0] = e;
}
}
catch (VcsException e) {
exception[0] = e;
}
};
@@ -289,27 +284,25 @@ public class SvnUtil {
}
};
Runnable command = new Runnable() {
public void run() {
ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
Runnable command = () -> {
ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
try {
try {
if (progress != null) {
progress.setText(SvnBundle.message("progress.text.unlocking.files"));
}
for (File ioFile : ioFiles) {
if (progress != null) {
progress.setText(SvnBundle.message("progress.text.unlocking.files"));
progress.checkCanceled();
}
for (File ioFile : ioFiles) {
if (progress != null) {
progress.checkCanceled();
}
if (progress != null) {
progress.setText2(SvnBundle.message("progress.text2.processing.file", ioFile.getName()));
}
activeVcs.getFactory(ioFile).createLockClient().unlock(ioFile, force, eventHandler);
if (progress != null) {
progress.setText2(SvnBundle.message("progress.text2.processing.file", ioFile.getName()));
}
activeVcs.getFactory(ioFile).createLockClient().unlock(ioFile, force, eventHandler);
}
catch (VcsException e) {
exception[0] = e;
}
}
catch (VcsException e) {
exception[0] = e;
}
};
@@ -332,26 +325,17 @@ public class SvnUtil {
@NotNull
public static MultiMap<Pair<SVNURL, WorkingCopyFormat>, Change> splitChangesIntoWc(@NotNull SvnVcs vcs, @NotNull List<Change> changes) {
return splitIntoRepositoriesMap(vcs, changes, new Convertor<Change, FilePath>() {
@Override
public FilePath convert(@NotNull Change change) {
return ChangesUtil.getFilePath(change);
}
});
return splitIntoRepositoriesMap(vcs, changes, change -> ChangesUtil.getFilePath(change));
}
@NotNull
public static <T> MultiMap<Pair<SVNURL, WorkingCopyFormat>, T> splitIntoRepositoriesMap(@NotNull final SvnVcs vcs,
@NotNull Collection<T> items,
@NotNull final Convertor<T, FilePath> converter) {
return ContainerUtil.groupBy(items, new NotNullFunction<T, Pair<SVNURL, WorkingCopyFormat>>() {
@NotNull
@Override
public Pair<SVNURL, WorkingCopyFormat> fun(@NotNull T item) {
RootUrlInfo path = vcs.getSvnFileUrlMapping().getWcRootForFilePath(converter.convert(item).getIOFile());
return ContainerUtil.groupBy(items, item -> {
RootUrlInfo path = vcs.getSvnFileUrlMapping().getWcRootForFilePath(converter.convert(item).getIOFile());
return path == null ? UNKNOWN_REPOSITORY_AND_FORMAT : Pair.create(path.getRepositoryUrlUrl(), path.getFormat());
}
return path == null ? UNKNOWN_REPOSITORY_AND_FORMAT : Pair.create(path.getRepositoryUrlUrl(), path.getFormat());
});
}
@@ -487,12 +471,8 @@ public class SvnUtil {
public static VirtualFile getVirtualFile(final String filePath) {
@NonNls final String path = VfsUtilCore.pathToUrl(filePath.replace(File.separatorChar, '/'));
return ApplicationManager.getApplication().runReadAction(new Computable<VirtualFile>() {
@Nullable
public VirtualFile compute() {
return VirtualFileManager.getInstance().findFileByUrl(path);
}
});
return ApplicationManager.getApplication()
.runReadAction((Computable<VirtualFile>)() -> VirtualFileManager.getInstance().findFileByUrl(path));
}
@Nullable
@@ -597,13 +577,9 @@ public class SvnUtil {
public static boolean remoteFolderIsEmpty(@NotNull SvnVcs vcs, @NotNull String url) throws VcsException {
SvnTarget target = SvnTarget.fromURL(createUrl(url));
Ref<Boolean> result = new Ref<>(true);
DirectoryEntryConsumer handler = new DirectoryEntryConsumer() {
@Override
public void consume(final DirectoryEntry entry) throws SVNException {
if (entry != null) {
result.set(false);
}
DirectoryEntryConsumer handler = entry -> {
if (entry != null) {
result.set(false);
}
};
@@ -990,15 +966,13 @@ public class SvnUtil {
String result = "";
try {
result = (String)runSynchronized(new ISqlJetEngineSynchronized() {
public Object runSynchronized(SqlJetEngine engine) throws SqlJetException {
btree.enter();
try {
return readDbSchema();
}
finally {
btree.leave();
}
result = (String)runSynchronized(engine -> {
btree.enter();
try {
return readDbSchema();
}
finally {
btree.leave();
}
});
}
@@ -185,12 +185,7 @@ public class SvnVcs extends AbstractVcs<CommittedChangeList> {
myChangeListListener = new SvnChangelistListener(this);
myVcsListener = new VcsListener() {
@Override
public void directoryMappingChanged() {
invokeRefreshSvnRoots();
}
};
myVcsListener = () -> invokeRefreshSvnRoots();
}
myFrameStateListener = project.isDefault() ? null : new MyFrameStateListener(ChangeListManager.getInstance(project),
@@ -205,12 +200,9 @@ public class SvnVcs extends AbstractVcs<CommittedChangeList> {
if (myProject.isDefault()) return;
myCopiesRefreshManager = new SvnCopiesRefreshManager((SvnFileUrlMappingImpl)getSvnFileUrlMapping());
if (!myConfiguration.isCleanupRun()) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
cleanup17copies();
myConfiguration.setCleanupRun(true);
}
ApplicationManager.getApplication().invokeLater(() -> {
cleanup17copies();
myConfiguration.setCleanupRun(true);
}, ModalityState.NON_MODAL, myProject.getDisposed());
}
else {
@@ -261,26 +253,23 @@ public class SvnVcs extends AbstractVcs<CommittedChangeList> {
private void upgradeIfNeeded(final MessageBus bus) {
final MessageBusConnection connection = bus.connect();
connection.subscribe(ChangeListManagerImpl.LISTS_LOADED, new LocalChangeListsLoadedListener() {
@Override
public void processLoadedLists(final List<LocalChangeList> lists) {
if (lists.isEmpty()) return;
try {
ChangeListManager.getInstance(myProject).setReadOnly(LocalChangeList.DEFAULT_NAME, true);
connection.subscribe(ChangeListManagerImpl.LISTS_LOADED, lists -> {
if (lists.isEmpty()) return;
try {
ChangeListManager.getInstance(myProject).setReadOnly(LocalChangeList.DEFAULT_NAME, true);
if (!myConfiguration.changeListsSynchronized()) {
processChangeLists(lists);
}
if (!myConfiguration.changeListsSynchronized()) {
processChangeLists(lists);
}
catch (ProcessCanceledException e) {
//
}
finally {
myConfiguration.upgrade();
}
connection.disconnect();
}
catch (ProcessCanceledException e) {
//
}
finally {
myConfiguration.upgrade();
}
connection.disconnect();
});
}
@@ -301,12 +290,7 @@ public class SvnVcs extends AbstractVcs<CommittedChangeList> {
finally {
final Application appManager = ApplicationManager.getApplication();
if (appManager.isDispatchThread()) {
appManager.executeOnPooledThread(new Runnable() {
@Override
public void run() {
plVcsManager.stopBackgroundVcsOperation();
}
});
appManager.executeOnPooledThread(() -> plVcsManager.stopBackgroundVcsOperation());
}
else {
plVcsManager.stopBackgroundVcsOperation();
@@ -356,24 +340,21 @@ public class SvnVcs extends AbstractVcs<CommittedChangeList> {
}
// do one time after project loaded
StartupManager.getInstance(myProject).runWhenProjectIsInitialized(new DumbAwareRunnable() {
@Override
public void run() {
postStartup();
StartupManager.getInstance(myProject).runWhenProjectIsInitialized((DumbAwareRunnable)() -> {
postStartup();
// for IDEA, it takes 2 minutes - and anyway this can be done in background, no sense...
// once it could be mistaken about copies for 2 minutes on start...
// for IDEA, it takes 2 minutes - and anyway this can be done in background, no sense...
// once it could be mistaken about copies for 2 minutes on start...
/*if (! myMapping.getAllWcInfos().isEmpty()) {
invokeRefreshSvnRoots();
return;
}
ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
public void run() {
myCopiesRefreshManager.getCopiesRefresh().ensureInit();
}
}, SvnBundle.message("refreshing.working.copies.roots.progress.text"), true, myProject);*/
/*if (! myMapping.getAllWcInfos().isEmpty()) {
invokeRefreshSvnRoots();
return;
}
ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
public void run() {
myCopiesRefreshManager.getCopiesRefresh().ensureInit();
}
}, SvnBundle.message("refreshing.working.copies.roots.progress.text"), true, myProject);*/
});
myProject.getMessageBus().connect().subscribe(ProjectLevelVcsManager.VCS_CONFIGURATION_CHANGED, myRootsToWorkingCopies);
@@ -818,12 +799,7 @@ public class SvnVcs extends AbstractVcs<CommittedChangeList> {
infos.add(new MyPair<>(vf, url.toString(), s));
}
final List<MyPair<S>> filtered = new UniqueRootsFilter().filter(infos);
final List<S> converted = ObjectsConvertor.convert(filtered, new Convertor<MyPair<S>, S>() {
@Override
public S convert(final MyPair<S> o) {
return o.getSrc();
}
});
final List<S> converted = ObjectsConvertor.convert(filtered, o -> o.getSrc());
if (!notMatched.isEmpty()) {
// potential bug is here: order is not kept. but seems it only occurs for cases where result is sorted after filtering so ok
converted.addAll(notMatched);
@@ -917,10 +893,10 @@ public class SvnVcs extends AbstractVcs<CommittedChangeList> {
/**
* Detects appropriate client factory based on project root directory working copy format.
*
* <p>
* Try to avoid usages of this method (for now) as it could not correctly for all cases
* detect svn 1.8 working copy format to guarantee command line client.
*
* <p>
* For instance, when working copies of several formats are presented in project
* (though it seems to be rather unlikely case).
*
@@ -15,7 +15,6 @@
*/
package org.jetbrains.idea.svn;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
@@ -24,7 +23,6 @@ import org.tmatesoft.svn.core.internal.util.SVNPathUtil;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
/**
@@ -46,20 +44,11 @@ public class UniqueRootsFilter {
}
private static <T extends RootUrlPair> void sort(List<T> list) {
Collections.sort(list, new Comparator<RootUrlPair>() {
public int compare(final RootUrlPair o1, final RootUrlPair o2) {
return o1.getVirtualFile().getPath().compareTo(o2.getVirtualFile().getPath());
}
});
Collections.sort(list, (o1, o2) -> o1.getVirtualFile().getPath().compareTo(o2.getVirtualFile().getPath()));
}
private static <T extends RootUrlPair> boolean alreadyRegistered(@NotNull final T child, @NotNull List<T> registered) {
return ContainerUtil.exists(registered, new Condition<T>() {
@Override
public boolean value(T parent) {
return isSamePath(child, parent) || isSameSupposedUrl(child, parent);
}
});
return ContainerUtil.exists(registered, parent -> isSamePath(child, parent) || isSameSupposedUrl(child, parent));
}
private static <T extends RootUrlPair> boolean isSamePath(@NotNull T child, @NotNull T parent) {
@@ -27,7 +27,6 @@ import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.AbstractVcsHelper;
import com.intellij.openapi.vcs.ProjectLevelVcsManager;
import com.intellij.openapi.vcs.TransactionRunnable;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vcs.changes.VcsDirtyScopeManager;
import com.intellij.openapi.vfs.VirtualFile;
@@ -59,24 +58,22 @@ public abstract class BasicAction extends AnAction implements DumbAware {
AbstractVcsHelper helper = AbstractVcsHelper.getInstance(project);
try {
List<VcsException> exceptions = helper.runTransactionRunnable(vcs, new TransactionRunnable() {
public void run(List<VcsException> exceptions) {
VirtualFile badFile = null;
try {
if (isBatchAction()) {
batchExecute(vcs, files, e.getDataContext());
}
else {
for (VirtualFile file : files) {
badFile = file;
execute(vcs, file, e.getDataContext());
}
List<VcsException> exceptions = helper.runTransactionRunnable(vcs, exceptionList -> {
VirtualFile badFile = null;
try {
if (isBatchAction()) {
batchExecute(vcs, files, e.getDataContext());
}
else {
for (VirtualFile file : files) {
badFile = file;
execute(vcs, file, e.getDataContext());
}
}
catch (VcsException ex) {
ex.setVirtualFile(badFile);
exceptions.add(ex);
}
}
catch (VcsException ex) {
ex.setVirtualFile(badFile);
exceptionList.add(ex);
}
}, null);
@@ -32,11 +32,7 @@ public class ExclusiveBackgroundVcsAction {
} finally {
final Application application = ApplicationManager.getApplication();
if (application.isDispatchThread()) {
application.executeOnPooledThread(new Runnable() {
public void run() {
plVcsManager.stopBackgroundVcsOperation();
}
});
application.executeOnPooledThread(() -> plVcsManager.stopBackgroundVcsOperation());
} else {
plVcsManager.stopBackgroundVcsOperation();
}
@@ -35,9 +35,7 @@ import org.jetbrains.idea.svn.api.Depth;
import org.jetbrains.idea.svn.commandLine.SvnBindException;
import org.jetbrains.idea.svn.conflict.ConflictClient;
import org.jetbrains.idea.svn.dialogs.SelectFilesDialog;
import org.jetbrains.idea.svn.status.Status;
import org.jetbrains.idea.svn.status.StatusClient;
import org.jetbrains.idea.svn.status.StatusConsumer;
import org.jetbrains.idea.svn.status.StatusType;
import org.tmatesoft.svn.core.wc.SVNRevision;
@@ -127,13 +125,10 @@ public class MarkResolvedAction extends BasicAction {
File path = VfsUtilCore.virtualToIoFile(file);
StatusClient client = vcs.getFactory(path).createStatusClient();
client.doStatus(path, SVNRevision.UNDEFINED, Depth.INFINITY, false, false, false, false, new StatusConsumer() {
@Override
public void consume(@NotNull Status status) {
if (status.getContentsStatus() == StatusType.STATUS_CONFLICTED ||
status.getPropertiesStatus() == StatusType.STATUS_CONFLICTED) {
result.add(status.getFile().getAbsolutePath());
}
client.doStatus(path, SVNRevision.UNDEFINED, Depth.INFINITY, false, false, false, false, status -> {
if (status.getContentsStatus() == StatusType.STATUS_CONFLICTED ||
status.getPropertiesStatus() == StatusType.STATUS_CONFLICTED) {
result.add(status.getFile().getAbsolutePath());
}
}, null);
}
@@ -42,7 +42,7 @@ public class ShareWholeProject extends AnAction implements DumbAware {
final Presentation presentation = e.getPresentation();
presentation.setEnabled(checker.isEnabled());
presentation.setVisible(checker.isVisible());
if (checker.isEnabled()) {
presentation.setText(SvnBundle.message("action.share.whole.project.text"));
@@ -73,19 +73,20 @@ public class ShareWholeProject extends AnAction implements DumbAware {
myHadNoMappings = MyCheckResult.notMapped.equals(result);
if (MyCheckResult.notMapped.equals(result)) {
// no change list manager working
if(SvnUtil.seemsLikeVersionedDir(baseDir)) return;
} else if (SvnStatusUtil.isUnderControl(myProject, baseDir)) {
if (SvnUtil.seemsLikeVersionedDir(baseDir)) return;
}
else if (SvnStatusUtil.isUnderControl(myProject, baseDir)) {
return;
}
if ((! myHadNoMappings) && (! SvnVcs.getInstance(myProject).getSvnFileUrlMapping().isEmpty())) {
if ((!myHadNoMappings) && (!SvnVcs.getInstance(myProject).getSvnFileUrlMapping().isEmpty())) {
// there are some versioned dirs under project dir
return;
}
// visible: already checked above
myVisible = true;
myEnabled = (! vcsManager.isBackgroundVcsOperationRunning());
myEnabled = (!vcsManager.isBackgroundVcsOperationRunning());
}
private static enum MyCheckResult {
@@ -137,7 +138,7 @@ public class ShareWholeProject extends AnAction implements DumbAware {
public void actionPerformed(AnActionEvent e) {
final MyChecker checker = new MyChecker();
checker.execute(e);
if (! checker.isEnabled()) return;
if (!checker.isEnabled()) return;
final Project project = checker.getProject();
final VirtualFile baseDir = project.getBaseDir();
@@ -146,26 +147,21 @@ public class ShareWholeProject extends AnAction implements DumbAware {
boolean excThrown = false;
try {
success = ShareProjectAction.share(project, baseDir);
} catch (VcsException exc) {
}
catch (VcsException exc) {
AbstractVcsHelper.getInstance(project).showError(exc, "Failed to Share Project");
excThrown = true;
} finally {
}
finally {
// if success = false -> either action was cancelled or exception was thrown, so also check for exception
if (success || excThrown) {
baseDir.refresh(true, true, new Runnable() {
public void run() {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
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());
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()));
}
}
}
@@ -67,12 +67,7 @@ public class SvnExcludingIgnoredOperation {
}
private boolean isIgnoredByVcs(final VirtualFile file) {
return ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
@Override
public Boolean compute() {
return myVcsManager.isIgnored(file);
}
});
return ApplicationManager.getApplication().runReadAction((Computable<Boolean>)() -> myVcsManager.isIgnored(file));
}
}
@@ -58,53 +58,53 @@ public class SvnMergeProvider implements MergeProvider {
@NotNull
public MergeData loadRevisions(@NotNull final VirtualFile file) throws VcsException {
final MergeData data = new MergeData();
VcsRunnable runnable = new VcsRunnable() {
public void run() throws VcsException {
File oldFile = null;
File newFile = null;
File workingFile = null;
boolean mergeCase = false;
SvnVcs vcs = SvnVcs.getInstance(myProject);
Info info = vcs.getInfo(file);
VcsRunnable runnable = () -> {
File oldFile = null;
File newFile = null;
File workingFile = null;
boolean mergeCase = false;
SvnVcs vcs = SvnVcs.getInstance(myProject);
Info info = vcs.getInfo(file);
if (info != null) {
oldFile = info.getConflictOldFile();
newFile = info.getConflictNewFile();
workingFile = info.getConflictWrkFile();
mergeCase = workingFile == null || workingFile.getName().contains("working");
// for debug
if (workingFile == null) {
LOG.info("Null working file when merging text conflict for " + file.getPath() + " old file: " + oldFile + " new file: " + newFile);
}
if (mergeCase) {
// this is merge case
oldFile = info.getConflictNewFile();
newFile = info.getConflictOldFile();
workingFile = info.getConflictWrkFile();
}
data.LAST_REVISION_NUMBER = new SvnRevisionNumber(info.getRevision());
} else {
throw new VcsException("Could not get info for " + file.getPath());
}
if (oldFile == null || newFile == null || workingFile == null) {
ByteArrayOutputStream bos = getBaseRevisionContents(vcs, file);
data.ORIGINAL = bos.toByteArray();
data.LAST = bos.toByteArray();
data.CURRENT = readFile(new File(file.getPath()));
}
else {
data.ORIGINAL = readFile(oldFile);
data.LAST = readFile(newFile);
data.CURRENT = readFile(workingFile);
if (info != null) {
oldFile = info.getConflictOldFile();
newFile = info.getConflictNewFile();
workingFile = info.getConflictWrkFile();
mergeCase = workingFile == null || workingFile.getName().contains("working");
// for debug
if (workingFile == null) {
LOG
.info("Null working file when merging text conflict for " + file.getPath() + " old file: " + oldFile + " new file: " + newFile);
}
if (mergeCase) {
final ByteArrayOutputStream contents = getBaseRevisionContents(vcs, file);
if (! Arrays.equals(contents.toByteArray(), data.ORIGINAL)) {
// swap base and server: another order of merge arguments
byte[] original = data.ORIGINAL;
data.ORIGINAL = data.LAST;
data.LAST = original;
}
// this is merge case
oldFile = info.getConflictNewFile();
newFile = info.getConflictOldFile();
workingFile = info.getConflictWrkFile();
}
data.LAST_REVISION_NUMBER = new SvnRevisionNumber(info.getRevision());
}
else {
throw new VcsException("Could not get info for " + file.getPath());
}
if (oldFile == null || newFile == null || workingFile == null) {
ByteArrayOutputStream bos = getBaseRevisionContents(vcs, file);
data.ORIGINAL = bos.toByteArray();
data.LAST = bos.toByteArray();
data.CURRENT = readFile(new File(file.getPath()));
}
else {
data.ORIGINAL = readFile(oldFile);
data.LAST = readFile(newFile);
data.CURRENT = readFile(workingFile);
}
if (mergeCase) {
final ByteArrayOutputStream contents = getBaseRevisionContents(vcs, file);
if (!Arrays.equals(contents.toByteArray(), data.ORIGINAL)) {
// swap base and server: another order of merge arguments
byte[] original = data.ORIGINAL;
data.ORIGINAL = data.LAST;
data.LAST = original;
}
}
};
@@ -176,11 +176,7 @@ public abstract class BaseSvnFileAnnotation extends FileAnnotation {
public List<VcsFileRevision> getRevisions() {
final List<VcsFileRevision> result = new ArrayList<>(myRevisionMap.values());
Collections.sort(result, new Comparator<VcsFileRevision>() {
public int compare(final VcsFileRevision o1, final VcsFileRevision o2) {
return o2.getRevisionNumber().compareTo(o1.getRevisionNumber());
}
});
Collections.sort(result, (o1, o2) -> o2.getRevisionNumber().compareTo(o1.getRevisionNumber()));
return result;
}
@@ -35,9 +35,10 @@ import com.intellij.vcsUtil.VcsUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.idea.svn.*;
import org.jetbrains.idea.svn.checkin.CommitInfo;
import org.jetbrains.idea.svn.diff.DiffOptions;
import org.jetbrains.idea.svn.history.*;
import org.jetbrains.idea.svn.history.HistoryClient;
import org.jetbrains.idea.svn.history.SvnChangeList;
import org.jetbrains.idea.svn.history.SvnFileRevision;
import org.jetbrains.idea.svn.info.Info;
import org.tmatesoft.svn.core.SVNErrorCode;
import org.tmatesoft.svn.core.SVNErrorMessage;
@@ -70,8 +71,9 @@ public class SvnAnnotationProvider implements AnnotationProvider, VcsCacheableAn
throw new VcsException("Can not get current revision for file " + file.getPath());
}
final SVNRevision svnRevision = ((SvnRevisionNumber)lastChangedRevision.getRevisionNumber()).getRevision();
if (! svnRevision.isValid()) {
throw new VcsException("Can not get last changed revision for file: " + file.getPath() + "\nPlease run svn info for this file and file an issue.");
if (!svnRevision.isValid()) {
throw new VcsException(
"Can not get last changed revision for file: " + file.getPath() + "\nPlease run svn info for this file and file an issue.");
}
return annotate(file, new SvnFileRevision(myVcs, currentRevision, currentRevision, null, null, null, null, null),
lastChangedRevision.getRevisionNumber(), true);
@@ -89,78 +91,80 @@ public class SvnAnnotationProvider implements AnnotationProvider, VcsCacheableAn
final FileAnnotation[] annotation = new FileAnnotation[1];
final VcsException[] exception = new VcsException[1];
Runnable command = new Runnable() {
public void run() {
final ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
final File ioFile = new File(file.getPath()).getAbsoluteFile();
Info info = null;
try {
Runnable command = () -> {
final ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
final File ioFile = new File(file.getPath()).getAbsoluteFile();
Info info = null;
try {
final String contents;
if (loadExternally) {
byte[] data = SvnUtil.getFileContents(myVcs, SvnTarget.fromFile(ioFile), SVNRevision.BASE, SVNRevision.UNDEFINED);
contents = LoadTextUtil.getTextByBinaryPresentation(data, file, false, false).toString();
} else {
final byte[] bytes = VcsHistoryUtil.loadRevisionContent(revision);
contents = LoadTextUtil.getTextByBinaryPresentation(bytes, file, false, false).toString();
}
final SvnFileAnnotation result = new SvnFileAnnotation(myVcs, file, contents, lastChangedRevision);
info = myVcs.getInfo(ioFile);
if (info == null) {
exception[0] = new VcsException(new SVNException(SVNErrorMessage.create(SVNErrorCode.UNKNOWN, "File ''{0}'' is not under version control", ioFile)));
return;
}
final String url = info.getURL() == null ? null : info.getURL().toString();
SVNRevision endRevision = ((SvnFileRevision) revision).getRevision();
if (SVNRevision.WORKING.equals(endRevision)) {
endRevision = info.getRevision();
}
if (progress != null) {
progress.setText(SvnBundle.message("progress.text.computing.annotation", file.getName()));
}
// ignore mime type=true : IDEA-19562
final AnnotationConsumer annotateHandler = createAnnotationHandler(progress, result);
boolean calculateMergeinfo =
myVcs.getSvnConfiguration().isShowMergeSourcesInAnnotate() && SvnUtil.checkRepositoryVersion15(myVcs, url);
final MySteppedLogGetter logGetter = new MySteppedLogGetter(
myVcs, ioFile, progress,
myVcs.getFactory(ioFile).createHistoryClient(), endRevision, result,
url, calculateMergeinfo, file.getCharset());
logGetter.go();
final LinkedList<SVNRevision> rp = logGetter.getRevisionPoints();
// TODO: only 2 elements will be in rp and for loop will be executed only once - probably rewrite with Pair
AnnotateClient annotateClient = myVcs.getFactory(ioFile).createAnnotateClient();
for (int i = 0; i < rp.size() - 1; i++) {
annotateClient.annotate(SvnTarget.fromFile(ioFile), rp.get(i + 1), rp.get(i), calculateMergeinfo, getLogClientOptions(myVcs),
annotateHandler);
}
if (rp.get(1).getNumber() > 0) {
result.setFirstRevision(rp.get(1));
}
annotation[0] = result;
final String contents;
if (loadExternally) {
byte[] data = SvnUtil.getFileContents(myVcs, SvnTarget.fromFile(ioFile), SVNRevision.BASE, SVNRevision.UNDEFINED);
contents = LoadTextUtil.getTextByBinaryPresentation(data, file, false, false).toString();
}
catch (IOException e) {
exception[0] = new VcsException(e);
} catch (VcsException e) {
if (e.getCause() instanceof SVNException) {
handleSvnException(ioFile, info, (SVNException)e.getCause(), file, revision, annotation, exception);
}
else {
exception[0] = e;
}
else {
final byte[] bytes = VcsHistoryUtil.loadRevisionContent(revision);
contents = LoadTextUtil.getTextByBinaryPresentation(bytes, file, false, false).toString();
}
final SvnFileAnnotation result = new SvnFileAnnotation(myVcs, file, contents, lastChangedRevision);
info = myVcs.getInfo(ioFile);
if (info == null) {
exception[0] = new VcsException(
new SVNException(SVNErrorMessage.create(SVNErrorCode.UNKNOWN, "File ''{0}'' is not under version control", ioFile)));
return;
}
final String url = info.getURL() == null ? null : info.getURL().toString();
SVNRevision endRevision = ((SvnFileRevision)revision).getRevision();
if (SVNRevision.WORKING.equals(endRevision)) {
endRevision = info.getRevision();
}
if (progress != null) {
progress.setText(SvnBundle.message("progress.text.computing.annotation", file.getName()));
}
// ignore mime type=true : IDEA-19562
final AnnotationConsumer annotateHandler = createAnnotationHandler(progress, result);
boolean calculateMergeinfo =
myVcs.getSvnConfiguration().isShowMergeSourcesInAnnotate() && SvnUtil.checkRepositoryVersion15(myVcs, url);
final MySteppedLogGetter logGetter = new MySteppedLogGetter(
myVcs, ioFile, progress,
myVcs.getFactory(ioFile).createHistoryClient(), endRevision, result,
url, calculateMergeinfo, file.getCharset());
logGetter.go();
final LinkedList<SVNRevision> rp = logGetter.getRevisionPoints();
// TODO: only 2 elements will be in rp and for loop will be executed only once - probably rewrite with Pair
AnnotateClient annotateClient = myVcs.getFactory(ioFile).createAnnotateClient();
for (int i = 0; i < rp.size() - 1; i++) {
annotateClient.annotate(SvnTarget.fromFile(ioFile), rp.get(i + 1), rp.get(i), calculateMergeinfo, getLogClientOptions(myVcs),
annotateHandler);
}
if (rp.get(1).getNumber() > 0) {
result.setFirstRevision(rp.get(1));
}
annotation[0] = result;
}
catch (IOException e) {
exception[0] = new VcsException(e);
}
catch (VcsException e) {
if (e.getCause() instanceof SVNException) {
handleSvnException(ioFile, info, (SVNException)e.getCause(), file, revision, annotation, exception);
}
else {
exception[0] = e;
}
}
};
if (ApplicationManager.getApplication().isDispatchThread()) {
ProgressManager.getInstance().runProcessWithProgressSynchronously(command, SvnBundle.message("action.text.annotate"), false, myVcs.getProject());
ProgressManager.getInstance()
.runProcessWithProgressSynchronously(command, SvnBundle.message("action.text.annotate"), false, myVcs.getProject());
}
else {
command.run();
@@ -179,10 +183,10 @@ public class SvnAnnotationProvider implements AnnotationProvider, VcsCacheableAn
FileAnnotation[] annotation, VcsException[] exception) {
// TODO: Check how this scenario could be reproduced by user and what changes needs to be done for command line client
if (SVNErrorCode.FS_NOT_FOUND.equals(e.getErrorMessage().getErrorCode())) {
final CommittedChangesProvider<SvnChangeList,ChangeBrowserSettings> provider = myVcs.getCommittedChangesProvider();
final CommittedChangesProvider<SvnChangeList, ChangeBrowserSettings> provider = myVcs.getCommittedChangesProvider();
try {
final Pair<SvnChangeList, FilePath> pair = provider.getOneList(file, revision.getRevisionNumber());
if (pair != null && info != null && pair.getSecond() != null && ! Comparing.equal(pair.getSecond().getIOFile(), ioFile)) {
if (pair != null && info != null && pair.getSecond() != null && !Comparing.equal(pair.getSecond().getIOFile(), ioFile)) {
annotation[0] = annotateNonExisting(pair, revision, info, file.getCharset(), file);
return;
}
@@ -205,19 +209,21 @@ public class SvnAnnotationProvider implements AnnotationProvider, VcsCacheableAn
final List<String> parts2 = StringUtil.split(can2.getPath(), File.separator, true);
int cnt = 0;
while (parts1.size() > cnt && parts2.size() > cnt) {
if (! parts1.get(cnt).equals(parts2.get(cnt))) {
if (!parts1.get(cnt).equals(parts2.get(cnt))) {
if (cnt > 0) {
return new File(StringUtil.join(parts1.subList(0, cnt), File.separator));
} else {
}
else {
return null;
}
}
++ cnt;
++cnt;
}
//shorter one
if (parts1.size() > parts2.size()) {
return file2;
} else {
}
else {
return file1;
}
}
@@ -225,28 +231,34 @@ public class SvnAnnotationProvider implements AnnotationProvider, VcsCacheableAn
private SvnRemoteFileAnnotation annotateNonExisting(Pair<SvnChangeList, FilePath> pair,
VcsFileRevision revision,
Info info,
Charset charset, final VirtualFile current) throws VcsException, SVNException, IOException {
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());
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());
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());
throw new VcsException("Can not find relative path for " + wasFile.getPath() + "@" + revision.getRevisionNumber().asString());
}
SVNURL wasUrl = wcRootInfo.getURL();
final String[] strings = relativePath.replace('\\','/').split("/");
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 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);
@@ -262,23 +274,19 @@ public class SvnAnnotationProvider implements AnnotationProvider, VcsCacheableAn
@NotNull
private static AnnotationConsumer createAnnotationHandler(@Nullable final ProgressIndicator progress,
@NotNull final BaseSvnFileAnnotation result) {
return new AnnotationConsumer() {
@Override
public void consume(int lineNumber, @NotNull CommitInfo info, @Nullable CommitInfo mergeInfo) throws SVNException {
if (progress != null) {
progress.checkCanceled();
}
result.setLineInfo(lineNumber, info, mergeInfo != null && info.getRevision() > mergeInfo.getRevision() ? mergeInfo : null);
return (lineNumber, info, mergeInfo) -> {
if (progress != null) {
progress.checkCanceled();
}
result.setLineInfo(lineNumber, info, mergeInfo != null && info.getRevision() > mergeInfo.getRevision() ? mergeInfo : null);
};
}
@Override
public VcsAnnotation createCacheable(FileAnnotation fileAnnotation) {
if (! (fileAnnotation instanceof SvnFileAnnotation)) return null;
final SvnFileAnnotation svnFileAnnotation = (SvnFileAnnotation) fileAnnotation;
if (!(fileAnnotation instanceof SvnFileAnnotation)) return null;
final SvnFileAnnotation svnFileAnnotation = (SvnFileAnnotation)fileAnnotation;
final AnnotationSourceSwitcher annotationSourceSwitcher = svnFileAnnotation.getAnnotationSourceSwitcher();
if (annotationSourceSwitcher != null) {
annotationSourceSwitcher.switchTo(AnnotationSource.LOCAL);
@@ -288,7 +296,7 @@ public class SvnAnnotationProvider implements AnnotationProvider, VcsCacheableAn
final VcsUsualLineAnnotationData lineAnnotationData = new VcsUsualLineAnnotationData(size);
for (int i = 0; i < size; i++) {
final VcsRevisionNumber revisionNumber = svnFileAnnotation.getLineRevisionNumber(i);
lineAnnotationData.put(i, revisionNumber);
lineAnnotationData.put(i, revisionNumber);
}
final VcsAnnotation vcsAnnotation = new VcsAnnotation(VcsUtil.getFilePath(svnFileAnnotation.getFile()), lineAnnotationData,
@@ -304,10 +312,10 @@ public class SvnAnnotationProvider implements AnnotationProvider, VcsCacheableAn
final VcsRevisionNumber number = svnFileAnnotation.getLineRevisionNumber(i);
if (number == null) continue;
merged.put(i, number);
addMap.put(number, svnFileAnnotation.getRevision(((SvnRevisionNumber) number).getRevision().getNumber()));
addMap.put(number, svnFileAnnotation.getRevision(((SvnRevisionNumber)number).getRevision().getNumber()));
}
}
if (! merged.isEmpty()) {
if (!merged.isEmpty()) {
vcsAnnotation.addAnnotation(MERGED_KEY, merged);
vcsAnnotation.addCachedOtherRevisions(addMap);
}
@@ -326,7 +334,7 @@ public class SvnAnnotationProvider implements AnnotationProvider, VcsCacheableAn
new SvnFileAnnotation(myVcs, vcsAnnotation.getFilePath().getVirtualFile(), annotatedContent, revisionNumber);
final VcsLineAnnotationData basicAnnotation = vcsAnnotation.getBasicAnnotation();
final VcsLineAnnotationData data = vcsAnnotation.getAdditionalAnnotations().get(MERGED_KEY);
final Map<VcsRevisionNumber,VcsFileRevision> historyAsMap = session.getHistoryAsMap();
final Map<VcsRevisionNumber, VcsFileRevision> historyAsMap = session.getHistoryAsMap();
final Map<VcsRevisionNumber, VcsFileRevision> cachedOtherRevisions = vcsAnnotation.getCachedOtherRevisions();
for (int i = 0; i < basicAnnotation.getNumLines(); i++) {
@@ -337,17 +345,18 @@ public class SvnAnnotationProvider implements AnnotationProvider, VcsCacheableAn
if (mergedData == null) {
annotation.setLineInfo(i, fileRevision.getCommitInfo(), null);
} else {
}
else {
final SvnFileRevision mergedRevision = (SvnFileRevision)cachedOtherRevisions.get(mergedData);
if (mergedRevision == null) return null;
annotation.setLineInfo(i, fileRevision.getCommitInfo(), mergedRevision.getCommitInfo());
}
}
if (vcsAnnotation.getFirstRevision() != null) {
annotation.setFirstRevision(((SvnRevisionNumber) vcsAnnotation.getFirstRevision()).getRevision());
annotation.setFirstRevision(((SvnRevisionNumber)vcsAnnotation.getFirstRevision()).getRevision());
}
for (VcsFileRevision revision : session.getRevisionList()) {
annotation.setRevision(((SvnRevisionNumber) revision.getRevisionNumber()).getRevision().getNumber(), (SvnFileRevision)revision);
annotation.setRevision(((SvnRevisionNumber)revision.getRevisionNumber()).getRevision().getNumber(), (SvnFileRevision)revision);
}
return annotation;
}
@@ -387,16 +396,18 @@ public class SvnAnnotationProvider implements AnnotationProvider, VcsCacheableAn
boolean longHistory = true;
if (maxAnnotateRevisions == -1) {
longHistory = false;
} else {
}
else {
if (myEndRevision.getNumber() < maxAnnotateRevisions) {
longHistory = false;
}
}
if (! longHistory) {
if (!longHistory) {
doLog(myCalculateMergeinfo, null, 0);
putDefaultBounds();
} else {
}
else {
doLog(false, null, 0);
final List<VcsFileRevision> fileRevisionList = myResult.getRevisions();
if (fileRevisionList.size() < maxAnnotateRevisions) {
@@ -407,7 +418,7 @@ public class SvnAnnotationProvider implements AnnotationProvider, VcsCacheableAn
return;
}
myRevisionPoints.add(((SvnRevisionNumber) fileRevisionList.get(0).getRevisionNumber()).getRevision());
myRevisionPoints.add(((SvnRevisionNumber)fileRevisionList.get(0).getRevisionNumber()).getRevision());
final SVNRevision truncateTo =
((SvnRevisionNumber)fileRevisionList.get(maxAnnotateRevisions - 1).getRevisionNumber()).getRevision();
myRevisionPoints.add(truncateTo);
@@ -427,19 +438,17 @@ public class SvnAnnotationProvider implements AnnotationProvider, VcsCacheableAn
private void doLog(final boolean includeMerged, final SVNRevision truncateTo, final int max) throws VcsException {
myClient.doLog(SvnTarget.fromFile(myIoFile), myEndRevision, truncateTo == null ? SVNRevision.create(1L) : truncateTo,
false, false, includeMerged, max, null,
new LogEntryConsumer() {
@Override
public void consume(LogEntry logEntry) {
if (SVNRevision.UNDEFINED.getNumber() == logEntry.getRevision()) {
return;
}
if (myProgress != null) {
myProgress.checkCanceled();
myProgress.setText2(SvnBundle.message("progress.text2.revision.processed", logEntry.getRevision()));
}
myResult.setRevision(logEntry.getRevision(), new SvnFileRevision(myVcs, SVNRevision.UNDEFINED, logEntry, myUrl, ""));
logEntry -> {
if (SVNRevision.UNDEFINED.getNumber() == logEntry.getRevision()) {
return;
}
if (myProgress != null) {
myProgress.checkCanceled();
myProgress.setText2(SvnBundle.message("progress.text2.revision.processed", logEntry.getRevision()));
}
myResult
.setRevision(logEntry.getRevision(), new SvnFileRevision(myVcs, SVNRevision.UNDEFINED, logEntry, myUrl, ""));
});
}
@@ -105,13 +105,8 @@ public class AuthenticationService {
if (repositoryUrl != null) {
final String realm = repositoryUrl.toDecodedString();
authentication = requestCredentials(realm, type, new Getter<SVNAuthentication>() {
@Override
public SVNAuthentication get() {
return myConfiguration.getInteractiveManager(myVcs).getInnerProvider()
.requestClientAuthentication(type, repositoryUrl, realm, null, null, true);
}
});
authentication = requestCredentials(realm, type, () -> myConfiguration.getInteractiveManager(myVcs).getInnerProvider()
.requestClientAuthentication(type, repositoryUrl, realm, null, null, true));
}
if (authentication == null) {
@@ -154,30 +149,25 @@ public class AuthenticationService {
public String requestSshCredentials(@NotNull final String realm,
@NotNull final SimpleCredentialsDialog.Mode mode,
@NotNull final String key) {
return requestCredentials(realm, StringUtil.toLowerCase(mode.toString()), new Getter<String>() {
@Override
public String get() {
final Ref<String> answer = new Ref<>();
return requestCredentials(realm, StringUtil.toLowerCase(mode.toString()), () -> {
final Ref<String> answer = new Ref<>();
Runnable command = new Runnable() {
public void run() {
SimpleCredentialsDialog dialog = new SimpleCredentialsDialog(myVcs.getProject());
Runnable command = () -> {
SimpleCredentialsDialog dialog = new SimpleCredentialsDialog(myVcs.getProject());
dialog.setup(mode, realm, key, true);
dialog.setTitle(SvnBundle.message("dialog.title.authentication.required"));
dialog.setSaveEnabled(false);
if (dialog.showAndGet()) {
answer.set(dialog.getPassword());
}
}
};
dialog.setup(mode, realm, key, true);
dialog.setTitle(SvnBundle.message("dialog.title.authentication.required"));
dialog.setSaveEnabled(false);
if (dialog.showAndGet()) {
answer.set(dialog.getPassword());
}
};
// Use ModalityState.any() as currently ssh credentials in terminal mode are requested in the thread that reads output and not in
// the thread that started progress
WaitForProgressToShow.runOrInvokeAndWaitAboveProgress(command, ModalityState.any());
// Use ModalityState.any() as currently ssh credentials in terminal mode are requested in the thread that reads output and not in
// the thread that started progress
WaitForProgressToShow.runOrInvokeAndWaitAboveProgress(command, ModalityState.any());
return answer.get();
}
return answer.get();
});
}
@@ -15,7 +15,6 @@
*/
package org.jetbrains.idea.svn.auth;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.diagnostic.Logger;
@@ -63,7 +62,8 @@ import static com.intellij.util.WaitForProgressToShow.runOrInvokeLaterAboveProgr
/**
* @author alex
*/
public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager implements SvnAuthenticationListener, ISVNAuthenticationManagerExt {
public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager
implements SvnAuthenticationListener, ISVNAuthenticationManagerExt {
private static final Logger LOG = Logger.getInstance(SvnAuthenticationManager.class);
// while Mac storage not working for IDEA, we use this key to check whether to prompt abt plaintext or just store
public static final String SVN_SSH = "svn+ssh";
@@ -104,26 +104,22 @@ public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager im
myPersistentAuthenticationProviderProxy.setProject(myProject);
}
myInteraction = new MySvnAuthenticationInteraction(myProject);
Disposer.register(myProject, new Disposable() {
@Override
public void dispose() {
myVcs = null;
myProject = null;
if (myPersistentAuthenticationProviderProxy != null) {
myPersistentAuthenticationProviderProxy.myProject = null;
((MyKeyringMasterKeyProvider) myPersistentAuthenticationProviderProxy.myISVNGnomeKeyringPasswordProvider).myProject = null;
myPersistentAuthenticationProviderProxy = null;
}
if (myInteraction instanceof MySvnAuthenticationInteraction) {
((MySvnAuthenticationInteraction) myInteraction).myProject = null;
}
if (myConfig != null) {
myConfig.clear();
myConfig = null;
}
myInteraction = null;
Disposer.register(myProject, () -> {
myVcs = null;
myProject = null;
if (myPersistentAuthenticationProviderProxy != null) {
myPersistentAuthenticationProviderProxy.myProject = null;
((MyKeyringMasterKeyProvider)myPersistentAuthenticationProviderProxy.myISVNGnomeKeyringPasswordProvider).myProject = null;
myPersistentAuthenticationProviderProxy = null;
}
if (myInteraction instanceof MySvnAuthenticationInteraction) {
((MySvnAuthenticationInteraction)myInteraction).myProject = null;
}
if (myConfig != null) {
myConfig.clear();
myConfig = null;
}
myInteraction = null;
});
// This is not the same instance as DefaultSVNAuthenticationManager.myProviders[1], but currently
// DefaultSVNAuthenticationManager.CacheAuthenticationProvider uses only its outer class state - so we utilize necessary logic with
@@ -189,7 +185,7 @@ public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager im
SVNAuthentication previousAuth, boolean authMayBeStored) {
final SVNAuthentication authentication =
myDelegate.requestClientAuthentication(kind, url, realm, errorMessage, previousAuth, authMayBeStored);
if (myProject != null && ! myProject.isDisposed()) {
if (myProject != null && !myProject.isDisposed()) {
myProject.getMessageBus().syncPublisher(AUTHENTICATION_PROVIDER_LISTENER)
.requestClientAuthentication(kind, url, realm, errorMessage, previousAuth, authMayBeStored, authentication);
}
@@ -202,7 +198,7 @@ public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager im
Object certificate,
boolean resultMayBeStored) {
final int result = myDelegate.acceptServerAuthentication(url, realm, certificate, resultMayBeStored);
if (myProject != null && ! myProject.isDisposed()) {
if (myProject != null && !myProject.isDisposed()) {
myProject.getMessageBus().syncPublisher(AUTHENTICATION_PROVIDER_LISTENER)
.acceptServerAuthentication(url, realm, certificate, resultMayBeStored, result);
}
@@ -212,14 +208,19 @@ public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager im
public interface ISVNAuthenticationProviderListener {
void requestClientAuthentication(String kind, SVNURL url, String realm, SVNErrorMessage errorMessage,
SVNAuthentication previousAuth, boolean authMayBeStored, SVNAuthentication authentication);
void acceptServerAuthentication(SVNURL url, String realm, Object certificate, boolean resultMayBeStored, @MagicConstant int acceptResult);
SVNAuthentication previousAuth, boolean authMayBeStored, SVNAuthentication authentication);
void acceptServerAuthentication(SVNURL url,
String realm,
Object certificate,
boolean resultMayBeStored,
@MagicConstant int acceptResult);
}
@Override
public void setAuthenticationProvider(ISVNAuthenticationProvider provider) {
ISVNAuthenticationProvider useProvider = provider;
if (! (provider instanceof AuthenticationProviderProxy)) {
if (!(provider instanceof AuthenticationProviderProxy)) {
useProvider = new AuthenticationProviderProxy(provider);
}
myProvider = useProvider;
@@ -234,13 +235,13 @@ public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager im
/**
* Gets authentication provider without looking into thread local storage for providers.
*
* <p>
* TODO:
* Thread local storage is used "for some interaction with SVNKit" and is not always cleared correctly. So some threads contain
* "passive provider" in thread local storage - and getProvider() returns this "passive provider". This occurs, for instance when
* RemoteRevisionsCache is refreshed in background - after its execution, corresponding thread has "passive provider" in thread local
* storage.
*
* <p>
* As a result authentication fails in such cases (at least for command line implementation). To fix this, command line implementation is
* updated not to check thread local storage at all.
*
@@ -305,7 +306,7 @@ public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager im
@Override
public void requested(ProviderType type, SVNURL url, String realm, String kind, boolean canceled) {
if (ProviderType.interactive.equals(type) && (! canceled)) {
if (ProviderType.interactive.equals(type) && (!canceled)) {
ourJustEntered.set(true);
}
myListener.getMulticaster().requested(type, url, realm, kind, canceled);
@@ -347,7 +348,8 @@ public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager im
}
};
ensureListenerCreated();
myDelegate = new DefaultSVNPersistentAuthenticationProvider(authDir, userName, delegatingOptions, getDefaultOptions(), getHostOptionsProvider()) {
myDelegate = new DefaultSVNPersistentAuthenticationProvider(authDir, userName, delegatingOptions, getDefaultOptions(),
getHostOptionsProvider()) {
@Override
protected IPasswordStorage[] createPasswordStorages(DefaultSVNOptions options) {
final IPasswordStorage[] passwordStorages = super.createPasswordStorages(options);
@@ -366,17 +368,18 @@ public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager im
myProject = project;
}
public SVNAuthentication requestClientAuthentication(final String kind, final SVNURL url, final String realm, final SVNErrorMessage errorMessage,
final SVNAuthentication previousAuth, final boolean authMayBeStored) {
public SVNAuthentication requestClientAuthentication(final String kind,
final SVNURL url,
final String realm,
final SVNErrorMessage errorMessage,
final SVNAuthentication previousAuth,
final boolean authMayBeStored) {
try {
return wrapNativeCall(new ThrowableComputable<SVNAuthentication, SVNException>() {
@Override
public SVNAuthentication compute() throws SVNException {
final SVNAuthentication svnAuthentication =
myDelegate.requestClientAuthentication(kind, url, realm, errorMessage, previousAuth, authMayBeStored);
myListener.getMulticaster().requested(ProviderType.persistent, url, realm, kind, svnAuthentication == null);
return svnAuthentication;
}
return wrapNativeCall(() -> {
final SVNAuthentication svnAuthentication =
myDelegate.requestClientAuthentication(kind, url, realm, errorMessage, previousAuth, authMayBeStored);
myListener.getMulticaster().requested(ProviderType.persistent, url, realm, kind, svnAuthentication == null);
return svnAuthentication;
});
}
catch (SVNException e) {
@@ -391,41 +394,39 @@ public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager im
private void actualSavePermissions(String realm, SVNAuthentication auth) {
final String actualKind = auth.getKind();
File dir = new File(myAuthDir, actualKind);
String fileName = SVNFileUtil.computeChecksum(realm);
File authFile = new File(dir, fileName);
File dir = new File(myAuthDir, actualKind);
String fileName = SVNFileUtil.computeChecksum(realm);
File authFile = new File(dir, fileName);
try {
((ISVNPersistentAuthenticationProvider) myDelegate).saveAuthentication(auth, actualKind, realm);
}
catch (SVNException e) {
if (myProject != null) {
ApplicationManager.getApplication().invokeLater(new VcsBalloonProblemNotifier(myProject,
"<b>Problem when storing Subversion credentials:</b>&nbsp;" + e.getMessage(), MessageType.ERROR));
}
}
finally {
// do not make password file readonly
setWriteable(authFile);
}
try {
((ISVNPersistentAuthenticationProvider)myDelegate).saveAuthentication(auth, actualKind, realm);
}
catch (SVNException e) {
if (myProject != null) {
ApplicationManager.getApplication().invokeLater(new VcsBalloonProblemNotifier(myProject,
"<b>Problem when storing Subversion credentials:</b>&nbsp;" +
e.getMessage(), MessageType.ERROR));
}
}
finally {
// do not make password file readonly
setWriteable(authFile);
}
}
public void saveAuthentication(final SVNAuthentication auth, final String kind, final String realm) throws SVNException {
try {
wrapNativeCall(new ThrowableComputable<Void, SVNException>() {
@Override
public Void compute() throws SVNException {
final Boolean fromInteractive = ourJustEntered.get();
ourJustEntered.set(null);
if (! myArtificialSaving && ! Boolean.TRUE.equals(fromInteractive)) {
// not what user entered
return null;
}
myListener.getMulticaster().saveAttemptStarted(ProviderType.persistent, auth.getURL(), realm, auth.getKind());
((ISVNPersistentAuthenticationProvider) myDelegate).saveAuthentication(auth, kind, realm);
myListener.getMulticaster().saveAttemptFinished(ProviderType.persistent, auth.getURL(), realm, auth.getKind());
wrapNativeCall(() -> {
final Boolean fromInteractive = ourJustEntered.get();
ourJustEntered.set(null);
if (!myArtificialSaving && !Boolean.TRUE.equals(fromInteractive)) {
// not what user entered
return null;
}
myListener.getMulticaster().saveAttemptStarted(ProviderType.persistent, auth.getURL(), realm, auth.getKind());
((ISVNPersistentAuthenticationProvider)myDelegate).saveAuthentication(auth, kind, realm);
myListener.getMulticaster().saveAttemptFinished(ProviderType.persistent, auth.getURL(), realm, auth.getKind());
return null;
});
}
catch (SVNException e) {
@@ -437,12 +438,9 @@ public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager im
@Override
public void saveFingerprints(final String realm, final byte[] fingerprints) {
try {
wrapNativeCall(new ThrowableComputable<Void, SVNException>() {
@Override
public Void compute() throws SVNException {
((ISVNPersistentAuthenticationProvider) myDelegate).saveFingerprints(realm, fingerprints);
return null;
}
wrapNativeCall(() -> {
((ISVNPersistentAuthenticationProvider)myDelegate).saveFingerprints(realm, fingerprints);
return null;
});
}
catch (SVNException e) {
@@ -454,12 +452,7 @@ public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager im
@Override
public byte[] loadFingerprints(final String realm) {
try {
return wrapNativeCall(new ThrowableComputable<byte[], SVNException>() {
@Override
public byte[] compute() throws SVNException {
return ((ISVNPersistentAuthenticationProvider) myDelegate).loadFingerprints(realm);
}
});
return wrapNativeCall(() -> ((ISVNPersistentAuthenticationProvider)myDelegate).loadFingerprints(realm));
}
catch (SVNException e) {
LOG.info(e);
@@ -468,8 +461,9 @@ public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager im
}
private final static int maxAttempts = 10;
private void setWriteable(final File file) {
if (! file.exists()) return;
if (!file.exists()) return;
if (file.getParentFile() == null) {
return;
}
@@ -478,8 +472,8 @@ public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager im
try {
final File tempFile = FileUtil.createTempFile(parent, "123", "1", true);
FileUtil.delete(tempFile);
if (! file.renameTo(tempFile)) continue;
if (! file.createNewFile()) continue;
if (!file.renameTo(tempFile)) continue;
if (!file.createNewFile()) continue;
FileUtil.copy(tempFile, file);
FileUtil.delete(tempFile);
return;
@@ -496,7 +490,8 @@ public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager im
myKeyAlgorithm.put(Thread.currentThread(), keyAlgorithm);
try {
super.verifyHostKey(hostName, port, keyAlgorithm, hostKey);
} finally {
}
finally {
myKeyAlgorithm.remove(Thread.currentThread());
}
}
@@ -543,7 +538,8 @@ public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager im
final SVNAuthentication proxy = ProxySvnAuthentication.proxy(authentication, authStorageEnabled, myArtificialSaving);
super.acknowledgeAuthentication(accepted, kind, realm, errorMessage, proxy);
successSaving = true;
} finally {
}
finally {
mySavePermissions.remove();
if (myArtificialSaving) {
myArtificialSaving = false;
@@ -569,7 +565,7 @@ public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager im
}
public void acknowledgeForSSL(boolean accepted, SVNAuthentication proxy) {
if (accepted && proxy instanceof SVNSSLAuthentication && (((SVNSSLAuthentication) proxy).getCertificateFile() != null)) {
if (accepted && proxy instanceof SVNSSLAuthentication && (((SVNSSLAuthentication)proxy).getCertificateFile() != null)) {
final SVNSSLAuthentication svnsslAuthentication = (SVNSSLAuthentication)proxy;
final SVNURL url = svnsslAuthentication.getURL();
@@ -603,7 +599,7 @@ public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager im
// ! use common proxy if it is set
try {
final List<Proxy> proxies = HttpConfigurable.getInstance().getOnlyBySettingsSelector().select(new URI(url.toString()));
if (proxies != null && ! proxies.isEmpty()) {
if (proxies != null && !proxies.isEmpty()) {
for (Proxy proxy : proxies) {
if (HttpConfigurable.isRealProxy(proxy) && Proxy.Type.HTTP.equals(proxy.type())) {
final SocketAddress address = proxy.address();
@@ -624,15 +620,15 @@ public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager im
String proxyExceptions = getServersPropertyIdea(host, "http-proxy-exceptions");
String proxyExceptionsSeparator = ",";
if (proxyExceptions == null) {
proxyExceptions = System.getProperty("http.nonProxyHosts");
proxyExceptionsSeparator = "|";
proxyExceptions = System.getProperty("http.nonProxyHosts");
proxyExceptionsSeparator = "|";
}
if (proxyExceptions != null) {
for(StringTokenizer exceptions = new StringTokenizer(proxyExceptions, proxyExceptionsSeparator); exceptions.hasMoreTokens();) {
String exception = exceptions.nextToken().trim();
if (DefaultSVNOptions.matches(exception, host)) {
return null;
}
for (StringTokenizer exceptions = new StringTokenizer(proxyExceptions, proxyExceptionsSeparator); exceptions.hasMoreTokens(); ) {
String exception = exceptions.nextToken().trim();
if (DefaultSVNOptions.matches(exception, host)) {
return null;
}
}
}
String proxyPort = getServersPropertyIdea(host, HTTP_PROXY_PORT);
@@ -687,41 +683,42 @@ public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager im
}
private static class MySimpleProxyManager implements ISVNProxyManager {
protected String myProxyHost;
private final String myProxyPort;
protected String myProxyUser;
protected String myProxyPassword;
protected String myProxyHost;
private final String myProxyPort;
protected String myProxyUser;
protected String myProxyPassword;
public MySimpleProxyManager(String host, String port, String user, String password) {
myProxyHost = host;
myProxyPort = port == null ? "3128" : port;
myProxyUser = user;
myProxyPassword = password;
}
public MySimpleProxyManager(String host, String port, String user, String password) {
myProxyHost = host;
myProxyPort = port == null ? "3128" : port;
myProxyUser = user;
myProxyPassword = password;
}
public String getProxyHost() {
return myProxyHost;
}
public String getProxyHost() {
return myProxyHost;
}
public int getProxyPort() {
try {
return Integer.parseInt(myProxyPort);
} catch (NumberFormatException nfe) {
//
}
return 3128;
public int getProxyPort() {
try {
return Integer.parseInt(myProxyPort);
}
catch (NumberFormatException nfe) {
//
}
return 3128;
}
public String getProxyUserName() {
return myProxyUser;
}
public String getProxyUserName() {
return myProxyUser;
}
public String getProxyPassword() {
return myProxyPassword;
}
public String getProxyPassword() {
return myProxyPassword;
}
public void acknowledgeProxyContext(boolean accepted, SVNErrorMessage errorMessage) {
}
public void acknowledgeProxyContext(boolean accepted, SVNErrorMessage errorMessage) {
}
}
// 30 seconds
@@ -786,7 +783,7 @@ public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager im
}
}
Map globalProps = serversFile.getProperties("global");
return (String) globalProps.get(name);
return (String)globalProps.get(name);
}
public static boolean checkHostGroup(final String url, final String patterns, final String exceptions) {
@@ -799,15 +796,15 @@ public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager im
}
final String host = svnurl.getHost();
return matches(patterns, host) && (! matches(exceptions, host));
return matches(patterns, host) && (!matches(exceptions, host));
}
private static boolean matches(final String pattern, final String host) {
final StringTokenizer tokenizer = new StringTokenizer(pattern, ",");
while(tokenizer.hasMoreTokens()) {
while (tokenizer.hasMoreTokens()) {
String token = tokenizer.nextToken();
if (DefaultSVNOptions.matches(token, host)) {
return true;
return true;
}
}
return false;
@@ -815,7 +812,7 @@ public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager im
@Nullable
public static String getGroupForHost(final String host, final IdeaSVNConfigFile serversFile) {
final Map<String,ProxyGroup> groups = serversFile.getAllGroups();
final Map<String, ProxyGroup> groups = serversFile.getAllGroups();
for (Map.Entry<String, ProxyGroup> entry : groups.entrySet()) {
if (matchesGroupPattern(host, entry.getValue().getPatterns())) return entry.getKey();
}
@@ -825,19 +822,19 @@ public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager im
// taken from default manager as is
private static String getGroupName(Map groups, String host) {
for (Object o : groups.keySet()) {
final String name = (String) o;
final String pattern = (String) groups.get(name);
final String name = (String)o;
final String pattern = (String)groups.get(name);
if (matchesGroupPattern(host, pattern)) return name;
}
return null;
return null;
}
private static boolean matchesGroupPattern(String host, String pattern) {
for(StringTokenizer tokens = new StringTokenizer(pattern, ","); tokens.hasMoreTokens();) {
String token = tokens.nextToken();
if (DefaultSVNOptions.matches(token, host)) {
return true;
}
for (StringTokenizer tokens = new StringTokenizer(pattern, ","); tokens.hasMoreTokens(); ) {
String token = tokens.nextToken();
if (DefaultSVNOptions.matches(token, host)) {
return true;
}
}
return false;
}
@@ -871,24 +868,28 @@ public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager im
@Override
public void warnOnAuthStorageDisabled(SVNURL url) {
VcsBalloonProblemNotifier.showOverChangesView(myProject, "Cannot store credentials: forbidden by \"store-auth-creds=no\"", MessageType.ERROR);
VcsBalloonProblemNotifier
.showOverChangesView(myProject, "Cannot store credentials: forbidden by \"store-auth-creds=no\"", MessageType.ERROR);
}
@Override
public void warnOnPasswordStorageDisabled(SVNURL url) {
VcsBalloonProblemNotifier.showOverChangesView(myProject, "Cannot store password: forbidden by \"store-passwords=no\"", MessageType.ERROR);
VcsBalloonProblemNotifier
.showOverChangesView(myProject, "Cannot store password: forbidden by \"store-passwords=no\"", MessageType.ERROR);
}
@Override
public void warnOnSSLPassphraseStorageDisabled(SVNURL url) {
VcsBalloonProblemNotifier.showOverChangesView(myProject, "Cannot store passphrase: forbidden by \"store-ssl-client-cert-pp=no\"", MessageType.ERROR);
VcsBalloonProblemNotifier
.showOverChangesView(myProject, "Cannot store passphrase: forbidden by \"store-ssl-client-cert-pp=no\"", MessageType.ERROR);
}
@Override
public boolean promptForPlaintextPasswordSaving(SVNURL url, String realm) {
final int answer = Messages.showYesNoDialog(myProject, String.format("Your password for authentication realm:\n" +
"%s\ncan only be stored to disk unencrypted. Would you like to store it in plaintext?", realm),
"Store the password in plaintext?", Messages.getQuestionIcon());
"%s\ncan only be stored to disk unencrypted. Would you like to store it in plaintext?",
realm),
"Store the password in plaintext?", Messages.getQuestionIcon());
return answer == Messages.YES;
}
@@ -900,9 +901,11 @@ public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager im
@Override
public boolean promptForSSLPlaintextPassphraseSaving(SVNURL url, String realm, File certificateFile, String certificateName) {
final int answer = Messages.showYesNoDialog(myProject,
String.format("Your passphrase for " + certificateName + ":\n%s\ncan only be stored to disk unencrypted. Would you like to store it in plaintext?",
certificateFile.getPath()),
"Store the passphrase in plaintext?", Messages.getQuestionIcon());
String.format("Your passphrase for " +
certificateName +
":\n%s\ncan only be stored to disk unencrypted. Would you like to store it in plaintext?",
certificateFile.getPath()),
"Store the passphrase in plaintext?", Messages.getQuestionIcon());
return answer == Messages.YES;
}
@@ -967,13 +970,8 @@ public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager im
final boolean superValue = super.isStorePlainTextPasswords(realm, auth);
final boolean value = mySavePermissions.allowed() || superValue;
if ((! value) && (! mySavePermissions.have())) {
promptAndSaveWhenWeLackEncryption(realm, auth, new Getter<Boolean>() {
@Override
public Boolean get() {
return myInteraction.promptForPlaintextPasswordSaving(myUrl, realm);
}
});
if ((!value) && (!mySavePermissions.have())) {
promptAndSaveWhenWeLackEncryption(realm, auth, () -> myInteraction.promptForPlaintextPasswordSaving(myUrl, realm));
}
return value;
}
@@ -983,25 +981,24 @@ public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager im
if (USERNAME.equals(auth.getKind())) return true;
final boolean value = mySavePermissions.allowed() || super.isStorePlainTextPassphrases(realm, auth);
if ((! value) && (! mySavePermissions.have())) {
promptAndSaveWhenWeLackEncryption(realm, auth, new Getter<Boolean>() {
@Override
public Boolean get() {
File file = null;
String certificateName = null;
if (auth instanceof SVNSSLAuthentication) {
file = ((SVNSSLAuthentication) auth).getCertificateFile();
certificateName = "client certificate";
} else if (auth instanceof SVNSSHAuthentication) {
file = ((SVNSSHAuthentication) auth).getPrivateKeyFile();
certificateName = "private key file";
} else {
assert false;
}
return myInteraction.promptForSSLPlaintextPassphraseSaving(myUrl, realm,
file, certificateName);
}
});
if ((!value) && (!mySavePermissions.have())) {
promptAndSaveWhenWeLackEncryption(realm, auth, () -> {
File file = null;
String certificateName = null;
if (auth instanceof SVNSSLAuthentication) {
file = ((SVNSSLAuthentication)auth).getCertificateFile();
certificateName = "client certificate";
}
else if (auth instanceof SVNSSHAuthentication) {
file = ((SVNSSHAuthentication)auth).getPrivateKeyFile();
certificateName = "private key file";
}
else {
assert false;
}
return myInteraction.promptForSSLPlaintextPassphraseSaving(myUrl, realm,
file, certificateName);
});
}
return value;
}
@@ -1011,10 +1008,11 @@ public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager im
final boolean value;
if (hasAuthStorageEnabledOption()) {
value = super.isAuthStorageEnabled();
} else {
}
else {
value = isTurned(getConfigFile().getPropertyValue("auth", "store-auth-creds"));
}
if (! value) {
if (!value) {
myInteraction.warnOnAuthStorageDisabled(myUrl);
}
return value;
@@ -1026,11 +1024,12 @@ public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager im
final boolean value;
if (storePasswords != null) {
value = isTurned(storePasswords);
} else {
}
else {
final String configValue = getConfigFile().getPropertyValue("auth", "store-passwords");
value = isTurned(configValue);
}
if (! value) {
if (!value) {
myInteraction.warnOnPasswordStorageDisabled(myUrl);
}
return value;
@@ -1039,7 +1038,7 @@ public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager im
@Override
public boolean isStoreSSLClientCertificatePassphrases() {
final boolean value = super.isStoreSSLClientCertificatePassphrases();
if (! value) {
if (!value) {
myInteraction.warnOnSSLPassphraseStorageDisabled(myUrl);
}
return value;
@@ -1062,16 +1061,13 @@ public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager im
private void promptAndSaveWhenWeLackEncryption(final String realm, final SVNAuthentication auth, final Getter<Boolean> prompt) {
final Boolean[] saveOnce = new Boolean[1];
final Runnable actualSave = new Runnable() {
@Override
public void run() {
mySavePermissions.put(Boolean.TRUE.equals(saveOnce[0]));
try {
myPersistentAuthenticationProviderProxy.actualSavePermissions(realm, auth);
}
finally {
mySavePermissions.remove();
}
final Runnable actualSave = () -> {
mySavePermissions.put(Boolean.TRUE.equals(saveOnce[0]));
try {
myPersistentAuthenticationProviderProxy.actualSavePermissions(realm, auth);
}
finally {
mySavePermissions.remove();
}
};
@@ -1080,7 +1076,8 @@ public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager im
saveOnce[0] = Boolean.TRUE.equals(prompt.get());
ApplicationManager.getApplication().executeOnPooledThread(actualSave);
}, getCurrent(), myProject);
} else {
}
else {
saveOnce[0] = Boolean.TRUE.equals(prompt.get());
actualSave.run();
}
@@ -1152,7 +1149,8 @@ public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager im
LOG.info(sb.toString());
}
return t;
} finally {
}
finally {
NativeLogReader.clear();
NativeLogReader.endTracking();
}
@@ -1170,12 +1168,8 @@ public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager im
final String message = keyringName != null ? SvnBundle.message("gnome.keyring.prompt.named", keyringName)
: SvnBundle.message("gnome.keyring.prompt.nameless");
final Ref<String> result = Ref.create();
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
@Override
public void run() {
result.set(Messages.showPasswordDialog(myProject, message, SvnBundle.message("subversion.name"), Messages.getQuestionIcon()));
}
});
UIUtil.invokeAndWaitIfNeeded((Runnable)() -> result
.set(Messages.showPasswordDialog(myProject, message, SvnBundle.message("subversion.name"), Messages.getQuestionIcon())));
return !result.isNull() ? result.get().toCharArray() : null;
}
}
@@ -38,7 +38,6 @@ import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.wm.IdeFrame;
import com.intellij.openapi.wm.ex.WindowManagerEx;
import com.intellij.ui.awt.RelativePoint;
import com.intellij.util.Consumer;
import com.intellij.util.ThreeState;
import com.intellij.util.net.HttpConfigurable;
import com.intellij.util.proxy.CommonProxy;
@@ -62,7 +61,6 @@ import org.tmatesoft.svn.core.wc2.SvnTarget;
import javax.swing.*;
import java.awt.*;
import java.io.File;
import java.io.FilenameFilter;
import java.net.*;
import java.util.*;
import java.util.List;
@@ -112,22 +110,19 @@ public class SvnAuthenticationNotifier extends GenericNotifierImpl<SvnAuthentica
final Ref<Boolean> resultRef = new Ref<>();
final Runnable checker = new Runnable() {
@Override
public void run() {
try {
final boolean result =
interactiveValidation(obj.myProject, obj.getUrl(), obj.getRealm(), obj.getKind());
log("ask result for: " + obj.getUrl() + " is: " + result);
resultRef.set(result);
if (result) {
onStateChangedToSuccess(obj);
}
}
finally {
myVerificationInProgress = false;
final Runnable checker = () -> {
try {
final boolean result =
interactiveValidation(obj.myProject, obj.getUrl(), obj.getRealm(), obj.getKind());
log("ask result for: " + obj.getUrl() + " is: " + result);
resultRef.set(result);
if (result) {
onStateChangedToSuccess(obj);
}
}
finally {
myVerificationInProgress = false;
}
};
final Application application = ApplicationManager.getApplication();
// also do not show auth if thread does not have progress indicator
@@ -173,12 +168,9 @@ public class SvnAuthenticationNotifier extends GenericNotifierImpl<SvnAuthentica
}
}
log("on state changed ");
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
for (SVNURL key : outdatedRequests) {
removeLazyNotificationByKey(key);
}
ApplicationManager.getApplication().invokeLater(() -> {
for (SVNURL key : outdatedRequests) {
removeLazyNotificationByKey(key);
}
}, ModalityState.NON_MODAL);
}
@@ -428,35 +420,23 @@ public class SvnAuthenticationNotifier extends GenericNotifierImpl<SvnAuthentica
private static void showAuthenticationFailedWithHotFixes(final Project project,
final SvnConfiguration configuration,
final SVNException e) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
VcsBalloonProblemNotifier.showOverChangesView(project, "Authentication failed: " + e.getMessage(), MessageType.ERROR,
new NamedRunnable(
SvnBundle.message("confirmation.title.clear.authentication.cache")) {
@Override
public void run() {
clearAuthenticationCache(project, null, configuration
.getConfigurationDirectory());
}
},
new NamedRunnable(SvnBundle.message("action.title.select.configuration.directory")) {
@Override
public void run() {
SvnConfigurable
.selectConfigurationDirectory(configuration.getConfigurationDirectory(),
new Consumer<String>() {
@Override
public void consume(String s) {
configuration
.setConfigurationDirParameters(false, s);
}
}, project, null);
}
}
);
}
}, ModalityState.NON_MODAL, project.getDisposed());
ApplicationManager.getApplication().invokeLater(() -> VcsBalloonProblemNotifier
.showOverChangesView(project, "Authentication failed: " + e.getMessage(), MessageType.ERROR, new NamedRunnable(
SvnBundle.message("confirmation.title.clear.authentication.cache")) {
@Override
public void run() {
clearAuthenticationCache(project, null, configuration
.getConfigurationDirectory());
}
}, new NamedRunnable(
SvnBundle.message("action.title.select.configuration.directory")) {
@Override
public void run() {
SvnConfigurable.selectConfigurationDirectory(configuration.getConfigurationDirectory(),
s -> configuration.setConfigurationDirParameters(false, s), project, null);
}
}
), ModalityState.NON_MODAL, project.getDisposed());
}
public static void clearAuthenticationCache(@NotNull final Project project, final Component component, final String configDirPath) {
@@ -481,27 +461,19 @@ public class SvnAuthenticationNotifier extends GenericNotifierImpl<SvnAuthentica
public static void clearAuthenticationDirectory(@NotNull SvnConfiguration configuration) {
final File authDir = new File(configuration.getConfigurationDirectory(), "auth");
if (authDir.exists()) {
final Runnable process = new Runnable() {
@Override
public void run() {
final ProgressIndicator ind = ProgressManager.getInstance().getProgressIndicator();
if (ind != null) {
ind.setIndeterminate(true);
ind.setText("Clearing stored credentials in " + authDir.getAbsolutePath());
}
final File[] files = authDir.listFiles(new FilenameFilter() {
@Override
public boolean accept(@NotNull File dir, @NotNull String name) {
return ourAuthKinds.contains(name);
}
});
final Runnable process = () -> {
final ProgressIndicator ind = ProgressManager.getInstance().getProgressIndicator();
if (ind != null) {
ind.setIndeterminate(true);
ind.setText("Clearing stored credentials in " + authDir.getAbsolutePath());
}
final File[] files = authDir.listFiles((dir, name) -> ourAuthKinds.contains(name));
for (File dir : files) {
if (ind != null) {
ind.setText("Deleting " + dir.getAbsolutePath());
}
FileUtil.delete(dir);
for (File dir : files) {
if (ind != null) {
ind.setText("Deleting " + dir.getAbsolutePath());
}
FileUtil.delete(dir);
}
};
final Application application = ApplicationManager.getApplication();
@@ -85,14 +85,12 @@ public class SvnInteractiveAuthenticationProvider implements ISVNAuthenticationP
final String userName =
previousAuth != null && previousAuth.getUserName() != null ? previousAuth.getUserName() : myManager.getDefaultUsername(kind, url);
if (ISVNAuthenticationManager.PASSWORD.equals(kind)) {// || ISVNAuthenticationManager.USERNAME.equals(kind)) {
command = new Runnable() {
public void run() {
SimpleCredentialsDialog dialog = new SimpleCredentialsDialog(myProject);
dialog.setup(realm, userName, authCredsOn);
setTitle(dialog, errorMessage);
if (dialog.showAndGet()) {
result[0] = new SVNPasswordAuthentication(dialog.getUserName(), dialog.getPassword(), dialog.isSaveAllowed(), url, false);
}
command = () -> {
SimpleCredentialsDialog dialog = new SimpleCredentialsDialog(myProject);
dialog.setup(realm, userName, authCredsOn);
setTitle(dialog, errorMessage);
if (dialog.showAndGet()) {
result[0] = new SVNPasswordAuthentication(dialog.getUserName(), dialog.getPassword(), dialog.isSaveAllowed(), url, false);
}
};
}
@@ -100,14 +98,12 @@ public class SvnInteractiveAuthenticationProvider implements ISVNAuthenticationP
if (ApplicationManager.getApplication().isUnitTestMode()) {
return new SVNUserNameAuthentication(userName, false);
}
command = new Runnable() {
public void run() {
UserNameCredentialsDialog dialog = new UserNameCredentialsDialog(myProject);
dialog.setup(realm, userName, authCredsOn);
setTitle(dialog, errorMessage);
if (dialog.showAndGet()) {
result[0] = new SVNUserNameAuthentication(dialog.getUserName(), dialog.isSaveAllowed(), url, false);
}
command = () -> {
UserNameCredentialsDialog dialog = new UserNameCredentialsDialog(myProject);
dialog.setup(realm, userName, authCredsOn);
setTitle(dialog, errorMessage);
if (dialog.showAndGet()) {
result[0] = new SVNUserNameAuthentication(dialog.getUserName(), dialog.isSaveAllowed(), url, false);
}
};
}
@@ -117,47 +113,43 @@ public class SvnInteractiveAuthenticationProvider implements ISVNAuthenticationP
final Connector agentConnector = createSshAgentConnector();
final boolean isAgentAvailable = agentConnector != null && agentConnector.isAvailable();
command = new Runnable() {
public void run() {
SSHCredentialsDialog dialog = new SSHCredentialsDialog(myProject, realm, userName, authCredsOn, url.getPort(), isAgentAvailable);
setTitle(dialog, errorMessage);
if (dialog.showAndGet()) {
int port = dialog.getPortNumber();
if (dialog.isSshAgentSelected()) {
if (agentConnector != null) {
result[0] =
new SVNSSHAuthentication(dialog.getUserName(), new TrileadAgentProxy(agentConnector), port, url, false);
}
}
else if (dialog.getKeyFile() != null && dialog.getKeyFile().trim().length() > 0) {
String passphrase = dialog.getPassphrase();
if (passphrase != null && passphrase.length() == 0) {
passphrase = null;
}
command = () -> {
SSHCredentialsDialog dialog = new SSHCredentialsDialog(myProject, realm, userName, authCredsOn, url.getPort(), isAgentAvailable);
setTitle(dialog, errorMessage);
if (dialog.showAndGet()) {
int port = dialog.getPortNumber();
if (dialog.isSshAgentSelected()) {
if (agentConnector != null) {
result[0] =
new SVNSSHAuthentication(dialog.getUserName(), new File(dialog.getKeyFile()), passphrase, port, dialog.isSaveAllowed(), url,
false);
new SVNSSHAuthentication(dialog.getUserName(), new TrileadAgentProxy(agentConnector), port, url, false);
}
else {
result[0] = new SVNSSHAuthentication(dialog.getUserName(), dialog.getPassword(), port, dialog.isSaveAllowed(), url, false);
}
else if (dialog.getKeyFile() != null && dialog.getKeyFile().trim().length() > 0) {
String passphrase = dialog.getPassphrase();
if (passphrase != null && passphrase.length() == 0) {
passphrase = null;
}
result[0] =
new SVNSSHAuthentication(dialog.getUserName(), new File(dialog.getKeyFile()), passphrase, port, dialog.isSaveAllowed(), url,
false);
}
else {
result[0] = new SVNSSHAuthentication(dialog.getUserName(), dialog.getPassword(), port, dialog.isSaveAllowed(), url, false);
}
}
};
} else if (ISVNAuthenticationManager.SSL.equals(kind)) {
command = new Runnable() {
public void run() {
final ISVNHostOptions options = myManager.getHostOptionsProvider().getHostOptions(url);
final String file = options.getSSLClientCertFile();
final SSLCredentialsDialog dialog = new SSLCredentialsDialog(myProject, realm, authCredsOn);
if (!StringUtil.isEmptyOrSpaces(file)) {
dialog.setFile(file);
}
setTitle(dialog, errorMessage);
if (dialog.showAndGet()) {
result[0] = new SVNSSLAuthentication(new File(dialog.getCertificatePath()), String.valueOf(dialog.getCertificatePassword()),
dialog.getSaveAuth(), url, false);
}
command = () -> {
final ISVNHostOptions options = myManager.getHostOptionsProvider().getHostOptions(url);
final String file = options.getSSLClientCertFile();
final SSLCredentialsDialog dialog = new SSLCredentialsDialog(myProject, realm, authCredsOn);
if (!StringUtil.isEmptyOrSpaces(file)) {
dialog.setFile(file);
}
setTitle(dialog, errorMessage);
if (dialog.showAndGet()) {
result[0] = new SVNSSLAuthentication(new File(dialog.getCertificatePath()), String.valueOf(dialog.getCertificatePassword()),
dialog.getSaveAuth(), url, false);
}
};
}
@@ -197,25 +189,20 @@ public class SvnInteractiveAuthenticationProvider implements ISVNAuthenticationP
final int[] result = new int[1];
Runnable command;
if (certificate instanceof X509Certificate || certificate instanceof String) {
command = new Runnable() {
public void run() {
ServerSSLDialog dialog = certificate instanceof X509Certificate
? new ServerSSLDialog(myProject, (X509Certificate)certificate, resultMayBeStored)
: new ServerSSLDialog(myProject, (String)certificate, resultMayBeStored);
dialog.show();
result[0] = dialog.getResult();
}
command = () -> {
ServerSSLDialog dialog = certificate instanceof X509Certificate
? new ServerSSLDialog(myProject, (X509Certificate)certificate, resultMayBeStored)
: new ServerSSLDialog(myProject, (String)certificate, resultMayBeStored);
dialog.show();
result[0] = dialog.getResult();
};
} else if (certificate instanceof byte[]) {
final String sshKeyAlgorithm = myManager.getSSHKeyAlgorithm();
command = new Runnable() {
@Override
public void run() {
final ServerSSHDialog serverSSHDialog =
new ServerSSHDialog(myProject, resultMayBeStored, url.toDecodedString(), sshKeyAlgorithm, (byte[])certificate);
serverSSHDialog.show();
result[0] = serverSSHDialog.getResult();
}
command = () -> {
final ServerSSHDialog serverSSHDialog =
new ServerSSHDialog(myProject, resultMayBeStored, url.toDecodedString(), sshKeyAlgorithm, (byte[])certificate);
serverSSHDialog.show();
result[0] = serverSSHDialog.getResult();
};
} else {
VcsBalloonProblemNotifier.showOverChangesView(myProject, "Subversion: unknown certificate type from " + url.toDecodedString(),
@@ -122,19 +122,16 @@ public class BranchConfigurationDialog extends DialogWrapper {
}
}
})
.setRemoveAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
int selectedIndex = myBranchLocationsList.getSelectedIndex();
for (String url : myBranchLocationsList.getSelectedValuesList()) {
int index = myBranchLocationsModel.getConfiguration().getBranchUrls().indexOf(url);
myBranchLocationsModel.getConfiguration().removeBranch(url);
myBranchLocationsModel.fireItemRemoved(index);
}
if (myBranchLocationsModel.getSize() > 0) {
selectedIndex = min(selectedIndex, myBranchLocationsModel.getSize() - 1);
myBranchLocationsList.setSelectedIndex(selectedIndex);
}
.setRemoveAction(button -> {
int selectedIndex = myBranchLocationsList.getSelectedIndex();
for (String url : myBranchLocationsList.getSelectedValuesList()) {
int index = myBranchLocationsModel.getConfiguration().getBranchUrls().indexOf(url);
myBranchLocationsModel.getConfiguration().removeBranch(url);
myBranchLocationsModel.fireItemRemoved(index);
}
if (myBranchLocationsModel.getSize() > 0) {
selectedIndex = min(selectedIndex, myBranchLocationsModel.getSize() - 1);
myBranchLocationsList.setSelectedIndex(selectedIndex);
}
})
.disableUpDownActions()
@@ -24,7 +24,6 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.idea.svn.SvnVcs;
import org.jetbrains.idea.svn.api.Depth;
import org.jetbrains.idea.svn.browse.BrowseClient;
import org.jetbrains.idea.svn.browse.DirectoryEntry;
import org.jetbrains.idea.svn.browse.DirectoryEntryConsumer;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNURL;
@@ -93,13 +92,9 @@ public class BranchesLoader implements Runnable {
@NotNull
private static DirectoryEntryConsumer createConsumer(@NotNull final List<SvnBranchItem> result) {
return new DirectoryEntryConsumer() {
@Override
public void consume(final DirectoryEntry entry) throws SVNException {
if (entry.getDate() != null) {
result.add(new SvnBranchItem(entry.getUrl().toDecodedString(), entry.getDate(), entry.getRevision()));
}
return entry -> {
if (entry.getDate() != null) {
result.add(new SvnBranchItem(entry.getUrl().toDecodedString(), entry.getDate(), entry.getRevision()));
}
};
}
@@ -45,11 +45,8 @@ import org.tmatesoft.svn.core.internal.util.SVNPathUtil;
import org.tmatesoft.svn.core.wc.SVNRevision;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
@@ -109,12 +106,10 @@ public class CreateBranchOrTagDialog extends DialogWrapper {
updateControls();
}
});
myRepositoryField.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
SVNURL url = SelectLocationDialog.selectLocation(project, mySrcURL);
if (url != null) {
myRepositoryField.setText(url.toString());
}
myRepositoryField.addActionListener(e -> {
SVNURL url = SelectLocationDialog.selectLocation(project, mySrcURL);
if (url != null) {
myRepositoryField.setText(url.toString());
}
});
myRepositoryField.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
@@ -122,16 +117,14 @@ public class CreateBranchOrTagDialog extends DialogWrapper {
updateToURL();
}
});
myToURLText.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
String url = myToURLText.getText();
String dstName = SVNPathUtil.tail(mySrcURL);
dstName = SVNEncodingUtil.uriDecode(dstName);
url = SelectLocationDialog.selectCopyDestination(myProject, SVNPathUtil.removeTail(url),
SvnBundle.message("label.copy.select.location.dialog.copy.as"), dstName, false);
if (url != null) {
myToURLText.setText(url);
}
myToURLText.addActionListener(e -> {
String url = myToURLText.getText();
String dstName = SVNPathUtil.tail(mySrcURL);
dstName = SVNEncodingUtil.uriDecode(dstName);
url = SelectLocationDialog.selectCopyDestination(myProject, SVNPathUtil.removeTail(url),
SvnBundle.message("label.copy.select.location.dialog.copy.as"), dstName, false);
if (url != null) {
myToURLText.setText(url);
}
});
@@ -149,25 +142,13 @@ public class CreateBranchOrTagDialog extends DialogWrapper {
myRevisionPanel.setRoot(mySrcVirtualFile);
myRevisionPanel.setProject(myProject);
myRevisionPanel.setUrlProvider(new SvnRevisionPanel.UrlProvider() {
public String getUrl() {
return mySrcURL;
}
});
myRevisionPanel.setUrlProvider(() -> mySrcURL);
updateBranchTagBases();
myRevisionPanel.addChangeListener(new ChangeListener() {
public void stateChanged(final ChangeEvent e) {
getOKAction().setEnabled(isOKActionEnabled());
}
});
myRevisionPanel.addChangeListener(e -> getOKAction().setEnabled(isOKActionEnabled()));
init();
ActionListener listener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
updateControls();
}
};
ActionListener listener = e -> updateControls();
myWorkingCopyRadioButton.addActionListener(listener);
myRepositoryRadioButton.addActionListener(listener);
myBranchOrTagRadioButton.addActionListener(listener);
@@ -179,23 +160,15 @@ public class CreateBranchOrTagDialog extends DialogWrapper {
}
});
updateToURL();
myProjectButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
myRepositoryField.setText(myWcRootUrl);
}
myProjectButton.addActionListener(e -> myRepositoryField.setText(myWcRootUrl));
myBranchTagBaseComboBox.addActionListener(e -> {
BranchConfigurationDialog.configureBranches(project, mySrcVirtualFile);
updateBranchTagBases();
updateControls();
});
myBranchTagBaseComboBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
BranchConfigurationDialog.configureBranches(project, mySrcVirtualFile);
updateBranchTagBases();
updateControls();
}
});
myBranchTagBaseComboBox.getComboBox().addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
updateToURL();
updateControls();
}
myBranchTagBaseComboBox.getComboBox().addActionListener(e -> {
updateToURL();
updateControls();
});
}
@@ -27,7 +27,6 @@ import org.jetbrains.annotations.Nullable;
import org.jetbrains.idea.svn.SvnUtil;
import org.jetbrains.idea.svn.SvnVcs;
import org.jetbrains.idea.svn.api.Depth;
import org.jetbrains.idea.svn.browse.DirectoryEntry;
import org.jetbrains.idea.svn.browse.DirectoryEntryConsumer;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNURL;
@@ -130,20 +129,16 @@ public class DefaultBranchConfigInitializer implements Runnable {
@NotNull
private static DirectoryEntryConsumer createHandler(@NotNull final SvnBranchConfigurationNew result, @NotNull final SVNURL rootPath) {
return new DirectoryEntryConsumer() {
return entry -> {
if (entry.isDirectory()) {
SVNURL childUrl = rootPath.appendPath(entry.getName(), false);
@Override
public void consume(final DirectoryEntry entry) throws SVNException {
if (entry.isDirectory()) {
SVNURL childUrl = rootPath.appendPath(entry.getName(), false);
if (StringUtil.endsWithIgnoreCase(entry.getName(), DEFAULT_TRUNK_NAME)) {
result.setTrunkUrl(childUrl.toString());
}
else {
result.addBranches(childUrl.toString(),
new InfoStorage<>(new ArrayList<>(0), InfoReliability.defaultValues));
}
if (StringUtil.endsWithIgnoreCase(entry.getName(), DEFAULT_TRUNK_NAME)) {
result.setTrunkUrl(childUrl.toString());
}
else {
result.addBranches(childUrl.toString(),
new InfoStorage<>(new ArrayList<>(0), InfoReliability.defaultValues));
}
}
};
@@ -17,10 +17,10 @@ package org.jetbrains.idea.svn.branchConfig;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.vcs.ProgressManagerQueue;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.CalledInBackground;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.vcs.ProgressManagerQueue;
import org.jetbrains.annotations.CalledInBackground;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.idea.svn.SvnVcs;
@@ -62,12 +62,7 @@ public class NewRootBunch {
}
if (reload && override) {
myBranchesLoader.run(new Runnable() {
@Override
public void run() {
reloadBranches(root, previous, config.getValue());
}
});
myBranchesLoader.run(() -> reloadBranches(root, previous, config.getValue()));
}
}
}
@@ -104,12 +99,7 @@ public class NewRootBunch {
public void reloadBranchesAsync(@NotNull final VirtualFile root,
@NotNull final String branchLocation,
@NotNull final InfoReliability reliability) {
ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
@Override
public void run() {
reloadBranches(root, branchLocation, reliability, true);
}
});
ApplicationManager.getApplication().executeOnPooledThread(() -> reloadBranches(root, branchLocation, reliability, true));
}
public void reloadBranches(@NotNull VirtualFile root, @Nullable SvnBranchConfigurationNew prev, @NotNull SvnBranchConfigurationNew next) {
@@ -168,25 +168,13 @@ public class SelectBranchPopup {
@Override
public PopupStep onChosen(final String selectedValue, final boolean finalChoice) {
if (CONFIGURE_MESSAGE.equals(selectedValue)) {
return doFinalStep(new Runnable() {
public void run() {
BranchConfigurationDialog.configureBranches(myProject, myVcsRoot);
}
});
return doFinalStep(() -> BranchConfigurationDialog.configureBranches(myProject, myVcsRoot));
}
else if (myTrunkString.equals(selectedValue)) {
return doFinalStep(new Runnable() {
public void run() {
myCallback.branchSelected(myProject, myConfiguration, myConfiguration.getTrunkUrl(), -1);
}
});
return doFinalStep(() -> myCallback.branchSelected(myProject, myConfiguration, myConfiguration.getTrunkUrl(), -1));
}
else if (!myTopLevel || selectedValue.equals(myConfiguration.getTrunkUrl())) {
return doFinalStep(new Runnable() {
public void run() {
myCallback.branchSelected(myProject, myConfiguration, selectedValue, -1);
}
});
return doFinalStep(() -> myCallback.branchSelected(myProject, myConfiguration, selectedValue, -1));
}
else {
showBranchPopup(selectedValue);
@@ -238,35 +226,18 @@ public class SelectBranchPopup {
.setTitle(SVNPathUtil.tail(selectedValue))
.setResizable(true)
//.setDimensionServiceKey("Svn.CompareWithBranchPopup")
.setItemChoosenCallback(new Runnable() {
public void run() {
if (REFRESH_MESSAGE.equals(branchList.getSelectedValue())) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
loadBranches(selectedValue, new Runnable() {
@Override
public void run() {
showBranchPopup(selectedValue);
}
});
}
});
return;
}
SvnBranchItem item = (SvnBranchItem)branchList.getSelectedValue();
if (item != null) {
myCallback.branchSelected(myProject, myConfiguration, item.getUrl(), item.getRevision());
}
.setItemChoosenCallback(() -> {
if (REFRESH_MESSAGE.equals(branchList.getSelectedValue())) {
SwingUtilities.invokeLater(() -> loadBranches(selectedValue, () -> showBranchPopup(selectedValue)));
return;
}
})
.setFilteringEnabled(new NullableFunction<Object, String>() {
@Nullable
@Override
public String fun(Object item) {
return item instanceof SvnBranchItem ? getBranchName((SvnBranchItem)item) : null;
SvnBranchItem item = (SvnBranchItem)branchList.getSelectedValue();
if (item != null) {
myCallback.branchSelected(myProject, myConfiguration, item.getUrl(), item.getRevision());
}
})
.setFilteringEnabled(
(NullableFunction<Object, String>)item -> item instanceof SvnBranchItem ? getBranchName((SvnBranchItem)item) : null)
.createPopup();
showPopupAt(popup);
}
@@ -62,18 +62,11 @@ public class SvnBranchConfigurationManager implements PersistentStateComponent<S
// TODO: for DefaultConfigLoader it would be better to run modal cancellable task - so branches structure could be detected and
// TODO: shown in dialog. Currently when "Configure Branches" is invoked for the first time - no branches are shown.
// TODO: If "Cancel" is pressed and "Configure Branches" invoked once again - already detected (in background) branches are shown.
((ProjectLevelVcsManagerImpl) vcsManager).addInitializationRequest(VcsInitObject.BRANCHES, new Runnable() {
@Override
public void run() {
ApplicationManager.getApplication().runReadAction(new Runnable() {
@Override
public void run() {
if (myProject.isDisposed()) return;
myBranchesLoader.start();
}
});
}
});
((ProjectLevelVcsManagerImpl)vcsManager)
.addInitializationRequest(VcsInitObject.BRANCHES, () -> ApplicationManager.getApplication().runReadAction(() -> {
if (myProject.isDisposed()) return;
myBranchesLoader.start();
}));
myBunch = new NewRootBunch(project, myBranchesLoader);
}
@@ -189,22 +182,17 @@ public class SvnBranchConfigurationManager implements PersistentStateComponent<S
}
private void preloadBranches(@NotNull final Collection<Pair<VirtualFile, SvnBranchConfigurationNew>> branchPoints) {
((ProjectLevelVcsManagerImpl) myVcsManager).addInitializationRequest(VcsInitObject.BRANCHES, new Runnable() {
public void run() {
ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
public void run() {
try {
for (Pair<VirtualFile, SvnBranchConfigurationNew> pair : branchPoints) {
myBunch.reloadBranches(pair.getFirst(), null, pair.getSecond());
}
}
catch (ProcessCanceledException e) {
//
}
((ProjectLevelVcsManagerImpl)myVcsManager)
.addInitializationRequest(VcsInitObject.BRANCHES, () -> ApplicationManager.getApplication().executeOnPooledThread(() -> {
try {
for (Pair<VirtualFile, SvnBranchConfigurationNew> pair : branchPoints) {
myBunch.reloadBranches(pair.getFirst(), null, pair.getSecond());
}
});
}
});
}
catch (ProcessCanceledException e) {
//
}
}));
}
private List<SvnBranchItem> getStored(String branchUrl) {
@@ -19,7 +19,6 @@ import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.ObjectsConvertor;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.containers.Convertor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.idea.svn.SvnUtil;
@@ -64,12 +63,7 @@ public class SvnBranchConfigurationNew {
public List<String> getBranchUrls() {
final ArrayList<String> result = new ArrayList<>(myBranchMap.keySet());
final List<String> cutList = ObjectsConvertor.convert(result, new Convertor<String, String>() {
@Override
public String convert(String s) {
return cutEndSlash(s);
}
});
final List<String> cutList = ObjectsConvertor.convert(result, s -> cutEndSlash(s));
Collections.sort(cutList);
return cutList;
}
@@ -121,12 +121,8 @@ public class IdeaCommitHandler implements CommitEventHandler, ProgressTracker {
private void trackDeletedFile(@NotNull ProgressEvent event) {
@NonNls final String filePath = "file://" + event.getFile().getAbsolutePath().replace(File.separatorChar, '/');
VirtualFile virtualFile = ApplicationManager.getApplication().runReadAction(new Computable<VirtualFile>() {
@Nullable
public VirtualFile compute() {
return VirtualFileManager.getInstance().findFileByUrl(filePath);
}
});
VirtualFile virtualFile = ApplicationManager.getApplication()
.runReadAction((Computable<VirtualFile>)() -> VirtualFileManager.getInstance().findFileByUrl(filePath));
if (virtualFile != null) {
myDeletedFiles.add(virtualFile);
@@ -22,7 +22,6 @@ import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.MessageType;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.vcs.CheckinProjectPanel;
import com.intellij.openapi.vcs.FilePath;
@@ -135,16 +134,8 @@ public class SvnCheckinEnvironment implements CheckinEnvironment {
final Project project = mySvnVcs.getProject();
final String message = SvnBundle.message("status.text.comitted.revision", committedRevisions);
if (feedback == null) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
public void run() {
new VcsBalloonProblemNotifier(project, message, MessageType.INFO).run();
}
}, new Condition<Object>() {
@Override
public boolean value(Object o) {
return (! project.isOpen()) || project.isDisposed();
}
});
ApplicationManager.getApplication().invokeLater(() -> new VcsBalloonProblemNotifier(project, message, MessageType.INFO).run(),
o -> (!project.isOpen()) || project.isDisposed());
} else {
feedback.add("Subversion: " + message);
}
@@ -207,11 +198,9 @@ public class SvnCheckinEnvironment implements CheckinEnvironment {
doCommit(committables, preparedComment, exception, feedback);
}
else if (ApplicationManager.getApplication().isDispatchThread()) {
ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
public void run() {
doCommit(committables, preparedComment, exception, feedback);
}
}, SvnBundle.message("progress.title.commit"), false, mySvnVcs.getProject());
ProgressManager.getInstance().runProcessWithProgressSynchronously(
() -> doCommit(committables, preparedComment, exception, feedback), SvnBundle.message("progress.title.commit"), false,
mySvnVcs.getProject());
}
else {
doCommit(committables, preparedComment, exception, feedback);
@@ -115,12 +115,10 @@ public class SvnCheckinHandlerFactory extends VcsCheckinHandlerFactory {
}
}
if (paths.isEmpty()) return;
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
AutoSvnUpdater.run(new AutoSvnUpdater(project, paths.toArray(new FilePath[paths.size()])), ActionInfo.UPDATE.getActionName());
}
}, ModalityState.NON_MODAL);
ApplicationManager.getApplication().invokeLater(
() -> AutoSvnUpdater
.run(new AutoSvnUpdater(project, paths.toArray(new FilePath[paths.size()])), ActionInfo.UPDATE.getActionName()),
ModalityState.NON_MODAL);
}
}
};
@@ -20,7 +20,6 @@ import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.ArrayUtil;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.idea.svn.api.BaseSvnClient;
@@ -83,12 +82,7 @@ public class SvnKitCheckinClient extends BaseSvnClient implements CheckinClient
@NotNull
private static CommitInfo[] convert(@NotNull SVNCommitInfo[] infos) {
return ContainerUtil.map(infos, new Function<SVNCommitInfo, CommitInfo>() {
@Override
public CommitInfo fun(SVNCommitInfo info) {
return new CommitInfo.Builder(info.getNewRevision(), info.getDate(), info.getAuthor())
.setError(info.getErrorMessage()).build();
}
}, new CommitInfo[0]);
return ContainerUtil.map(infos, info -> new CommitInfo.Builder(info.getNewRevision(), info.getDate(), info.getAuthor())
.setError(info.getErrorMessage()).build(), new CommitInfo[0]);
}
}
@@ -80,7 +80,7 @@ public class SvnCheckoutProvider implements CheckoutProvider {
public static void doCheckout(@NotNull Project project, @NotNull File target, final String url, final SVNRevision revision,
final Depth depth, final boolean ignoreExternals, @Nullable final Listener listener) {
if (! target.exists()) {
if (!target.exists()) {
target.mkdirs();
}
@@ -102,16 +102,17 @@ public class SvnCheckoutProvider implements CheckoutProvider {
}
public static void checkout(final Project project,
final File target,
final String url,
final SVNRevision revision,
final Depth depth,
final boolean ignoreExternals,
final Listener listener, final WorkingCopyFormat selectedFormat) {
final File target,
final String url,
final SVNRevision revision,
final Depth depth,
final boolean ignoreExternals,
final Listener listener, final WorkingCopyFormat selectedFormat) {
final Ref<Boolean> checkoutSuccessful = new Ref<>();
final Exception[] exception = new Exception[1];
final Task.Backgroundable checkoutBackgroundTask = new Task.Backgroundable(project,
message("message.title.check.out"), true, VcsConfiguration.getInstance(project).getCheckoutOption()) {
message("message.title.check.out"), true,
VcsConfiguration.getInstance(project).getCheckoutOption()) {
public void run(@NotNull final ProgressIndicator indicator) {
final WorkingCopyFormat format = selectedFormat == null ? UNKNOWN : selectedFormat;
@@ -170,7 +171,7 @@ public class SvnCheckoutProvider implements CheckoutProvider {
private static void notifyRootManagerIfUnderProject(final Project project, final File directory) {
if (project.isDefault()) return;
final ProjectLevelVcsManagerEx plVcsManager = ProjectLevelVcsManagerEx.getInstanceEx(project);
final SvnVcs vcs = (SvnVcs) plVcsManager.findVcsByName(SvnVcs.VCS_NAME);
final SvnVcs vcs = (SvnVcs)plVcsManager.findVcsByName(SvnVcs.VCS_NAME);
final VirtualFile[] files = vcs.getSvnFileUrlMapping().getNotFilteredRoots();
for (VirtualFile file : files) {
@@ -194,20 +195,18 @@ public class SvnCheckoutProvider implements CheckoutProvider {
final VcsException[] exception = new VcsException[1];
final SvnVcs vcs = SvnVcs.getInstance(project);
ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
public void run() {
ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator();
ProgressTracker handler = new CheckoutEventHandler(vcs, true, progressIndicator);
try {
progressIndicator.setText(message("progress.text.export", target.getAbsolutePath()));
ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> {
ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator();
ProgressTracker handler = new CheckoutEventHandler(vcs, true, progressIndicator);
try {
progressIndicator.setText(message("progress.text.export", target.getAbsolutePath()));
SvnTarget from = SvnTarget.fromURL(url);
ExportClient client = vcs.getFactoryFromSettings().createExportClient();
client.export(from, target, SVNRevision.HEAD, depth, eolStyle, force, ignoreExternals, handler);
}
catch (VcsException e) {
exception[0] = e;
}
SvnTarget from = SvnTarget.fromURL(url);
ExportClient client = vcs.getFactoryFromSettings().createExportClient();
client.export(from, target, SVNRevision.HEAD, depth, eolStyle, force, ignoreExternals, handler);
}
catch (VcsException e) {
exception[0] = e;
}
}, message("message.title.export"), true, project);
if (exception[0] != null) {
@@ -225,46 +224,36 @@ public class SvnCheckoutProvider implements CheckoutProvider {
final SvnVcs vcs = SvnVcs.getInstance(project);
final String targetPath = FileUtil.toSystemIndependentName(target.getAbsolutePath());
ExclusiveBackgroundVcsAction.run(project, new Runnable() {
public void run() {
ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
public void run() {
final FileIndexFacade facade = PeriodicalTasksCloser.getInstance().safeGetService(project, FileIndexFacade.class);
ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator();
try {
progressIndicator.setText(message("progress.text.import", 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(new Computable<Boolean>() {
@Override
public Boolean compute() {
return 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);
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());
}
if (revision > 0) {
StatusBar.Info.set(message("status.text.comitted.revision", revision), project);
}
}, message("message.title.import"), true, project);
}
}
});
if (! errorMessage.isNull()) {
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"));
}
}
@@ -323,29 +312,23 @@ public class SvnCheckoutProvider implements CheckoutProvider {
final ModalityState dialogState = any();
dialog.startLoading();
getApplication().executeOnPooledThread(new Runnable() {
@Override
public void run() {
final List<WorkingCopyFormat> formats = loadSupportedFormats();
getApplication().executeOnPooledThread(() -> {
final List<WorkingCopyFormat> formats = loadSupportedFormats();
getApplication().invokeLater(new Runnable() {
@Override
public void run() {
final String errorMessage = error.get();
getApplication().invokeLater(() -> {
final String errorMessage = error.get();
if (errorMessage != null) {
dialog.doCancelAction();
showErrorDialog(message("message.text.cannot.load.supported.formats", errorMessage),
message("message.title.check.out"));
}
else {
dialog.setSupported(formats);
dialog.setData(getFirstItem(formats, UNKNOWN));
dialog.stopLoading();
}
}
}, dialogState);
}
if (errorMessage != null) {
dialog.doCancelAction();
showErrorDialog(message("message.text.cannot.load.supported.formats", errorMessage),
message("message.title.check.out"));
}
else {
dialog.setSupported(formats);
dialog.setData(getFirstItem(formats, UNKNOWN));
dialog.stopLoading();
}
}, dialogState);
});
return dialog.showAndGet() ? dialog.getUpgradeMode() : UNKNOWN;
@@ -1,7 +1,6 @@
package org.jetbrains.idea.svn.commandLine;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -116,12 +115,7 @@ public class Command {
@Nullable
public List<String> getTargetsPaths() {
return ContainerUtil.isEmpty(myTargets) ? null : ContainerUtil.map(myTargets, new Function<File, String>() {
@Override
public String fun(File file) {
return CommandUtil.format(file.getAbsolutePath(), null);
}
});
return ContainerUtil.isEmpty(myTargets) ? null : ContainerUtil.map(myTargets, file -> CommandUtil.format(file.getAbsolutePath(), null));
}
@Nullable
@@ -16,7 +16,6 @@
package org.jetbrains.idea.svn.commandLine;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.containers.ContainerUtil;
@@ -202,12 +201,7 @@ public class CommandRuntime {
authCases.add(new UsernamePasswordCallback(myAuthenticationService, url));
}
return ContainerUtil.find(authCases, new Condition<AuthCallbackCase>() {
@Override
public boolean value(AuthCallbackCase authCase) {
return authCase.canHandle(errText);
}
});
return ContainerUtil.find(authCases, authCase -> authCase.canHandle(errText));
}
private void cleanup(@NotNull CommandExecutor executor, @NotNull File workingDirectory) throws SvnBindException {
@@ -16,7 +16,6 @@
package org.jetbrains.idea.svn.commandLine;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
@@ -75,12 +74,7 @@ public class ProxyCallback extends AuthCallbackCase {
// TODO: This is quite messy logic for determining group for host - either ProxyCallback could be unified with ProxyModule
// TODO: or group name resolved in ProxyModule could be saved in Command instance.
// TODO: This will be done later after corresponding refactorings.
String proxyHostParameter = ContainerUtil.find(command.getParameters(), new Condition<String>() {
@Override
public boolean value(String s) {
return s.contains("http-proxy-port");
}
});
String proxyHostParameter = ContainerUtil.find(command.getParameters(), s -> s.contains("http-proxy-port"));
if (!StringUtil.isEmpty(proxyHostParameter) && myUrl != null && myProxyAuthentication != null) {
String group = getHostGroup(proxyHostParameter);
@@ -96,12 +96,7 @@ public class SvnBindException extends VcsException {
public boolean containsCategory(int category) {
final int categoryCode = getCategoryCode(category);
Condition<Integer> belongsToCategoryCondition = new Condition<Integer>() {
@Override
public boolean value(Integer code) {
return getCategoryCode(code) == categoryCode;
}
};
Condition<Integer> belongsToCategoryCondition = code -> getCategoryCode(code) == categoryCode;
return ContainerUtil.exists(errors.keySet(), belongsToCategoryCondition) ||
ContainerUtil.exists(warnings.keySet(), belongsToCategoryCondition);
@@ -90,13 +90,10 @@ public class TerminalSshModule extends BaseTerminalModule {
final Project project = myRuntime.getVcs().getProject();
final Ref<Integer> answer = new Ref<>();
Runnable command = new Runnable() {
@Override
public void run() {
final ServerSSHDialog dialog = new ServerSSHDialog(project, true, unknownHost, fingerprintAlgorithm, hostFingerprint);
dialog.show();
answer.set(dialog.getResult());
}
Runnable command = () -> {
final ServerSSHDialog dialog = new ServerSSHDialog(project, true, unknownHost, fingerprintAlgorithm, hostFingerprint);
dialog.show();
answer.set(dialog.getResult());
};
// Use ModalityState.any() as currently ssh credentials in terminal mode are requested in the thread that reads output and not in
@@ -20,7 +20,6 @@ import com.intellij.execution.process.ProcessWrapper;
import com.intellij.execution.util.ExecUtil;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -139,12 +138,7 @@ public class WinTerminalExecutor extends TerminalExecutor {
@NotNull
@Override
protected List<String> escapeArguments(@NotNull List<String> arguments) {
return ContainerUtil.map(arguments, new Function<String, String>() {
@Override
public String fun(String argument) {
return needQuote(argument) && !isQuoted(argument) ? quote(argument) : argument;
}
});
return ContainerUtil.map(arguments, argument -> needQuote(argument) && !isQuoted(argument) ? quote(argument) : argument);
}
@NotNull
@@ -22,11 +22,7 @@ import com.intellij.ui.InsertPathAction;
import org.jetbrains.idea.svn.SvnBundle;
import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.text.JTextComponent;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.util.ArrayList;
@@ -113,12 +109,10 @@ public class ConfigureProxiesOptionsPanel implements RepositoryUrlsListener {
initRepositories();
putPatternsListener();
myTestConnectionButton.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
final String value = (String) myRepositoriesList.getSelectedValue();
if ((value != null) && (myTestConnectionPerformer.enabled())) {
myTestConnectionPerformer.execute(value);
}
myTestConnectionButton.addActionListener(e -> {
final String value = (String)myRepositoriesList.getSelectedValue();
if ((value != null) && (myTestConnectionPerformer.enabled())) {
myTestConnectionPerformer.execute(value);
}
});
}
@@ -146,11 +140,8 @@ public class ConfigureProxiesOptionsPanel implements RepositoryUrlsListener {
final ListSelectionModel selectionModel = new DefaultListSelectionModel();
selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
myRepositoriesList.setSelectionModel(selectionModel);
myRepositoriesList.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(final ListSelectionEvent e) {
myTestConnectionButton.setEnabled(myTestConnectionPerformer.enabled() && (myRepositoriesList.getSelectedValue() != null));
}
});
myRepositoriesList.addListSelectionListener(
e -> myTestConnectionButton.setEnabled(myTestConnectionPerformer.enabled() && (myRepositoriesList.getSelectedValue() != null)));
}
private void fillMappings() {
@@ -21,7 +21,6 @@ import com.intellij.openapi.actionSystem.CommonShortcuts;
import com.intellij.openapi.actionSystem.CustomShortcutSet;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.ui.MasterDetailsComponent;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.Ref;
import com.intellij.util.IconUtil;
import com.intellij.util.PlatformIcons;
@@ -163,17 +162,15 @@ public class SvnConfigureProxiesComponent extends MasterDetailsComponent {
});
result.add(new MyDeleteAction(forAll(new Condition<Object>(){
public boolean value(final Object o) {
if (o instanceof MyNode) {
final MyNode node = (MyNode) o;
if (node.getConfigurable() instanceof GroupConfigurable) {
final ProxyGroup group = ((GroupConfigurable) node.getConfigurable()).getEditableObject();
return ! group.isDefault();
}
result.add(new MyDeleteAction(forAll(o -> {
if (o instanceof MyNode) {
final MyNode node = (MyNode)o;
if (node.getConfigurable() instanceof GroupConfigurable) {
final ProxyGroup group = ((GroupConfigurable)node.getConfigurable()).getEditableObject();
return !group.isDefault();
}
return false;
}
return false;
})) {
public void actionPerformed(final AnActionEvent e) {
final TreePath path = myTree.getSelectionPath();
@@ -65,7 +65,7 @@ public class SvnConfigureProxiesDialog extends DialogWrapper implements Validati
myTabbedPane.setSelectedComponent(component);
String errorPrefix = myTabbedPane.getTitleAt(myTabbedPane.indexOfComponent(component)) + ": ";
setOKActionEnabled(! forbidSave);
setOKActionEnabled(!forbidSave);
setInvalid(errorPrefix + text, myTabbedPane);
}
@@ -83,7 +83,8 @@ public class SvnConfigureProxiesDialog extends DialogWrapper implements Validati
private boolean applyToTab(final SvnConfigureProxiesComponent component) {
try {
component.apply();
} catch (ConfigurationException e) {
}
catch (ConfigurationException e) {
myTabbedPane.setSelectedComponent(component.createComponent());
setInvalid(e.getMessage(), myTabbedPane);
return false;
@@ -97,10 +98,10 @@ public class SvnConfigureProxiesDialog extends DialogWrapper implements Validati
}
private boolean applyImpl() {
if (! applyToTab(myUserTab)) {
if (!applyToTab(myUserTab)) {
return false;
}
if (! applyToTab(mySystemTab)) {
if (!applyToTab(mySystemTab)) {
return false;
}
return true;
@@ -108,7 +109,7 @@ public class SvnConfigureProxiesDialog extends DialogWrapper implements Validati
protected void doOKAction() {
if (getOKAction().isEnabled()) {
if(! applyImpl()) {
if (!applyImpl()) {
return;
}
myValidator.stop();
@@ -119,29 +120,28 @@ public class SvnConfigureProxiesDialog extends DialogWrapper implements Validati
public void execute(final String url) {
Messages.showInfoMessage(myProject, SvnBundle.message("dialog.edit.http.proxies.settings.test.connection.settings.will.be.stored.text"),
SvnBundle.message("dialog.edit.http.proxies.settings.test.connection.settings.will.be.stored.title"));
if(! applyImpl()) {
if (!applyImpl()) {
return;
}
final Ref<Exception> excRef = new Ref<>();
final ProgressManager pm = ProgressManager.getInstance();
pm.runProcessWithProgressSynchronously(new Runnable() {
public void run() {
final ProgressIndicator pi = pm.getProgressIndicator();
if (pi != null) {
pi.setText("Connecting to " + url);
}
try {
SvnVcs.getInstance(myProject).getInfo(SvnUtil.createUrl(url), SVNRevision.HEAD);
}
catch (SvnBindException e) {
excRef.set(e);
}
pm.runProcessWithProgressSynchronously(() -> {
final ProgressIndicator pi = pm.getProgressIndicator();
if (pi != null) {
pi.setText("Connecting to " + url);
}
try {
SvnVcs.getInstance(myProject).getInfo(SvnUtil.createUrl(url), SVNRevision.HEAD);
}
catch (SvnBindException e) {
excRef.set(e);
}
}, "Test connection", true, myProject);
if (! excRef.isNull()) {
if (!excRef.isNull()) {
Messages.showErrorDialog(myProject, excRef.get().getMessage(),
SvnBundle.message("dialog.edit.http.proxies.settings.test.connection.error.title"));
} else {
}
else {
Messages.showInfoMessage(myProject, SvnBundle.message("dialog.edit.http.proxies.settings.test.connection.succes.text"),
SvnBundle.message("dialog.edit.http.proxies.settings.test.connection.succes.title"));
}
@@ -25,9 +25,11 @@ import org.jetbrains.annotations.Nullable;
import org.jetbrains.idea.svn.commandLine.SvnBindException;
import javax.swing.*;
import java.awt.GridBagConstraints;
import java.awt.*;
import java.awt.event.*;
import java.awt.event.InputMethodEvent;
import java.awt.event.InputMethodListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.util.List;
import static com.intellij.util.containers.ContainerUtil.sorted;
@@ -107,11 +109,7 @@ public class AddRepositoryLocationDialog extends DialogWrapper {
}
});
myCombo.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
validateMe();
}
});
myCombo.addActionListener(e -> validateMe());
validateMe();
JPanel wrapper = new JPanel(new GridBagLayout());
@@ -21,8 +21,6 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.idea.svn.SvnBundle;
import javax.swing.*;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
public class CheckoutDialog extends RepositoryBrowserDialog {
private final CheckoutProvider.Listener myListener;
@@ -36,11 +34,9 @@ public class CheckoutDialog extends RepositoryBrowserDialog {
super.init();
setTitle(SvnBundle.message("checkout.dialog.title"));
setOKButtonText(SvnBundle.message("checkout.dialog.button"));
getRepositoryBrowser().addChangeListener(new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent e) {
if (getOKAction() != null) {
getOKAction().setEnabled(getRepositoryBrowser().getSelectedURL() != null);
}
getRepositoryBrowser().addChangeListener(e -> {
if (getOKAction() != null) {
getOKAction().setEnabled(getRepositoryBrowser().getSelectedURL() != null);
}
});
getOKAction().setEnabled(getRepositoryBrowser().getSelectedURL() != null);
@@ -17,7 +17,6 @@ package org.jetbrains.idea.svn.dialogs;
import com.intellij.ide.DataManager;
import com.intellij.notification.*;
import com.intellij.openapi.actionSystem.DataProvider;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
@@ -40,11 +39,9 @@ import com.intellij.ui.components.labels.LinkLabel;
import com.intellij.ui.components.labels.LinkListener;
import com.intellij.util.Consumer;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.Convertor;
import com.intellij.util.io.EqualityPolicy;
import com.intellij.util.messages.MessageBusConnection;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.idea.svn.*;
@@ -106,64 +103,42 @@ public class CopiesPanel {
myVcs = SvnVcs.getInstance(myProject);
myCurrentInfoList = null;
final Runnable focus = new Runnable() {
@Override
public void run() {
IdeFocusManager.getInstance(myProject).requestFocus(myRefreshLabel, true);
}
};
final Runnable refreshView = new Runnable() {
@Override
public void run() {
final List<WCInfo> infoList = myVcs.getWcInfosWithErrors();
final boolean hasErrors = !myVcs.getSvnFileUrlMapping().getErrorRoots().isEmpty();
final List<WorkingCopyFormat> supportedFormats = getSupportedFormats();
Runnable runnable = new Runnable() {
@Override
public void run() {
if (myCurrentInfoList != null) {
final List<OverrideEqualsWrapper<WCInfo>> newList =
ObjectsConvertor.convert(infoList, new Convertor<WCInfo, OverrideEqualsWrapper<WCInfo>>() {
@Override
public OverrideEqualsWrapper<WCInfo> convert(WCInfo o) {
return new OverrideEqualsWrapper<>(InfoEqualityPolicy.getInstance(), o);
}
}, ObjectsConvertor.NOT_NULL);
final Runnable focus = () -> IdeFocusManager.getInstance(myProject).requestFocus(myRefreshLabel, true);
final Runnable refreshView = () -> {
final List<WCInfo> infoList = myVcs.getWcInfosWithErrors();
final boolean hasErrors = !myVcs.getSvnFileUrlMapping().getErrorRoots().isEmpty();
final List<WorkingCopyFormat> supportedFormats = getSupportedFormats();
Runnable runnable = () -> {
if (myCurrentInfoList != null) {
final List<OverrideEqualsWrapper<WCInfo>> newList =
ObjectsConvertor
.convert(infoList, o -> new OverrideEqualsWrapper<>(InfoEqualityPolicy.getInstance(), o), ObjectsConvertor.NOT_NULL);
if (Comparing.haveEqualElements(newList, myCurrentInfoList)) {
myRefreshLabel.setEnabled(true);
return;
}
myCurrentInfoList = newList;
}
Collections.sort(infoList, WCComparator.getInstance());
updateList(infoList, supportedFormats);
if (Comparing.haveEqualElements(newList, myCurrentInfoList)) {
myRefreshLabel.setEnabled(true);
showErrorNotification(hasErrors);
SwingUtilities.invokeLater(focus);
return;
}
};
ApplicationManager.getApplication().invokeLater(runnable, ModalityState.NON_MODAL);
}
};
final Consumer<Boolean> refreshOnPooled = new Consumer<Boolean>() {
@Override
public void consume(Boolean somethingNew) {
if (Boolean.TRUE.equals(somethingNew)) {
if (ApplicationManager.getApplication().isUnitTestMode()) {
refreshView.run();
}
else {
ApplicationManager.getApplication().executeOnPooledThread(refreshView);
}
} else {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
myRefreshLabel.setEnabled(true);
}
}, ModalityState.NON_MODAL);
myCurrentInfoList = newList;
}
Collections.sort(infoList, WCComparator.getInstance());
updateList(infoList, supportedFormats);
myRefreshLabel.setEnabled(true);
showErrorNotification(hasErrors);
SwingUtilities.invokeLater(focus);
};
ApplicationManager.getApplication().invokeLater(runnable, ModalityState.NON_MODAL);
};
final Consumer<Boolean> refreshOnPooled = somethingNew -> {
if (Boolean.TRUE.equals(somethingNew)) {
if (ApplicationManager.getApplication().isUnitTestMode()) {
refreshView.run();
}
else {
ApplicationManager.getApplication().executeOnPooledThread(refreshView);
}
}
else {
ApplicationManager.getApplication().invokeLater(() -> myRefreshLabel.setEnabled(true), ModalityState.NON_MODAL);
}
};
myConnection.subscribe(SvnVcs.ROOTS_RELOADED, refreshOnPooled);
@@ -175,13 +150,10 @@ public class CopiesPanel {
final JPanel panel = new JPanel(new BorderLayout());
panel.add(myPanel, BorderLayout.NORTH);
holderPanel.add(panel, BorderLayout.WEST);
myRefreshLabel = new MyLinkLabel(myTextHeight, "Refresh", new LinkListener() {
@Override
public void linkSelected(LinkLabel aSource, Object aLinkData) {
if (myRefreshLabel.isEnabled()) {
myVcs.invokeRefreshSvnRoots();
myRefreshLabel.setEnabled(false);
}
myRefreshLabel = new MyLinkLabel(myTextHeight, "Refresh", (aSource, aLinkData) -> {
if (myRefreshLabel.isEnabled()) {
myVcs.invokeRefreshSvnRoots();
myRefreshLabel.setEnabled(false);
}
});
final JScrollPane pane = ScrollPaneFactory.createScrollPane(holderPanel);
@@ -361,17 +333,11 @@ public class CopiesPanel {
}
private void mergeFrom(@NotNull final WCInfo wcInfo, @NotNull final VirtualFile root, @Nullable final Component mergeLabel) {
SelectBranchPopup.showForBranchRoot(myProject, root, new SelectBranchPopup.BranchSelectedCallback() {
@Override
public void branchSelected(Project project,
@NotNull SvnBranchConfigurationNew configuration,
@NotNull String branchUrl,
long revision) {
String workingCopyUrlInSelectedBranch = getCorrespondingUrlInOtherBranch(configuration, wcInfo.getUrl(), branchUrl);
MergeContext mergeContext = new MergeContext(myVcs, workingCopyUrlInSelectedBranch, wcInfo, SVNPathUtil.tail(branchUrl), root);
SelectBranchPopup.showForBranchRoot(myProject, root, (project, configuration, branchUrl, revision) -> {
String workingCopyUrlInSelectedBranch = getCorrespondingUrlInOtherBranch(configuration, wcInfo.getUrl(), branchUrl);
MergeContext mergeContext = new MergeContext(myVcs, workingCopyUrlInSelectedBranch, wcInfo, SVNPathUtil.tail(branchUrl), root);
new QuickMerge(mergeContext, new QuickMergeInteractionImpl(mergeContext)).execute();
}
new QuickMerge(mergeContext, new QuickMergeInteractionImpl(mergeContext)).execute();
}, "Select branch", mergeLabel);
}
@@ -453,15 +419,11 @@ public class CopiesPanel {
}
private static void registerHelp(@NotNull JComponent component) {
DataManager.registerDataProvider(component, new DataProvider() {
@Nullable
@Override
public Object getData(@NonNls String dataId) {
if (PlatformDataKeys.HELP_ID.is(dataId)) {
return "reference.vcs.svn.working.copies.information";
}
return null;
DataManager.registerDataProvider(component, dataId -> {
if (PlatformDataKeys.HELP_ID.is(dataId)) {
return "reference.vcs.svn.working.copies.information";
}
return null;
});
}
@@ -21,8 +21,6 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.idea.svn.SvnBundle;
import javax.swing.*;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
public class ImportDialog extends RepositoryBrowserDialog {
public ImportDialog(Project project) {
@@ -33,11 +31,9 @@ public class ImportDialog extends RepositoryBrowserDialog {
super.init();
setTitle(SvnBundle.message("import.dialog.title"));
setOKButtonText(SvnBundle.message("import.dialog.button"));
getRepositoryBrowser().addChangeListener(new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent e) {
if (getOKAction() != null) {
updateOKAction();
}
getRepositoryBrowser().addChangeListener(e -> {
if (getOKAction() != null) {
updateOKAction();
}
});
updateOKAction();
@@ -46,8 +46,6 @@ import org.tmatesoft.svn.core.wc.SVNRevision;
import org.tmatesoft.svn.core.wc2.SvnTarget;
import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import java.awt.*;
@@ -96,19 +94,17 @@ public class PropertiesComponent extends JPanel {
myTable.setModel(model);
myTable.setShowVerticalLines(true);
myTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
myTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
int index = myTable.getSelectedRow();
if (index >= 0) {
Object value = myTable.getValueAt(index, 1);
if (value instanceof String) {
myTextArea.setText(((String) value));
} else {
myTextArea.setText("");
}
myTable.getSelectionModel().addListSelectionListener(e -> {
int index = myTable.getSelectedRow();
if (index >= 0) {
Object value = myTable.getValueAt(index, 1);
if (value instanceof String) {
myTextArea.setText(((String) value));
} else {
myTextArea.setText("");
}
} else {
myTextArea.setText("");
}
});
myPopupActionGroup = createPopup();
@@ -31,7 +31,6 @@ import com.intellij.ui.TreeSpeedSearch;
import com.intellij.ui.treeStructure.Tree;
import com.intellij.util.EditSourceOnDoubleClickHandler;
import com.intellij.util.NotNullFunction;
import com.intellij.util.containers.Convertor;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -99,7 +98,9 @@ public class RepositoryBrowserComponent extends JPanel implements Disposable, Da
}
}
public void setRepositoryURL(SVNURL url, boolean showFiles, final NotNullFunction<RepositoryBrowserComponent, Expander> defaultExpanderFactory) {
public void setRepositoryURL(SVNURL url,
boolean showFiles,
final NotNullFunction<RepositoryBrowserComponent, Expander> defaultExpanderFactory) {
RepositoryTreeModel model = new RepositoryTreeModel(myVCS, showFiles, this);
model.setDefaultExpanderFactory(defaultExpanderFactory);
@@ -121,7 +122,7 @@ public class RepositoryBrowserComponent extends JPanel implements Disposable, Da
}
public void expandNode(@NotNull final TreeNode treeNode) {
final TreeNode[] pathToNode = ((RepositoryTreeModel) myRepositoryTree.getModel()).getPathToRoot(treeNode);
final TreeNode[] pathToNode = ((RepositoryTreeModel)myRepositoryTree.getModel()).getPathToRoot(treeNode);
if ((pathToNode != null) && (pathToNode.length > 0)) {
final TreePath treePath = new TreePath(pathToNode);
@@ -130,7 +131,7 @@ public class RepositoryBrowserComponent extends JPanel implements Disposable, Da
}
public Collection<TreeNode> getExpandedSubTree(@NotNull final TreeNode treeNode) {
final TreeNode[] pathToNode = ((RepositoryTreeModel) myRepositoryTree.getModel()).getPathToRoot(treeNode);
final TreeNode[] pathToNode = ((RepositoryTreeModel)myRepositoryTree.getModel()).getPathToRoot(treeNode);
final Enumeration<TreePath> expanded = myRepositoryTree.getExpandedDescendants(new TreePath(pathToNode));
@@ -138,30 +139,32 @@ public class RepositoryBrowserComponent extends JPanel implements Disposable, Da
if (expanded != null) {
while (expanded.hasMoreElements()) {
final TreePath treePath = expanded.nextElement();
result.add((TreeNode) treePath.getLastPathComponent());
result.add((TreeNode)treePath.getLastPathComponent());
}
}
return result;
}
public boolean isExpanded(@NotNull final TreeNode treeNode) {
final TreeNode[] pathToNode = ((RepositoryTreeModel) myRepositoryTree.getModel()).getPathToRoot(treeNode);
final TreeNode[] pathToNode = ((RepositoryTreeModel)myRepositoryTree.getModel()).getPathToRoot(treeNode);
return (pathToNode != null) && (pathToNode.length > 0) && myRepositoryTree.isExpanded(new TreePath(pathToNode));
}
public void addURL(String url) {
try {
((RepositoryTreeModel) myRepositoryTree.getModel()).addRoot(SVNURL.parseURIEncoded(url));
} catch (SVNException e) {
((RepositoryTreeModel)myRepositoryTree.getModel()).addRoot(SVNURL.parseURIEncoded(url));
}
catch (SVNException e) {
//
}
}
public void removeURL(String url) {
try {
((RepositoryTreeModel) myRepositoryTree.getModel()).removeRoot(SVNURL.parseURIEncoded(url));
} catch (SVNException e) {
((RepositoryTreeModel)myRepositoryTree.getModel()).removeRoot(SVNURL.parseURIEncoded(url));
}
catch (SVNException e) {
//
}
}
@@ -174,7 +177,7 @@ public class RepositoryBrowserComponent extends JPanel implements Disposable, Da
}
Object element = selection.getLastPathComponent();
if (element instanceof RepositoryTreeNode) {
RepositoryTreeNode node = (RepositoryTreeNode) element;
RepositoryTreeNode node = (RepositoryTreeNode)element;
return node.getSVNDirEntry();
}
return null;
@@ -194,7 +197,7 @@ public class RepositoryBrowserComponent extends JPanel implements Disposable, Da
}
Object element = selection.getLastPathComponent();
if (element instanceof RepositoryTreeNode) {
RepositoryTreeNode node = (RepositoryTreeNode) element;
RepositoryTreeNode node = (RepositoryTreeNode)element;
return node.getURL();
}
return null;
@@ -222,15 +225,12 @@ public class RepositoryBrowserComponent extends JPanel implements Disposable, Da
ScrollPaneFactory.createScrollPane(myRepositoryTree, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
add(scrollPane, BorderLayout.CENTER);
myRepositoryTree.setCellRenderer(new SvnRepositoryTreeCellRenderer());
TreeSpeedSearch search = new TreeSpeedSearch(myRepositoryTree, new Convertor<TreePath, String>() {
@Override
public String convert(TreePath o) {
Object component = o.getLastPathComponent();
if (component instanceof RepositoryTreeNode) {
return ((RepositoryTreeNode)component).getURL().toDecodedString();
}
return null;
TreeSpeedSearch search = new TreeSpeedSearch(myRepositoryTree, o -> {
Object component = o.getLastPathComponent();
if (component instanceof RepositoryTreeNode) {
return ((RepositoryTreeNode)component).getURL().toDecodedString();
}
return null;
});
search.setComparator(new SpeedSearchComparator(false, true));
@@ -241,13 +241,13 @@ public class RepositoryBrowserComponent extends JPanel implements Disposable, Da
public RepositoryTreeNode getSelectedNode() {
TreePath selection = myRepositoryTree.getSelectionPath();
if (selection != null && selection.getLastPathComponent() instanceof RepositoryTreeNode) {
return (RepositoryTreeNode) selection.getLastPathComponent();
return (RepositoryTreeNode)selection.getLastPathComponent();
}
return null;
}
public void setSelectedNode(@NotNull final TreeNode node) {
final TreeNode[] pathNodes = ((RepositoryTreeModel) myRepositoryTree.getModel()).getPathToRoot(node);
final TreeNode[] pathNodes = ((RepositoryTreeModel)myRepositoryTree.getModel()).getPathToRoot(node);
myRepositoryTree.setSelectionPath(new TreePath(pathNodes));
}
@@ -267,10 +267,11 @@ public class RepositoryBrowserComponent extends JPanel implements Disposable, Da
if (entry.getName().lastIndexOf('.') > 0 && !manager.getFileTypeByFileName(name).isBinary()) {
SVNURL url = node.getURL();
final SvnFileRevision revision = new SvnFileRevision(myVCS, SVNRevision.UNDEFINED, SVNRevision.HEAD, url.toString(),
entry.getAuthor(), entry.getDate(), null, null);
entry.getAuthor(), entry.getDate(), null, null);
return new VcsVirtualFile(node.getSVNDirEntry().getName(), revision, VcsFileSystem.getInstance());
} else {
}
else {
return null;
}
}
@@ -295,7 +296,8 @@ public class RepositoryBrowserComponent extends JPanel implements Disposable, Da
navigate(project, vcsFile, requestFocus);
}
} : null;
} else if (CommonDataKeys.PROJECT.is(dataId)) {
}
else if (CommonDataKeys.PROJECT.is(dataId)) {
return myVCS.getProject();
}
return null;
@@ -305,6 +307,6 @@ public class RepositoryBrowserComponent extends JPanel implements Disposable, Da
}
public void setLazyLoadingExpander(final NotNullFunction<RepositoryBrowserComponent, Expander> expanderFactory) {
((RepositoryTreeModel) myRepositoryTree.getModel()).setDefaultExpanderFactory(expanderFactory);
((RepositoryTreeModel)myRepositoryTree.getModel()).setDefaultExpanderFactory(expanderFactory);
}
}
@@ -575,31 +575,24 @@ public class RepositoryBrowserDialog extends DialogWrapper {
boolean cancelable;
if (dialog.isUnifiedDiff()) {
final File targetFile = dialog.getTargetFile();
command = new Runnable() {
public void run() {
targetFile.getParentFile().mkdirs();
doUnifiedDiff(targetFile, sURL, tURL);
}
command = () -> {
targetFile.getParentFile().mkdirs();
doUnifiedDiff(targetFile, sURL, tURL);
};
cancelable = false;
}
else {
command = new Runnable() {
public void run() {
try {
doGraphicalDiff(sURL, tURL);
}
catch (final VcsException ex) {
//noinspection InstanceofCatchParameter
boolean isCancelled = ex instanceof SvnBindException && ((SvnBindException)ex).contains(SVNErrorCode.CANCELLED);
command = () -> {
try {
doGraphicalDiff(sURL, tURL);
}
catch (final VcsException ex) {
//noinspection InstanceofCatchParameter
boolean isCancelled = ex instanceof SvnBindException && ((SvnBindException)ex).contains(SVNErrorCode.CANCELLED);
if (!isCancelled) {
WaitForProgressToShow.runOrInvokeLaterAboveProgress(new Runnable() {
public void run() {
Messages.showErrorDialog(myProject, ex.getMessage(), "Error");
}
}, null, myProject);
}
if (!isCancelled) {
WaitForProgressToShow
.runOrInvokeLaterAboveProgress(() -> Messages.showErrorDialog(myProject, ex.getMessage(), "Error"), null, myProject);
}
}
};
@@ -800,19 +793,17 @@ public class RepositoryBrowserDialog extends DialogWrapper {
private boolean doDelete(final SVNURL url, final String comment) {
final Ref<Exception> exception = new Ref<>();
final Project project = myBrowserComponent.getProject();
Runnable command = new Runnable() {
public void run() {
ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
if (progress != null) {
progress.setText(SvnBundle.message("progres.text.deleting", url.toString()));
}
SvnVcs vcs = SvnVcs.getInstance(project);
try {
vcs.getFactoryFromSettings().createDeleteClient().delete(url, comment);
}
catch (VcsException e) {
exception.set(e);
}
Runnable command = () -> {
ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
if (progress != null) {
progress.setText(SvnBundle.message("progres.text.deleting", url.toString()));
}
SvnVcs vcs = SvnVcs.getInstance(project);
try {
vcs.getFactoryFromSettings().createDeleteClient().delete(url, comment);
}
catch (VcsException e) {
exception.set(e);
}
};
ProgressManager.getInstance().runProcessWithProgressSynchronously(command, SvnBundle.message("progress.title.browser.delete"), false, project);
@@ -970,20 +961,18 @@ public class RepositoryBrowserDialog extends DialogWrapper {
protected static void doMkdir(final SVNURL url, final String comment, final Project project) {
final Ref<Exception> exception = new Ref<>();
Runnable command = new Runnable() {
public void run() {
ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
if (progress != null) {
progress.setText(SvnBundle.message("progress.text.browser.creating", url.toString()));
}
SvnVcs vcs = SvnVcs.getInstance(project);
SvnTarget target = SvnTarget.fromURL(url);
try {
vcs.getFactoryFromSettings().createBrowseClient().createDirectory(target, comment, false);
}
catch (VcsException e) {
exception.set(e);
}
Runnable command = () -> {
ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
if (progress != null) {
progress.setText(SvnBundle.message("progress.text.browser.creating", url.toString()));
}
SvnVcs vcs = SvnVcs.getInstance(project);
SvnTarget target = SvnTarget.fromURL(url);
try {
vcs.getFactoryFromSettings().createBrowseClient().createDirectory(target, comment, false);
}
catch (VcsException e) {
exception.set(e);
}
};
ProgressManager.getInstance().runProcessWithProgressSynchronously(command, SvnBundle.message("progress.text.create.remote.folder"), false, project);
@@ -994,21 +983,20 @@ public class RepositoryBrowserDialog extends DialogWrapper {
private void doCopy(final SVNURL src, final SVNURL dst, final boolean move, final String comment) {
final Ref<Exception> exception = new Ref<>();
Runnable command = new Runnable() {
public void run() {
ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
if (progress != null) {
progress.setText((move ? SvnBundle.message("progress.text.browser.moving", src) : SvnBundle.message("progress.text.browser.copying", src)));
progress.setText2(SvnBundle.message("progress.text.browser.remote.destination", dst));
}
SvnVcs vcs = SvnVcs.getInstance(myProject);
try {
vcs.getFactoryFromSettings().createCopyMoveClient().copy(SvnTarget.fromURL(src), SvnTarget.fromURL(dst), SVNRevision.HEAD, true,
move, comment, null);
}
catch (VcsException e) {
exception.set(e);
}
Runnable command = () -> {
ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
if (progress != null) {
progress.setText(
(move ? SvnBundle.message("progress.text.browser.moving", src) : SvnBundle.message("progress.text.browser.copying", src)));
progress.setText2(SvnBundle.message("progress.text.browser.remote.destination", dst));
}
SvnVcs vcs = SvnVcs.getInstance(myProject);
try {
vcs.getFactoryFromSettings().createCopyMoveClient().copy(SvnTarget.fromURL(src), SvnTarget.fromURL(dst), SVNRevision.HEAD, true,
move, comment, null);
}
catch (VcsException e) {
exception.set(e);
}
};
String progressTitle = move ? SvnBundle.message("progress.title.browser.move") : SvnBundle.message("progress.title.browser.copy");
@@ -1118,12 +1106,10 @@ public class RepositoryBrowserDialog extends DialogWrapper {
private void showDiffEditorResults(final Collection<Change> changes, String sourceTitle, String targetTitle) {
final String title = SvnBundle.message("repository.browser.compare.title", sourceTitle, targetTitle);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
final ChangeListViewerDialog dlg = new ChangeListViewerDialog(myRepositoryBrowser, myProject, changes, true);
dlg.setTitle(title);
dlg.show();
}
SwingUtilities.invokeLater(() -> {
final ChangeListViewerDialog dlg = new ChangeListViewerDialog(myRepositoryBrowser, myProject, changes, true);
dlg.setTitle(title);
dlg.show();
});
}
@@ -21,7 +21,10 @@ import org.tmatesoft.svn.core.SVNURL;
import javax.swing.tree.TreeNode;
import java.text.Collator;
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;
public class RepositoryTreeRootNode implements TreeNode, Disposable {
private final List<TreeNode> myChildren;
@@ -36,22 +39,14 @@ public class RepositoryTreeRootNode implements TreeNode, Disposable {
Disposer.register(this, rootNode);
myChildren.add(rootNode);
}
Collections.sort(myChildren, new Comparator<TreeNode>() {
public int compare(TreeNode o1, TreeNode o2) {
return Collator.getInstance().compare(o1.toString(), o2.toString());
}
});
Collections.sort(myChildren, (o1, o2) -> Collator.getInstance().compare(o1.toString(), o2.toString()));
}
public void addRoot(SVNURL url) {
RepositoryTreeNode rootNode = new RepositoryTreeNode(myModel, this, url, url);
Disposer.register(this, rootNode);
myChildren.add(rootNode);
Collections.sort(myChildren, new Comparator<TreeNode>() {
public int compare(TreeNode o1, TreeNode o2) {
return Collator.getInstance().compare(o1.toString(), o2.toString());
}
});
Collections.sort(myChildren, (o1, o2) -> Collator.getInstance().compare(o1.toString(), o2.toString()));
myModel.nodesWereInserted(this, new int[]{myChildren.indexOf(rootNode)});
}
@@ -27,7 +27,6 @@ import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.ui.components.JBRadioButton;
import com.intellij.util.Consumer;
import com.intellij.util.SystemProperties;
import com.intellij.util.ui.JBUI;
import com.intellij.util.ui.UIUtil;
@@ -47,7 +46,6 @@ import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.io.File;
import java.io.IOException;
import java.util.List;
/**
* @author alex
@@ -441,16 +439,13 @@ public class SSHCredentialsDialog extends DialogWrapper implements ActionListene
.withHideIgnored(false)
.withShowHiddenFiles(true);
FileChooser.chooseFiles(descriptor, myProject, file, new Consumer<List<VirtualFile>>() {
@Override
public void consume(List<VirtualFile> files) {
if (files.size() == 1) {
path[0] = FileUtil.toSystemDependentName(files.get(0).getPath());
myKeyFileText.setText(path[0]);
}
checkKeyFile();
updateOKButton();
FileChooser.chooseFiles(descriptor, myProject, file, files -> {
if (files.size() == 1) {
path[0] = FileUtil.toSystemDependentName(files.get(0).getPath());
myKeyFileText.setText(path[0]);
}
checkKeyFile();
updateOKButton();
});
}
}
@@ -27,8 +27,6 @@ import org.jetbrains.annotations.NotNull;
import org.tmatesoft.svn.core.internal.util.SVNPathUtil;
import javax.swing.*;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import java.awt.*;
import java.awt.event.*;
import java.util.Set;
@@ -65,15 +63,13 @@ public class SelectCreateExternalTargetDialog extends RepositoryBrowserDialog {
myFollowRemoteTarget = true;
setTitle("Select Target For External");
setOKButtonText("Select");
getRepositoryBrowser().addChangeListener(new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent e) {
if (getOKAction() != null) {
final String selectedURL = getRepositoryBrowser().getSelectedURL();
if (myFollowRemoteTarget && selectedURL != null) {
myFolderName.setText(SVNPathUtil.tail(selectedURL));
}
checkEnabled();
getRepositoryBrowser().addChangeListener(e -> {
if (getOKAction() != null) {
final String selectedURL = getRepositoryBrowser().getSelectedURL();
if (myFollowRemoteTarget && selectedURL != null) {
myFolderName.setText(SVNPathUtil.tail(selectedURL));
}
checkEnabled();
}
});
getOKAction().setEnabled(getRepositoryBrowser().getSelectedURL() != null);
@@ -178,12 +174,7 @@ public class SelectCreateExternalTargetDialog extends RepositoryBrowserDialog {
});
final JCheckBox checkout = new JCheckBox("Checkout");
checkout.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
myCheckout = checkout.isSelected();
}
});
checkout.addActionListener(e -> myCheckout = checkout.isSelected());
wrapper.add(checkout, gb);
return wrapper;
}
@@ -19,7 +19,6 @@ import com.intellij.openapi.help.HelpManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.ui.OrderPanel;
import com.intellij.ui.OrderPanelListener;
import com.intellij.ui.ScrollPaneFactory;
import com.intellij.util.ArrayUtil;
import org.jetbrains.annotations.NonNls;
@@ -79,11 +78,7 @@ public class SelectFilesDialog extends DialogWrapper implements ActionListener {
mySelectAllButton.addActionListener(this);
myDeselectAllButton.addActionListener(this);
myFilesList.addListener(new OrderPanelListener() {
public void entryMoved() {
getOKAction().setEnabled(isOKActionEnabled());
}
});
myFilesList.addListener(() -> getOKAction().setEnabled(isOKActionEnabled()));
}
protected String getDimensionServiceKey() {
@@ -41,8 +41,6 @@ import org.tmatesoft.svn.core.internal.util.SVNPathUtil;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import java.awt.*;
import static com.intellij.openapi.util.Pair.create;
@@ -142,16 +140,15 @@ public class SelectLocationDialog extends DialogWrapper {
final Ref<SVNURL> result = new Ref<>();
final Ref<SvnBindException> excRef = new Ref<>();
ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
public void run() {
try {
result.set(SvnUtil.getRepositoryRoot(SvnVcs.getInstance(project), url));
} catch (SvnBindException e) {
excRef.set(e);
}
ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> {
try {
result.set(SvnUtil.getRepositoryRoot(SvnVcs.getInstance(project), url));
}
catch (SvnBindException e) {
excRef.set(e);
}
}, "Detecting repository root", true, project);
if (! excRef.isNull()) {
if (!excRef.isNull()) {
throw excRef.get();
}
return result.get();
@@ -167,11 +164,7 @@ public class SelectLocationDialog extends DialogWrapper {
else {
myRepositoryBrowser.setRepositoryURL(myURL, myIsShowFiles, new UrlOpeningExpander.Factory(urlString, urlString));
}
myRepositoryBrowser.addChangeListener(new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent e) {
getOKAction().setEnabled(isOKActionEnabled());
}
});
myRepositoryBrowser.addChangeListener(e -> getOKAction().setEnabled(isOKActionEnabled()));
}
@Override
@@ -17,9 +17,7 @@ package org.jetbrains.idea.svn.dialogs;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.Function;
import com.intellij.util.ObjectUtils;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
@@ -66,19 +64,9 @@ public class SetKeywordsDialog extends DialogWrapper {
@Nullable
public String getKeywords() {
List<JCheckBox> selectedKeywords = ContainerUtil.filter(myKeywordOptions, new Condition<JCheckBox>() {
@Override
public boolean value(@NotNull JCheckBox keywordOption) {
return keywordOption.isSelected();
}
});
List<JCheckBox> selectedKeywords = ContainerUtil.filter(myKeywordOptions, keywordOption -> keywordOption.isSelected());
return StringUtil.nullize(StringUtil.join(selectedKeywords, new Function<JCheckBox, String>() {
@Override
public String fun(@NotNull JCheckBox keywordOption) {
return keywordOption.getText();
}
}, " "));
return StringUtil.nullize(StringUtil.join(selectedKeywords, keywordOption -> keywordOption.getText(), " "));
}
@Nullable
@@ -38,12 +38,9 @@ import org.tmatesoft.svn.core.wc.SVNRevision;
import org.tmatesoft.svn.core.wc2.SvnTarget;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.io.File;
import java.util.Collection;
import java.util.TreeSet;
@@ -126,13 +123,11 @@ public class SetPropertyDialog extends DialogWrapper {
else {
myPropertyNameBox.getEditor().setItem("");
}
myPropertyNameBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
String name = getPropertyName();
updatePropertyValue(name);
getOKAction().setEnabled(name != null && !"".equals(name.trim()));
}
myPropertyNameBox.addItemListener(e -> {
if (e.getStateChange() == ItemEvent.SELECTED) {
String name = getPropertyName();
updatePropertyValue(name);
getOKAction().setEnabled(name != null && !"".equals(name.trim()));
}
});
Component editor = myPropertyNameBox.getEditor().getEditorComponent();
@@ -188,14 +183,12 @@ public class SetPropertyDialog extends DialogWrapper {
myPropertyNameBox.getEditor().setItem(myPropertyName);
myPropertyNameBox.getEditor().selectAll();
}
mySetPropertyButton.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
if (mySetPropertyButton.isSelected()) {
myValueText.setEnabled(true);
}
else {
myValueText.setEnabled(false);
}
mySetPropertyButton.addChangeListener(e -> {
if (mySetPropertyButton.isSelected()) {
myValueText.setEnabled(true);
}
else {
myValueText.setEnabled(false);
}
});
myRecursiveButton.setEnabled(myIsRecursionAllowed);
@@ -29,10 +29,6 @@ import com.intellij.util.ui.JBUI;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import java.awt.*;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
@@ -69,13 +65,11 @@ public class ShareDialog extends RepositoryBrowserDialog {
super.init();
setTitle("Select Share Target");
setOKButtonText("Share");
getRepositoryBrowser().addChangeListener(new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent e) {
if (getOKAction() != null) {
final String selectedURL = getRepositoryBrowser().getSelectedURL();
updateOptionsTexts(selectedURL);
getOKAction().setEnabled(selectedURL != null);
}
getRepositoryBrowser().addChangeListener(e -> {
if (getOKAction() != null) {
final String selectedURL = getRepositoryBrowser().getSelectedURL();
updateOptionsTexts(selectedURL);
getOKAction().setEnabled(selectedURL != null);
}
});
getOKAction().setEnabled(getRepositoryBrowser().getSelectedURL() != null);
@@ -229,12 +223,7 @@ public class ShareDialog extends RepositoryBrowserDialog {
gb.insets.top = 5;
panel.add(myTrunk, gb);
myCreateStandard = new JCheckBox("Create /tags and /branches");
myTrunk.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
myCreateStandard.setEnabled(myTrunk.isSelected());
}
});
myTrunk.addChangeListener(e -> myCreateStandard.setEnabled(myTrunk.isSelected()));
myCreateStandard.setSelected(true);
++ gb.gridy;
gb.insets.top = 0;
@@ -35,8 +35,6 @@ import org.jetbrains.idea.svn.commandLine.SshTunnelRuntimeModule;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
@@ -75,12 +73,9 @@ public class SshSettingsPanel implements ConfigurableUi<SvnConfiguration> {
register(myPrivateKeyChoice, SvnConfiguration.SshConnectionType.PRIVATE_KEY);
register(mySubversionConfigChoice, SvnConfiguration.SshConnectionType.SUBVERSION_CONFIG);
ItemListener connectionTypeChangedListener = new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
enableOptions(e.getSource());
}
ItemListener connectionTypeChangedListener = e -> {
if (e.getStateChange() == ItemEvent.SELECTED) {
enableOptions(e.getSource());
}
};
myPasswordChoice.addItemListener(connectionTypeChangedListener);
@@ -100,15 +95,12 @@ public class SshSettingsPanel implements ConfigurableUi<SvnConfiguration> {
}
});
myUpdateTunnelButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String tunnel = mySshTunnelField.getText();
myUpdateTunnelButton.addActionListener(e -> {
String tunnel = mySshTunnelField.getText();
// remove tunnel from config in case it is null or empty
mySvnConfiguration.setSshTunnelSetting(StringUtil.nullize(tunnel));
setSshTunnelSetting(mySvnConfiguration.getSshTunnelSetting());
}
// remove tunnel from config in case it is null or empty
mySvnConfiguration.setSshTunnelSetting(StringUtil.nullize(tunnel));
setSshTunnelSetting(mySvnConfiguration.getSshTunnelSetting());
});
}
@@ -32,16 +32,11 @@ import org.jetbrains.idea.svn.DepthCombo;
import org.jetbrains.idea.svn.SvnBundle;
import org.jetbrains.idea.svn.api.Depth;
import org.jetbrains.idea.svn.revision.SvnSelectRevisionPanel;
import org.jetbrains.idea.svn.update.SvnRevisionPanel;
import org.tmatesoft.svn.core.SVNURL;
import org.tmatesoft.svn.core.wc.SVNRevision;
import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
@@ -68,35 +63,25 @@ public class CheckoutOptionsDialog extends DialogWrapper {
fillTargetList(target);
validateTargetSelected();
mySelectTarget.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
// choose directory here/
FileChooserDescriptor fcd = FileChooserDescriptorFactory.createSingleFolderDescriptor();
fcd.setShowFileSystemRoots(true);
fcd.setTitle(SvnBundle.message("checkout.directory.chooser.title"));
fcd.setDescription(SvnBundle.message("checkout.directory.chooser.prompt"));
fcd.setHideIgnored(false);
VirtualFile file = FileChooser.chooseFile(fcd, getContentPane(), project, null);
if (file == null) {
return;
}
fillTargetList(new File(file.getPath()));
validateTargetSelected();
}
});
myLocalTargetList.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(final ListSelectionEvent e) {
validateTargetSelected();
mySelectTarget.addActionListener(e -> {
// choose directory here/
FileChooserDescriptor fcd = FileChooserDescriptorFactory.createSingleFolderDescriptor();
fcd.setShowFileSystemRoots(true);
fcd.setTitle(SvnBundle.message("checkout.directory.chooser.title"));
fcd.setDescription(SvnBundle.message("checkout.directory.chooser.prompt"));
fcd.setHideIgnored(false);
VirtualFile file = FileChooser.chooseFile(fcd, getContentPane(), project, null);
if (file == null) {
return;
}
fillTargetList(new File(file.getPath()));
validateTargetSelected();
});
myLocalTargetList.addListSelectionListener(e -> validateTargetSelected());
svnSelectRevisionPanel.setRoot(root);
svnSelectRevisionPanel.setProject(project);
svnSelectRevisionPanel.setUrlProvider(new SvnRevisionPanel.UrlProvider() {
public String getUrl() {
return urlText;
}
});
svnSelectRevisionPanel.setUrlProvider(() -> urlText);
setTitle(SvnBundle.message("checkout.options.dialog.title"));
myDepthLabel.setLabelFor(myDepthCombo);
@@ -43,12 +43,8 @@ import org.tmatesoft.svn.core.internal.util.SVNPathUtil;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.TreeNode;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Collections;
@@ -87,11 +83,7 @@ public class CopyOptionsDialog extends DialogWrapper {
myBrowser.setRepositoryURL(root.getURL(), false,
new OpeningExpander.Factory(subPath, (RepositoryTreeNode)((node.getParent() instanceof RepositoryTreeNode) ? node.getParent() : null)));
myBrowser.addChangeListener(new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent e) {
update();
}
});
myBrowser.addChangeListener(e -> update());
myNameField.setText(SVNPathUtil.tail(myURL.getPath()));
myNameField.selectAll();
@@ -112,13 +104,11 @@ public class CopyOptionsDialog extends DialogWrapper {
myCommitMessage.setText(lastMessage);
myCommitMessage.selectAll();
}
myMessagesBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
final Object item = myMessagesBox.getSelectedItem();
if (item != null) {
myCommitMessage.setText(item.toString());
myCommitMessage.selectAll();
}
myMessagesBox.addActionListener(e -> {
final Object item = myMessagesBox.getSelectedItem();
if (item != null) {
myCommitMessage.setText(item.toString());
myCommitMessage.selectAll();
}
});
Disposer.register(getDisposable(), myBrowser);
@@ -26,8 +26,6 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Collections;
@@ -105,12 +103,9 @@ public class DeleteOptionsDialog extends DialogWrapper {
myCommitMessage.setText(lastMessage);
myCommitMessage.selectAll();
}
messagesBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
myCommitMessage.setText(messagesBox.getSelectedItem().toString());
myCommitMessage.selectAll();
}
messagesBox.addActionListener(e -> {
myCommitMessage.setText(messagesBox.getSelectedItem().toString());
myCommitMessage.selectAll();
});
return panel;
}
@@ -41,8 +41,6 @@ import org.tmatesoft.svn.core.SVNURL;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
@@ -71,23 +69,17 @@ public class DiffOptionsDialog extends DialogWrapper implements ActionListener {
setTitle(SvnBundle.message("diff.options.title"));
mySourceUrlLabel.setText(myURL.toString());
myBrowser.setRepositoryURL(myRootURL, false);
myBrowser.addChangeListener(new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent e) {
update();
}
});
myBrowser.addChangeListener(e -> update());
myUIDiffButton.addActionListener(this);
myUnifiedDiffButton.addActionListener(this);
init();
myFileBrowser.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
File f = selectFile("Patch File", "Select file to store unified diff");
if (f != null) {
if (f.exists() && f.isDirectory()) {
f = new File(f, DEFAULT_PATCH_NAME);
}
myFileBrowser.setText(f.getAbsolutePath());
myFileBrowser.addActionListener(e -> {
File f = selectFile("Patch File", "Select file to store unified diff");
if (f != null) {
if (f.exists() && f.isDirectory()) {
f = new File(f, DEFAULT_PATCH_NAME);
}
myFileBrowser.setText(f.getAbsolutePath());
}
});
myFileBrowser.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
@@ -179,12 +179,9 @@ public class ImportOptionsDialog extends DialogWrapper implements ActionListener
myCommitMessage.setText(lastMessage);
myCommitMessage.selectAll();
}
messagesBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
myCommitMessage.setText(messagesBox.getSelectedItem().toString());
myCommitMessage.selectAll();
}
messagesBox.addActionListener(e -> {
myCommitMessage.setText(messagesBox.getSelectedItem().toString());
myCommitMessage.selectAll();
});
return panel;
}
@@ -27,8 +27,6 @@ import org.tmatesoft.svn.core.SVNURL;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Collections;
@@ -79,11 +77,9 @@ public class MkdirOptionsDialog extends DialogWrapper {
myCommitMessage.setText(lastMessage);
myCommitMessage.selectAll();
}
myMessagesBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
myCommitMessage.setText(myMessagesBox.getSelectedItem().toString());
myCommitMessage.selectAll();
}
myMessagesBox.addActionListener(e -> {
myCommitMessage.setText(myMessagesBox.getSelectedItem().toString());
myCommitMessage.selectAll();
});
}
@@ -37,21 +37,19 @@ public class CacheLoader extends Loader {
}
public void load(@NotNull final RepositoryTreeNode node, @NotNull final Expander expander) {
SwingUtilities.invokeLater(new Runnable(){
public void run() {
final String nodeUrl = node.getURL().toString();
SwingUtilities.invokeLater(() -> {
final String nodeUrl = node.getURL().toString();
final List<DirectoryEntry> cached = myCache.getChildren(nodeUrl);
if (cached != null) {
refreshNode(node, cached, expander);
}
final String error = myCache.getError(nodeUrl);
if (error != null) {
refreshNodeError(node, error);
}
// refresh anyway
myRepositoryLoader.load(node, expander);
final List<DirectoryEntry> cached = myCache.getChildren(nodeUrl);
if (cached != null) {
refreshNode(node, cached, expander);
}
final String error = myCache.getError(nodeUrl);
if (error != null) {
refreshNodeError(node, error);
}
// refresh anyway
myRepositoryLoader.load(node, expander);
});
}
@@ -29,7 +29,6 @@ import org.jetbrains.idea.svn.auth.SvnAuthenticationProvider;
import org.jetbrains.idea.svn.browse.DirectoryEntry;
import org.jetbrains.idea.svn.browse.DirectoryEntryConsumer;
import org.jetbrains.idea.svn.dialogs.RepositoryTreeNode;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.wc.SVNRevision;
import org.tmatesoft.svn.core.wc2.SvnTarget;
@@ -91,12 +90,8 @@ class RepositoryLoader extends Loader {
private void startLoadTask(@NotNull final Pair<RepositoryTreeNode, Expander> data) {
final ModalityState state = ModalityState.current();
ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
@Override
public void run() {
ProgressManager.getInstance().runProcess(new LoadTask(data), new EmptyProgressIndicator(state));
}
});
ApplicationManager.getApplication()
.executeOnPooledThread(() -> ProgressManager.getInstance().runProcess(new LoadTask(data), new EmptyProgressIndicator(state)));
}
@NotNull
@@ -118,34 +113,24 @@ class RepositoryLoader extends Loader {
final SvnVcs vcs = node.getVcs();
SvnAuthenticationProvider.forceInteractive();
DirectoryEntryConsumer handler = new DirectoryEntryConsumer() {
@Override
public void consume(final DirectoryEntry entry) throws SVNException {
entries.add(entry);
}
};
DirectoryEntryConsumer handler = entry -> entries.add(entry);
try {
SvnTarget target = SvnTarget.fromURL(node.getURL());
vcs.getFactoryFromSettings().createBrowseClient().list(target, SVNRevision.HEAD, Depth.IMMEDIATES, handler);
}
catch (final VcsException e) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
setError(myData, e.getMessage());
startNext();
}
SwingUtilities.invokeLater(() -> {
setError(myData, e.getMessage());
startNext();
});
return;
} finally {
SvnAuthenticationProvider.clearInteractive();
}
SwingUtilities.invokeLater(new Runnable() {
public void run() {
setResults(myData, ContainerUtil.newArrayList(entries));
startNext();
}
SwingUtilities.invokeLater(() -> {
setResults(myData, ContainerUtil.newArrayList(entries));
startNext();
});
}
}
@@ -141,23 +141,16 @@ public abstract class ElementWithBranchComparer {
}
protected void reportGeneralException(final Exception e) {
WaitForProgressToShow.runOrInvokeLaterAboveProgress(new Runnable() {
public void run() {
Messages.showMessageDialog(myProject, e.getMessage(),
SvnBundle.message("compare.with.branch.error.title"), Messages.getErrorIcon());
}
}, null, myProject);
WaitForProgressToShow.runOrInvokeLaterAboveProgress(
() -> Messages
.showMessageDialog(myProject, e.getMessage(), SvnBundle.message("compare.with.branch.error.title"), Messages.getErrorIcon()), null,
myProject);
LOG.info(e);
}
private void reportNotFound() {
WaitForProgressToShow.runOrInvokeLaterAboveProgress(new Runnable() {
public void run() {
Messages.showMessageDialog(myProject,
SvnBundle
.message("compare.with.branch.location.error", myVirtualFile.getPresentableUrl(), myBranchUrl),
SvnBundle.message("compare.with.branch.error.title"), Messages.getErrorIcon());
}
}, null, myProject);
WaitForProgressToShow.runOrInvokeLaterAboveProgress(() -> Messages
.showMessageDialog(myProject, SvnBundle.message("compare.with.branch.location.error", myVirtualFile.getPresentableUrl(), myBranchUrl),
SvnBundle.message("compare.with.branch.error.title"), Messages.getErrorIcon()), null, myProject);
}
}
@@ -34,8 +34,6 @@ import org.tmatesoft.svn.core.internal.wc.admin.SVNWCAccess;
import org.tmatesoft.svn.core.internal.wc17.SVNReporter17;
import org.tmatesoft.svn.core.internal.wc17.SVNWCContext;
import org.tmatesoft.svn.core.io.ISVNEditor;
import org.tmatesoft.svn.core.io.ISVNReporter;
import org.tmatesoft.svn.core.io.ISVNReporterBaton;
import org.tmatesoft.svn.core.io.SVNRepository;
import org.tmatesoft.svn.core.wc.ISVNEventHandler;
import org.tmatesoft.svn.core.wc.SVNEvent;
@@ -125,11 +123,9 @@ public class SvnKitDiffClient extends BaseSvnClient implements DiffClient {
targetRepository = myVcs.getSvnKitManager().createRepository(myTarget2.getURL());
diffEditor = new SvnDiffEditor(sourceRepository, targetRepository, -1, false);
final ISVNEditor cancellableEditor = SVNCancellableEditor.newInstance(diffEditor, new SvnKitProgressCanceller(), null);
sourceRepository.diff(myTarget2.getURL(), rev, rev, null, true, true, false, new ISVNReporterBaton() {
public void report(ISVNReporter reporter) throws SVNException {
reporter.setPath("", null, rev, false);
reporter.finishReport();
}
sourceRepository.diff(myTarget2.getURL(), rev, rev, null, true, true, false, reporter -> {
reporter.setPath("", null, rev, false);
reporter.finishReport();
}, cancellableEditor);
return diffEditor.getChangesMap().values();
@@ -30,7 +30,6 @@ import com.intellij.ui.components.panels.Wrapper;
import com.intellij.util.containers.HashMap;
import com.intellij.util.ui.JBUI;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.idea.svn.difftool.SvnDiffSettingsHolder.SvnDiffSettings;
@@ -97,15 +96,12 @@ public class SvnDiffViewer implements DiffViewer {
myPanel = new JPanel(new BorderLayout());
myPanel.add(mySplitter, BorderLayout.CENTER);
myPanel.add(myNotificationPanel, BorderLayout.SOUTH);
DataManager.registerDataProvider(myPanel, new DataProvider() {
@Override
public Object getData(@NonNls String dataId) {
DataProvider propertiesDataProvider = DataManagerImpl.getDataProviderEx(myPropertiesViewer.getComponent());
DataProvider contentDataProvider = DataManagerImpl.getDataProviderEx(myContentViewer.getComponent());
DataProvider defaultDP = myPropertiesViewerFocused ? propertiesDataProvider : contentDataProvider;
DataProvider fallbackDP = myPropertiesViewerFocused ? contentDataProvider : propertiesDataProvider;
return DiffUtil.getData(defaultDP, fallbackDP, dataId);
}
DataManager.registerDataProvider(myPanel, dataId -> {
DataProvider propertiesDataProvider = DataManagerImpl.getDataProviderEx(myPropertiesViewer.getComponent());
DataProvider contentDataProvider = DataManagerImpl.getDataProviderEx(myContentViewer.getComponent());
DataProvider defaultDP = myPropertiesViewerFocused ? propertiesDataProvider : contentDataProvider;
DataProvider fallbackDP = myPropertiesViewerFocused ? contentDataProvider : propertiesDataProvider;
return DiffUtil.getData(defaultDP, fallbackDP, dataId);
});
updatePropertiesPanel();
@@ -44,8 +44,10 @@ import org.jetbrains.idea.svn.properties.PropertyValue;
import javax.swing.*;
import java.awt.*;
import java.awt.geom.AffineTransform;
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
public class SvnPropertiesDiffViewer extends TwosideTextDiffViewer {
@NotNull private final WrapperRequest myWrapperRequest;
@@ -135,13 +137,10 @@ public class SvnPropertiesDiffViewer extends TwosideTextDiffViewer {
}
}
return new Runnable() {
@Override
public void run() {
for (DiffChange change : myDiffChanges) {
setupHighlighting(change, Side.LEFT);
setupHighlighting(change, Side.RIGHT);
}
return () -> {
for (DiffChange change : myDiffChanges) {
setupHighlighting(change, Side.LEFT);
setupHighlighting(change, Side.RIGHT);
}
};
}
@@ -384,12 +383,7 @@ public class SvnPropertiesDiffViewer extends TwosideTextDiffViewer {
records.add(createRecord(name, before.get(name), after.get(name)));
}
ContainerUtil.sort(records, new Comparator<PropertyRecord>() {
@Override
public int compare(PropertyRecord o1, PropertyRecord o2) {
return StringUtil.naturalCompare(o1.getName(), o2.getName());
}
});
ContainerUtil.sort(records, (o1, o2) -> StringUtil.naturalCompare(o1.getName(), o2.getName()));
return records;
}
@@ -27,7 +27,10 @@ import org.jetbrains.idea.svn.SvnUtil;
import org.jetbrains.idea.svn.SvnVcs;
import org.jetbrains.idea.svn.commandLine.SvnBindException;
import org.jetbrains.idea.svn.info.Info;
import org.tmatesoft.svn.core.*;
import org.tmatesoft.svn.core.SVNErrorCode;
import org.tmatesoft.svn.core.SVNErrorMessage;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNURL;
import org.tmatesoft.svn.core.internal.util.SVNURLUtil;
import org.tmatesoft.svn.core.wc.SVNRevision;
import org.tmatesoft.svn.core.wc2.SvnTarget;
@@ -94,16 +97,13 @@ public class LatestExistentSearcher {
@NotNull
private LogEntryConsumer createHandler(@NotNull final Ref<Long> latest) {
return new LogEntryConsumer() {
@Override
public void consume(final LogEntry logEntry) throws SVNException {
final Map changedPaths = logEntry.getChangedPaths();
for (Object o : changedPaths.values()) {
final LogEntryPath path = (LogEntryPath)o;
if ((path.getType() == 'D') && (myRelativeUrl.equals(path.getPath()))) {
latest.set(logEntry.getRevision());
throw new SVNException(SVNErrorMessage.UNKNOWN_ERROR_MESSAGE);
}
return logEntry -> {
final Map changedPaths = logEntry.getChangedPaths();
for (Object o : changedPaths.values()) {
final LogEntryPath path = (LogEntryPath)o;
if ((path.getType() == 'D') && (myRelativeUrl.equals(path.getPath()))) {
latest.set(logEntry.getRevision());
throw new SVNException(SVNErrorMessage.UNKNOWN_ERROR_MESSAGE);
}
}
};
@@ -79,15 +79,13 @@ public class LiveProvider implements BunchProvider {
final Ref<List<CommittedChangeList>> refToList = new Ref<>();
final Ref<VcsException> exceptionRef = new Ref<>();
final Runnable loader = new Runnable() {
public void run() {
try {
refToList.set(
myLoader.loadInterval(youngRevision, SVNRevision.create(oldestRevision), desirableSize, includeYoungest, includeOldest));
}
catch (VcsException e) {
exceptionRef.set(e);
}
final Runnable loader = () -> {
try {
refToList
.set(myLoader.loadInterval(youngRevision, SVNRevision.create(oldestRevision), desirableSize, includeYoungest, includeOldest));
}
catch (VcsException e) {
exceptionRef.set(e);
}
};
@@ -95,14 +93,12 @@ public class LiveProvider implements BunchProvider {
if (application.isUnitTestMode() || ! application.isDispatchThread()) {
loader.run();
} else {
ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
public void run() {
final ProgressIndicator ind = ProgressManager.getInstance().getProgressIndicator();
if (ind != null) {
ind.setText(SvnBundle.message("progress.live.provider.loading.revisions.details.text"));
}
loader.run();
ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> {
final ProgressIndicator ind = ProgressManager.getInstance().getProgressIndicator();
if (ind != null) {
ind.setText(SvnBundle.message("progress.live.provider.loading.revisions.details.text"));
}
loader.run();
}, SvnBundle.message("progress.live.provider.loading.revisions.text"), false, myVcs.getProject());
}
@@ -54,11 +54,9 @@ public class LoadedRevisionsCache implements Disposable {
@Override
public void changesLoaded(final RepositoryLocation location, final List<CommittedChangeList> changes) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
public void run() {
myMap.clear();
setRefreshTime(System.currentTimeMillis());
}
ApplicationManager.getApplication().invokeLater(() -> {
myMap.clear();
setRefreshTime(System.currentTimeMillis());
});
}
});
@@ -18,11 +18,8 @@ package org.jetbrains.idea.svn.history;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.ZipperUpdater;
import com.intellij.openapi.vcs.VcsListener;
import com.intellij.openapi.vcs.changes.committed.CommittedChangesTreeBrowser;
import com.intellij.openapi.vcs.changes.committed.VcsConfigurationChangeListener;
import com.intellij.openapi.vcs.versionBrowser.CommittedChangeList;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.Consumer;
import com.intellij.util.messages.MessageBusConnection;
import org.jetbrains.annotations.NotNull;
@@ -54,35 +51,19 @@ public class MergeInfoUpdatesListener {
myMergeInfoRefreshActions = new ArrayList<>();
myMergeInfoRefreshActions.add(action);
myConnection.subscribe(VcsConfigurationChangeListener.BRANCHES_CHANGED, new VcsConfigurationChangeListener.Notification() {
public void execute(final Project project, final VirtualFile vcsRoot) {
callReloadMergeInfo();
}
});
final Consumer<Boolean> reloadConsumer = new Consumer<Boolean>() {
@Override
public void consume(Boolean aBoolean) {
if (Boolean.TRUE.equals(aBoolean)) {
callReloadMergeInfo();
}
}
};
final Runnable reloadRunnable = new Runnable() {
@Override
public void run() {
myConnection.subscribe(VcsConfigurationChangeListener.BRANCHES_CHANGED, (project, vcsRoot) -> callReloadMergeInfo());
final Consumer<Boolean> reloadConsumer = aBoolean -> {
if (Boolean.TRUE.equals(aBoolean)) {
callReloadMergeInfo();
}
};
final Runnable reloadRunnable = () -> callReloadMergeInfo();
myConnection.subscribe(SvnVcs.WC_CONVERTED, reloadRunnable);
myConnection.subscribe(RootsAndBranches.REFRESH_REQUEST, reloadRunnable);
myConnection.subscribe(SvnVcs.ROOTS_RELOADED, reloadConsumer);
myConnection.subscribe(VCS_CONFIGURATION_CHANGED, new VcsListener() {
public void directoryMappingChanged() {
callReloadMergeInfo();
}
});
myConnection.subscribe(VCS_CONFIGURATION_CHANGED, () -> callReloadMergeInfo());
myConnection.subscribe(CommittedChangesTreeBrowser.ITEMS_RELOADED, new CommittedChangesTreeBrowser.CommittedChangesReloadListener() {
public void itemsReloaded() {
@@ -92,44 +73,25 @@ public class MergeInfoUpdatesListener {
}
});
myConnection.subscribe(SvnMergeInfoCache.SVN_MERGE_INFO_CACHE, new SvnMergeInfoCache.SvnMergeInfoCacheListener() {
public void copyRevisionUpdated() {
doForEachInitialized(new Consumer<RootsAndBranches>() {
public void consume(final RootsAndBranches rootsAndBranches) {
rootsAndBranches.fireRepaint();
}
});
}
});
myConnection
.subscribe(SvnMergeInfoCache.SVN_MERGE_INFO_CACHE, () -> doForEachInitialized(rootsAndBranches -> rootsAndBranches.fireRepaint()));
myConnection.subscribe(Merger.COMMITTED_CHANGES_MERGED_STATE, new Merger.CommittedChangesMergedStateChanged() {
public void event(final List<CommittedChangeList> list) {
doForEachInitialized(new Consumer<RootsAndBranches>() {
public void consume(RootsAndBranches rootsAndBranches) {
rootsAndBranches.refreshByLists(list);
}
});
}
});
myConnection.subscribe(Merger.COMMITTED_CHANGES_MERGED_STATE,
list -> doForEachInitialized(rootsAndBranches -> rootsAndBranches.refreshByLists(list)));
} else {
myMergeInfoRefreshActions.add(action);
}
}
private void doForEachInitialized(final Consumer<RootsAndBranches> consumer) {
myUpdater.queue(new Runnable() {
public void run() {
for (final RootsAndBranches action : myMergeInfoRefreshActions) {
if (action.strategyInitialized()) {
if (ApplicationManager.getApplication().isDispatchThread()) {
consumer.consume(action);
} else {
ApplicationManager.getApplication().invokeLater(new Runnable() {
public void run() {
consumer.consume(action);
}
});
}
myUpdater.queue(() -> {
for (final RootsAndBranches action : myMergeInfoRefreshActions) {
if (action.strategyInitialized()) {
if (ApplicationManager.getApplication().isDispatchThread()) {
consumer.consume(action);
}
else {
ApplicationManager.getApplication().invokeLater(() -> consumer.consume(action));
}
}
}
@@ -137,11 +99,9 @@ public class MergeInfoUpdatesListener {
}
private void callReloadMergeInfo() {
doForEachInitialized(new Consumer<RootsAndBranches>() {
public void consume(final RootsAndBranches rootsAndBranches) {
rootsAndBranches.reloadPanels();
rootsAndBranches.refresh();
}
doForEachInitialized(rootsAndBranches -> {
rootsAndBranches.reloadPanels();
rootsAndBranches.refresh();
});
}
@@ -28,7 +28,6 @@ import com.intellij.openapi.vcs.RepositoryLocation;
import com.intellij.openapi.vcs.changes.committed.*;
import com.intellij.openapi.vcs.versionBrowser.CommittedChangeList;
import com.intellij.ui.ScrollPaneFactory;
import com.intellij.util.NotNullFunction;
import com.intellij.util.messages.Topic;
import com.intellij.util.ui.JBUI;
import icons.SvnIcons;
@@ -121,7 +120,7 @@ public class RootsAndBranches implements CommittedChangeListDecorator {
new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.NORTH, GridBagConstraints.NONE, JBUI.insets(1), 0, 0);
gb.insets = JBUI.insets(20, 1, 1, 1);
myPanel.add(new JLabel("Loading..."), gb);
myPanel.setPreferredSize(JBUI.size(200, 60));
myManager.install(this);
@@ -148,16 +147,14 @@ public class RootsAndBranches implements CommittedChangeListDecorator {
final WCInfoWithBranches wcInfo = entry.getValue().getWcInfo();
states.put(Couple.of(localPath, wcInfo.getUrl().toString()), entry.getValue().getInfo());
}
createPanels(myLocation, new Runnable() {
public void run() {
for (Map.Entry<String, SvnMergeInfoRootPanelManual> entry : myMergePanels.entrySet()) {
final String localPath = entry.getKey();
final WCInfoWithBranches wcInfo = entry.getValue().getWcInfo();
final Couple<String> key = Couple.of(localPath, wcInfo.getUrl().toString());
final SvnMergeInfoRootPanelManual.InfoHolder infoHolder = states.get(key);
if (infoHolder != null) {
entry.getValue().initSelection(infoHolder);
}
createPanels(myLocation, () -> {
for (Map.Entry<String, SvnMergeInfoRootPanelManual> entry : myMergePanels.entrySet()) {
final String localPath = entry.getKey();
final WCInfoWithBranches wcInfo = entry.getValue().getWcInfo();
final Couple<String> key = Couple.of(localPath, wcInfo.getUrl().toString());
final SvnMergeInfoRootPanelManual.InfoHolder infoHolder = states.get(key);
if (infoHolder != null) {
entry.getValue().initSelection(infoHolder);
}
}
});
@@ -185,7 +182,7 @@ public class RootsAndBranches implements CommittedChangeListDecorator {
final ListMergeStatus status = getStatus(list, false);
return (status == null) ? ListMergeStatus.ALIEN.getIcon() : status.getIcon();
}
private void createPanels(final RepositoryLocation location, final Runnable afterRefresh) {
final Task.Backgroundable backgroundable = new Task.Backgroundable(myProject, "Subversion: loading working copies data..", false) {
public void run(@NotNull final ProgressIndicator indicator) {
@@ -193,40 +190,43 @@ public class RootsAndBranches implements CommittedChangeListDecorator {
final Map<String, SvnMergeInfoRootPanelManual> panels = new HashMap<>();
final Map<String, MergeInfoHolder> holders = new HashMap<>();
final List<WCInfoWithBranches> roots = myDataLoader.loadRoots();
SwingUtilities.invokeLater(new Runnable() {
public void run() {
if (myDisposed) return;
final JPanel mainPanel = prepareData(panels, holders, roots);
SwingUtilities.invokeLater(() -> {
if (myDisposed) return;
final JPanel mainPanel = prepareData(panels, holders, roots);
myMergePanels.clear();
myHolders.clear();
myMergePanels.putAll(panels);
myHolders.putAll(holders);
if (myPanelWrapper != null) {
myPanelWrapper.removeAll();
if (myMergePanels.isEmpty()) {
final JPanel emptyPanel = new JPanel(new GridBagLayout());
final GridBagConstraints gb =
new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0);
final JLabel label = new JLabel("No Subversion 1.5 working copies\nof 1.5 repositories in the project");
label.setUI(new MultiLineLabelUI());
emptyPanel.add(label, gb);
gb.fill = GridBagConstraints.HORIZONTAL;
myPanelWrapper.add(emptyPanel, gb);
} else {
for (MergeInfoHolder holder : myHolders.values()) {
holder.updateMixedRevisionsForPanel();
}
myPanelWrapper.add(mainPanel, new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
myMergePanels.clear();
myHolders.clear();
myMergePanels.putAll(panels);
myHolders.putAll(holders);
if (myPanelWrapper != null) {
myPanelWrapper.removeAll();
if (myMergePanels.isEmpty()) {
final JPanel emptyPanel = new JPanel(new GridBagLayout());
final GridBagConstraints gb =
new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0,
0);
final JLabel label = new JLabel("No Subversion 1.5 working copies\nof 1.5 repositories in the project");
label.setUI(new MultiLineLabelUI());
emptyPanel.add(label, gb);
gb.fill = GridBagConstraints.HORIZONTAL;
myPanelWrapper.add(emptyPanel, gb);
}
else {
for (MergeInfoHolder holder : myHolders.values()) {
holder.updateMixedRevisionsForPanel();
}
myPanelWrapper.repaint();
} else {
myPanel = mainPanel;
}
if (afterRefresh != null) {
afterRefresh.run();
myPanelWrapper.add(mainPanel,
new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL,
new Insets(0, 0, 0, 0), 0, 0));
}
myPanelWrapper.repaint();
}
else {
myPanel = mainPanel;
}
if (afterRefresh != null) {
afterRefresh.run();
}
});
}
@@ -235,8 +235,8 @@ public class RootsAndBranches implements CommittedChangeListDecorator {
}
public void refreshByLists(final List<CommittedChangeList> committedChangeLists) {
if (! committedChangeLists.isEmpty()) {
final SvnChangeList svnList = (SvnChangeList) committedChangeLists.get(0);
if (!committedChangeLists.isEmpty()) {
final SvnChangeList svnList = (SvnChangeList)committedChangeLists.get(0);
final String wcPath = svnList.getWcPath();
if (wcPath != null) {
final MergeInfoHolder holder = getHolder(wcPath);
@@ -255,52 +255,47 @@ public class RootsAndBranches implements CommittedChangeListDecorator {
private JPanel prepareData(final Map<String, SvnMergeInfoRootPanelManual> panels, final Map<String, MergeInfoHolder> holders,
List<WCInfoWithBranches> roots) {
final JPanel mainPanel = new JPanel(new GridBagLayout());
boolean onlyOneRoot = roots.size() == 1;
final GridBagConstraints gb = new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL,
new Insets(0,0,0,0), 0, 0);
mainPanel.add(myToolbarComponent, gb);
++ gb.gridy;
final JPanel mainPanel = new JPanel(new GridBagLayout());
boolean onlyOneRoot = roots.size() == 1;
final GridBagConstraints gb = new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL,
new Insets(0, 0, 0, 0), 0, 0);
mainPanel.add(myToolbarComponent, gb);
++gb.gridy;
for (final WCInfoWithBranches root : roots) {
if (root == null) {
continue;
for (final WCInfoWithBranches root : roots) {
if (root == null) {
continue;
}
final SvnMergeInfoRootPanelManual panel = new SvnMergeInfoRootPanelManual(myProject, wcInfoWithBranches -> {
final WCInfoWithBranches newInfo =
myDataLoader.reloadInfo(wcInfoWithBranches);
if (newInfo == null) {
// reload all items
myProject.getMessageBus()
.syncPublisher(SvnVcs.WC_CONVERTED).run();
// do not reload right now
return wcInfoWithBranches;
}
final SvnMergeInfoRootPanelManual panel = new SvnMergeInfoRootPanelManual(myProject,
new NotNullFunction<WCInfoWithBranches, WCInfoWithBranches>() {
@NotNull
public WCInfoWithBranches fun(@NotNull WCInfoWithBranches wcInfoWithBranches) {
final WCInfoWithBranches newInfo =
myDataLoader.reloadInfo(wcInfoWithBranches);
if (newInfo == null) {
// reload all items
myProject.getMessageBus().syncPublisher(SvnVcs.WC_CONVERTED).run();
// do not reload right now
return wcInfoWithBranches;
}
return newInfo;
}
}, new Runnable() {
public void run() {
final MergeInfoHolder holder = getHolder(root.getPath());
if (holder != null) {
holder.refresh(false);
}
}
}, onlyOneRoot, root);
panels.put(root.getPath(), panel);
holders.put(root.getPath(), createHolder(panel));
return newInfo;
}, () -> {
final MergeInfoHolder holder = getHolder(root.getPath());
if (holder != null) {
holder.refresh(false);
}
}, onlyOneRoot, root);
panels.put(root.getPath(), panel);
holders.put(root.getPath(), createHolder(panel));
final JPanel contentPanel = panel.getContentPanel();
mainPanel.add(contentPanel, gb);
++ gb.gridy;
final JPanel contentPanel = panel.getContentPanel();
mainPanel.add(contentPanel, gb);
++gb.gridy;
}
if (panels.size() == 1) {
for (SvnMergeInfoRootPanelManual panel : panels.values()) {
panel.setOnlyOneRoot(true);
}
if (panels.size() == 1) {
for (SvnMergeInfoRootPanelManual panel : panels.values()) {
panel.setOnlyOneRoot(true);
}
}
return mainPanel;
}
return mainPanel;
}
private DefaultActionGroup createActions() {
@@ -355,14 +350,14 @@ public class RootsAndBranches implements CommittedChangeListDecorator {
}
}
if (! refreshers.isEmpty()) {
if (!refreshers.isEmpty()) {
myManager.reportLoadedLists(new CommittedChangeListsListener() {
public void onBeforeStartReport() {
}
public boolean report(final CommittedChangeList list) {
if (list instanceof SvnChangeList) {
final SvnChangeList svnList = (SvnChangeList) list;
final SvnChangeList svnList = (SvnChangeList)list;
final String wcPath = svnList.getWcPath();
if (wcPath != null) {
final CommittedChangeListsListener refresher = refreshers.get(ensureEndsWithSeparator(wcPath));
@@ -428,7 +423,8 @@ public class RootsAndBranches implements CommittedChangeListDecorator {
public void setSelected(final AnActionEvent e, final boolean state) {
if (state) {
turnFromHereHighlighting();
} else {
}
else {
turnOff();
}
}
@@ -485,7 +481,7 @@ public class RootsAndBranches implements CommittedChangeListDecorator {
return false;
}
for (CommittedChangeList list : listsList) {
if (! mergeEnabled(list, forMerge)) {
if (!mergeEnabled(list, forMerge)) {
return false;
}
}
@@ -496,7 +492,8 @@ public class RootsAndBranches implements CommittedChangeListDecorator {
final ListMergeStatus mergeStatus = getStatus(list, true);
if ((mergeStatus == null) || (ListMergeStatus.ALIEN.equals(mergeStatus))) {
return false;
} else if (ListMergeStatus.REFRESHING.equals(mergeStatus)) {
}
else if (ListMergeStatus.REFRESHING.equals(mergeStatus)) {
return true;
}
if (forMerge) {
@@ -535,7 +532,7 @@ public class RootsAndBranches implements CommittedChangeListDecorator {
presentation.setDescription(myDescription);
presentation.setEnabled(presentation.isEnabled() && mergeEnabled(checker.getSelectedLists(), myMarkAsMerged));
}
@Nullable
protected String getSelectedBranchUrl(SelectedCommittedStuffChecker checker) {
final SvnMergeInfoRootPanelManual data = getPanelData(checker.getSelectedLists());
@@ -617,10 +614,10 @@ public class RootsAndBranches implements CommittedChangeListDecorator {
private SvnMergeInfoRootPanelManual getPanelData(final List<CommittedChangeList> listsList) {
for (CommittedChangeList list : listsList) {
if (! (list instanceof SvnChangeList)) {
if (!(list instanceof SvnChangeList)) {
return null;
}
final SvnChangeList svnList = (SvnChangeList) list;
final SvnChangeList svnList = (SvnChangeList)list;
final String wcPath = svnList.getWcPath();
if (wcPath == null) {
continue;
@@ -632,11 +629,11 @@ public class RootsAndBranches implements CommittedChangeListDecorator {
@Nullable
public ListMergeStatus getStatus(final CommittedChangeList list, final boolean ignoreEnabled) {
if (! (list instanceof SvnChangeList)) {
if (!(list instanceof SvnChangeList)) {
return null;
}
final SvnChangeList svnList = (SvnChangeList) list;
final SvnChangeList svnList = (SvnChangeList)list;
final String wcPath = svnList.getWcPath();
MergeInfoHolder holder = null;
if (wcPath == null) {
@@ -647,7 +644,8 @@ public class RootsAndBranches implements CommittedChangeListDecorator {
holder = getHolder(entry.getKey());
}
}
} else {
}
else {
holder = getHolder(wcPath);
}
if (holder != null) {
@@ -679,7 +677,7 @@ public class RootsAndBranches implements CommittedChangeListDecorator {
}
public JComponent getFilterUI() {
if (! myInitialized) {
if (!myInitialized) {
createPanels(myLocation, null);
}
myInitialized = true;
@@ -710,7 +708,7 @@ public class RootsAndBranches implements CommittedChangeListDecorator {
@NotNull
public List<CommittedChangeList> filterChangeLists(final List<CommittedChangeList> changeLists) {
if ((! myFilterAlien.isSelected(null)) && (! myFilterNotMerged.isSelected(null)) && (! myFilterMerged.isSelected(null))) {
if ((!myFilterAlien.isSelected(null)) && (!myFilterNotMerged.isSelected(null)) && (!myFilterMerged.isSelected(null))) {
return changeLists;
}
@@ -719,17 +717,20 @@ public class RootsAndBranches implements CommittedChangeListDecorator {
final ListMergeStatus status = getStatus(list, true);
if (ListMergeStatus.REFRESHING.equals(status)) {
result.add(list);
} else if ((status == null) || ListMergeStatus.ALIEN.equals(status)) {
if (! myFilterAlien.isSelected(null)) {
}
else if ((status == null) || ListMergeStatus.ALIEN.equals(status)) {
if (!myFilterAlien.isSelected(null)) {
result.add(list);
}
} else if (ListMergeStatus.MERGED.equals(status) || ListMergeStatus.COMMON.equals(status)) {
if (! myFilterMerged.isSelected(null)) {
}
else if (ListMergeStatus.MERGED.equals(status) || ListMergeStatus.COMMON.equals(status)) {
if (!myFilterMerged.isSelected(null)) {
result.add(list);
}
} else {
}
else {
// not merged
if (! myFilterNotMerged.isSelected(null)) {
if (!myFilterNotMerged.isSelected(null)) {
result.add(list);
}
}
@@ -128,20 +128,17 @@ public class SingleCommittedListProvider {
final SvnCopyPathTracker pathTracker = new SvnCopyPathTracker(repositoryUrl.toDecodedString(), repositoryRelativeUrl);
SvnTarget target = SvnTarget.fromURL(url);
myVcs.getFactory(target).createHistoryClient().doLog(target, SVNRevision.HEAD, revisionBefore, false, true, false, 0, null,
new LogEntryConsumer() {
@Override
public void consume(LogEntry logEntry) {
checkDisposed();
// date could be null for lists where there are paths that user has no rights to observe
if (logEntry.getDate() != null) {
pathTracker.accept(logEntry);
if (logEntry.getRevision() == revisionBefore.getNumber()) {
changeList[0] = createChangeList(logEntry);
}
}
myVcs.getFactory(target).createHistoryClient()
.doLog(target, SVNRevision.HEAD, revisionBefore, false, true, false, 0, null, logEntry -> {
checkDisposed();
// date could be null for lists where there are paths that user has no rights to observe
if (logEntry.getDate() != null) {
pathTracker.accept(logEntry);
if (logEntry.getRevision() == revisionBefore.getNumber()) {
changeList[0] = createChangeList(logEntry);
}
}
}
);
FilePath path = pathTracker.getFilePath(myVcs);
@@ -160,14 +157,11 @@ public class SingleCommittedListProvider {
}
private boolean searchForUrl(@NotNull SVNURL url) throws VcsException {
LogEntryConsumer handler = new LogEntryConsumer() {
@Override
public void consume(LogEntry logEntry) {
checkDisposed();
// date could be null for lists where there are paths that user has no rights to observe
if (logEntry.getDate() != null) {
changeList[0] = createChangeList(logEntry);
}
LogEntryConsumer handler = logEntry -> {
checkDisposed();
// date could be null for lists where there are paths that user has no rights to observe
if (logEntry.getDate() != null) {
changeList[0] = createChangeList(logEntry);
}
};
@@ -42,8 +42,6 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.idea.svn.*;
import org.jetbrains.idea.svn.api.Depth;
import org.jetbrains.idea.svn.browse.DirectoryEntry;
import org.jetbrains.idea.svn.browse.DirectoryEntryConsumer;
import org.jetbrains.idea.svn.commandLine.SvnBindException;
import org.jetbrains.idea.svn.info.Info;
import org.tmatesoft.svn.core.SVNException;
@@ -359,14 +357,11 @@ public class SvnChangeList implements CommittedChangeList, VcsRevisionNumberAwar
public SvnRepositoryContentRevision createRevisionLazily(final String path, final boolean isBeforeRevision) {
final boolean knownAsDirectory = myKnownAsDirectories.contains(path);
final FilePath localPath = getLocalPath(path, new NotNullFunction<File, Boolean>() {
@NotNull
public Boolean fun(final File file) {
if (knownAsDirectory) return Boolean.TRUE;
// list will be next
myWithoutDirStatus.add(new Pair<>(myList.size(), isBeforeRevision));
return Boolean.FALSE;
}
final FilePath localPath = getLocalPath(path, file -> {
if (knownAsDirectory) return Boolean.TRUE;
// list will be next
myWithoutDirStatus.add(new Pair<>(myList.size(), isBeforeRevision));
return Boolean.FALSE;
});
long revision = getRevision(isBeforeRevision);
return localPath == null
@@ -489,16 +484,12 @@ public class SvnChangeList implements CommittedChangeList, VcsRevisionNumberAwar
SVNRevision revisionNumber = SVNRevision.create(getRevision(isBefore));
SvnTarget target = SvnTarget.fromURL(fullPath, revisionNumber);
myVcs.getFactory(target).createBrowseClient().list(target, revisionNumber, Depth.INFINITY, new DirectoryEntryConsumer() {
myVcs.getFactory(target).createBrowseClient().list(target, revisionNumber, Depth.INFINITY, entry -> {
final String childPath = path + '/' + entry.getRelativePath();
@Override
public void consume(final DirectoryEntry entry) throws SVNException {
final String childPath = path + '/' + entry.getRelativePath();
if (!duplicates.contains(Pair.create(isBefore, childPath))) {
final ContentRevision contentRevision = createRevision(childPath, isBefore, entry.isDirectory());
result.add(new Change(isBefore ? contentRevision : null, isBefore ? null : contentRevision));
}
if (!duplicates.contains(Pair.create(isBefore, childPath))) {
final ContentRevision contentRevision1 = createRevision(childPath, isBefore, entry.isDirectory());
result.add(new Change(isBefore ? contentRevision1 : null, isBefore ? null : contentRevision1));
}
});
@@ -44,8 +44,6 @@ import org.jetbrains.idea.svn.SvnVcs;
import org.jetbrains.idea.svn.api.Depth;
import org.jetbrains.idea.svn.branchConfig.ConfigureBranchesAction;
import org.jetbrains.idea.svn.commandLine.SvnBindException;
import org.jetbrains.idea.svn.status.Status;
import org.jetbrains.idea.svn.status.StatusConsumer;
import org.jetbrains.idea.svn.status.StatusType;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNURL;
@@ -375,17 +373,14 @@ public class SvnCommittedChangesProvider implements CachingCommittedChangesProvi
File rootFile = root.getIOFile();
myVcs.getFactory(rootFile).createStatusClient()
.doStatus(rootFile, SVNRevision.UNDEFINED, Depth.INFINITY, true, false, false, false, new StatusConsumer() {
@Override
public void consume(Status status) throws SVNException {
File file = status.getFile();
boolean changedOnServer = isNotNone(status.getRemoteContentsStatus()) ||
isNotNone(status.getRemoteNodeStatus()) ||
isNotNone(status.getRemotePropertiesStatus());
.doStatus(rootFile, SVNRevision.UNDEFINED, Depth.INFINITY, true, false, false, false, status -> {
File file = status.getFile();
boolean changedOnServer = isNotNone(status.getRemoteContentsStatus()) ||
isNotNone(status.getRemoteNodeStatus()) ||
isNotNone(status.getRemotePropertiesStatus());
if (file != null && changedOnServer) {
result.add(VcsUtil.getFilePath(file));
}
if (file != null && changedOnServer) {
result.add(VcsUtil.getFilePath(file));
}
}, null);
@@ -29,8 +29,6 @@ import com.intellij.util.Consumer;
import com.intellij.vcsUtil.VcsUtil;
import org.jetbrains.idea.svn.SvnVcs;
import java.util.List;
/**
* Created with IntelliJ IDEA.
* User: Irina.Chernushina
@@ -54,28 +52,24 @@ public class SvnEditCommitMessageFromFileHistoryAction extends AnAction {
final SvnFileRevision svnFileRevision = (SvnFileRevision) revision;
final Consumer<String> listener = VcsDataKeys.REMOTE_HISTORY_CHANGED_LISTENER.getData(e.getDataContext());
SvnEditCommitMessageAction.askAndEditRevision(svnFileRevision.getRevision().getNumber(), svnFileRevision.getCommitMessage(),
(SvnRepositoryLocation) svnFileRevision.getChangedRepositoryPath(), project, new Consumer<String>() {
@Override
public void consume(final String newMessage) {
svnFileRevision.setCommitMessage(newMessage);
if (listener != null) {
listener.consume(newMessage);
}
ProjectLevelVcsManager.getInstance(project).getVcsHistoryCache().editCached(VcsUtil.getFilePath(revisionVirtualFile), vcsKey,
new Consumer<List<VcsFileRevision>>() {
@Override
public void consume(List<VcsFileRevision> revisions) {
for (VcsFileRevision fileRevision : revisions) {
if (! (fileRevision instanceof SvnFileRevision)) continue;
if (((SvnFileRevision) fileRevision).getRevision().getNumber() == svnFileRevision.getRevision().getNumber()) {
((SvnFileRevision) fileRevision).setCommitMessage(newMessage);
break;
}
}
}
});
}
}, true);
(SvnRepositoryLocation)svnFileRevision.getChangedRepositoryPath(), project,
newMessage -> {
svnFileRevision.setCommitMessage(newMessage);
if (listener != null) {
listener.consume(newMessage);
}
ProjectLevelVcsManager.getInstance(project).getVcsHistoryCache()
.editCached(VcsUtil.getFilePath(revisionVirtualFile), vcsKey, revisions -> {
for (VcsFileRevision fileRevision : revisions) {
if (!(fileRevision instanceof SvnFileRevision)) continue;
if (((SvnFileRevision)fileRevision).getRevision().getNumber() ==
svnFileRevision.getRevision().getNumber()) {
((SvnFileRevision)fileRevision).setCommitMessage(newMessage);
break;
}
}
});
}, true);
}
@Override
@@ -19,7 +19,6 @@ import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.util.Throwable2Computable;
import com.intellij.openapi.vcs.RepositoryLocation;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vcs.history.VcsFileRevision;
@@ -174,12 +173,7 @@ public class SvnFileRevision implements VcsFileRevision {
else {
result = ContentRevisionCache.getOrLoadAsBytes(myVCS.getProject(), VcsUtil.getFilePathOnNonLocal(myURL, false), getRevisionNumber(),
myVCS.getKeyInstanceMethod(), ContentRevisionCache.UniqueType.REMOTE_CONTENT,
new Throwable2Computable<byte[], VcsException, IOException>() {
@Override
public byte[] compute() throws VcsException, IOException {
return loadContent();
}
});
() -> loadContent());
}
return result;
@@ -19,7 +19,6 @@ import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vcs.FilePath;
@@ -126,13 +125,10 @@ public class SvnHistoryProvider
field.setEditable(false);
field.setOpaque(false);
field.setWrapStyleWord(true);
listener = new Consumer<VcsFileRevision>() {
@Override
public void consume(VcsFileRevision vcsFileRevision) {
field.setText(mergeSourceColumn.getText(vcsFileRevision));
field.setCaretPosition(0);
field.repaint();
}
listener = vcsFileRevision -> {
field.setText(mergeSourceColumn.getText(vcsFileRevision));
field.setCaretPosition(0);
field.repaint();
};
final MergeSourceDetailsAction sourceAction = new MergeSourceDetailsAction();
@@ -255,15 +251,12 @@ public class SvnHistoryProvider
if (indicator != null) {
indicator.setText(SvnBundle.message("progress.text2.collecting.history", path.getName()));
}
final Consumer<VcsFileRevision> consumer = new Consumer<VcsFileRevision>() {
@Override
public void consume(VcsFileRevision vcsFileRevision) {
if (!Boolean.TRUE.equals(sessionReported.get())) {
partner.reportCreatedEmptySession(historySession);
sessionReported.set(true);
}
partner.acceptRevision(vcsFileRevision);
final Consumer<VcsFileRevision> consumer = vcsFileRevision -> {
if (!Boolean.TRUE.equals(sessionReported.get())) {
partner.reportCreatedEmptySession(historySession);
sessionReported.set(true);
}
partner.acceptRevision(vcsFileRevision);
};
logLoader.setConsumer(consumer);
@@ -372,12 +365,7 @@ public class SvnHistoryProvider
}
private static ThrowableConsumer<VcsFileRevision, SVNException> createConsumerAdapter(final Consumer<VcsFileRevision> consumer) {
return new ThrowableConsumer<VcsFileRevision, SVNException>() {
@Override
public void consume(VcsFileRevision revision) throws SVNException {
consumer.consume(revision);
}
};
return revision -> consumer.consume(revision);
}
private static class RepositoryLoader extends LogLoader {
@@ -459,13 +447,7 @@ public class SvnHistoryProvider
}
final RepositoryLogEntryHandler repositoryLogEntryHandler =
new RepositoryLogEntryHandler(myVcs, myUrl, SVNRevision.UNDEFINED, relativeUrl,
new ThrowableConsumer<VcsFileRevision, SVNException>() {
@Override
public void consume(VcsFileRevision revision) throws SVNException {
myConsumer.consume(revision);
}
}, rootURL);
new RepositoryLogEntryHandler(myVcs, myUrl, SVNRevision.UNDEFINED, relativeUrl, revision -> myConsumer.consume(revision), rootURL);
repositoryLogEntryHandler.setThrowCancelOnMeetPathCreation(true);
SvnTarget target = SvnTarget.fromURL(rootURL, myFrom);
@@ -536,56 +518,53 @@ public class SvnHistoryProvider
myPegRevision = pegRevision;
myUrl = url;
myRepositoryRoot = repoRootURL;
myTracker = new SvnMergeSourceTracker(new ThrowableConsumer<Pair<LogEntry, Integer>, SVNException>() {
@Override
public void consume(final Pair<LogEntry, Integer> svnLogEntryIntegerPair) throws SVNException {
final LogEntry logEntry = svnLogEntryIntegerPair.getFirst();
myTracker = new SvnMergeSourceTracker(svnLogEntryIntegerPair -> {
final LogEntry logEntry = svnLogEntryIntegerPair.getFirst();
if (myIndicator != null) {
if (myIndicator.isCanceled()) {
SVNErrorManager.cancel(SvnBundle.message("exception.text.update.operation.cancelled"), SVNLogType.DEFAULT);
}
myIndicator.setText2(SvnBundle.message("progress.text2.revision.processed", logEntry.getRevision()));
if (myIndicator != null) {
if (myIndicator.isCanceled()) {
SVNErrorManager.cancel(SvnBundle.message("exception.text.update.operation.cancelled"), SVNLogType.DEFAULT);
}
LogEntryPath entryPath = null;
String copyPath = null;
final int mergeLevel = svnLogEntryIntegerPair.getSecond();
myIndicator.setText2(SvnBundle.message("progress.text2.revision.processed", logEntry.getRevision()));
}
LogEntryPath entryPath = null;
String copyPath = null;
final int mergeLevel = svnLogEntryIntegerPair.getSecond();
if (! myLastPathCorrector.isRoot()) {
myLastPathCorrector.consume(logEntry);
entryPath = myLastPathCorrector.getDirectlyMentioned();
copyPath = null;
if (entryPath != null) {
copyPath = entryPath.getCopyPath();
} else {
// if there are no path with exact match, check whether parent or child paths had changed
// "entry path" is allowed to be null now; if it is null, last path would be taken for revision construction
// Separate LogEntry is issued for each "merge source" revision. These "merge source" revisions are treated as child
// revisions of some other revision - this way we construct merge hierarchy.
// mergeLevel >= 0 indicates that we are currently processing some "merge source" revision. This "merge source" revision
// contains changes from some other branch - so checkForChildChanges() and checkForParentChanges() return "false".
// Because of this case we apply these methods only for non-"merge source" revisions - this means mergeLevel < 0.
// TODO: Do not apply path filtering even for log entries on the first level => just output of 'svn log' should be returned.
// TODO: Looks like there is no cases when we issue 'svn log' for some parent paths or some other cases where we need such
// TODO: filtering. Check user feedback on this.
// if (mergeLevel < 0 && !checkForChildChanges(logEntry) && !checkForParentChanges(logEntry)) return;
}
}
final SvnFileRevision revision = createRevision(logEntry, copyPath, entryPath);
if (mergeLevel >= 0) {
addToListByLevel((SvnFileRevision)myPrevious, revision, mergeLevel);
if (!myLastPathCorrector.isRoot()) {
myLastPathCorrector.consume(logEntry);
entryPath = myLastPathCorrector.getDirectlyMentioned();
copyPath = null;
if (entryPath != null) {
copyPath = entryPath.getCopyPath();
}
else {
myResult.consume(revision);
myPrevious = revision;
}
if (myThrowCancelOnMeetPathCreation && myUrl.equals(revision.getURL()) && entryPath != null && entryPath.getType() == 'A') {
throw new SVNCancelException();
// if there are no path with exact match, check whether parent or child paths had changed
// "entry path" is allowed to be null now; if it is null, last path would be taken for revision construction
// Separate LogEntry is issued for each "merge source" revision. These "merge source" revisions are treated as child
// revisions of some other revision - this way we construct merge hierarchy.
// mergeLevel >= 0 indicates that we are currently processing some "merge source" revision. This "merge source" revision
// contains changes from some other branch - so checkForChildChanges() and checkForParentChanges() return "false".
// Because of this case we apply these methods only for non-"merge source" revisions - this means mergeLevel < 0.
// TODO: Do not apply path filtering even for log entries on the first level => just output of 'svn log' should be returned.
// TODO: Looks like there is no cases when we issue 'svn log' for some parent paths or some other cases where we need such
// TODO: filtering. Check user feedback on this.
// if (mergeLevel < 0 && !checkForChildChanges(logEntry) && !checkForParentChanges(logEntry)) return;
}
}
final SvnFileRevision revision = createRevision(logEntry, copyPath, entryPath);
if (mergeLevel >= 0) {
addToListByLevel((SvnFileRevision)myPrevious, revision, mergeLevel);
}
else {
myResult.consume(revision);
myPrevious = revision;
}
if (myThrowCancelOnMeetPathCreation && myUrl.equals(revision.getURL()) && entryPath != null && entryPath.getType() == 'A') {
throw new SVNCancelException();
}
});
}
@@ -8,7 +8,6 @@ import org.jetbrains.idea.svn.api.BaseSvnClient;
import org.jetbrains.idea.svn.commandLine.SvnBindException;
import org.tmatesoft.svn.core.ISVNLogEntryHandler;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNLogEntry;
import org.tmatesoft.svn.core.wc.SVNLogClient;
import org.tmatesoft.svn.core.wc.SVNRevision;
import org.tmatesoft.svn.core.wc2.SvnTarget;
@@ -52,12 +51,7 @@ public class SvnKitHistoryClient extends BaseSvnClient implements HistoryClient
ISVNLogEntryHandler result = null;
if (handler != null) {
result = new ISVNLogEntryHandler() {
@Override
public void handleLogEntry(SVNLogEntry logEntry) throws SVNException {
handler.consume(LogEntry.create(logEntry));
}
};
result = logEntry -> handler.consume(LogEntry.create(logEntry));
}
return result;
@@ -61,23 +61,20 @@ public class SvnLogUtil implements SvnLogLoader {
final SVNRevision toIncluding,
final boolean includingYoungest,
final boolean includeOldest, final List<CommittedChangeList> result) {
return new LogEntryConsumer() {
@Override
public void consume(LogEntry logEntry) {
if (myProject.isDisposed()) throw new ProcessCanceledException();
final ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
if (progress != null) {
progress.setText2(SvnBundle.message("progress.text2.processing.revision", logEntry.getRevision()));
progress.checkCanceled();
}
if ((!includingYoungest) && (logEntry.getRevision() == fromIncluding.getNumber())) {
return;
}
if ((!includeOldest) && (logEntry.getRevision() == toIncluding.getNumber())) {
return;
}
result.add(new SvnChangeList(myVcs, myLocation, logEntry, myRepositoryRoot.toString()));
return logEntry -> {
if (myProject.isDisposed()) throw new ProcessCanceledException();
final ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
if (progress != null) {
progress.setText2(SvnBundle.message("progress.text2.processing.revision", logEntry.getRevision()));
progress.checkCanceled();
}
if ((!includingYoungest) && (logEntry.getRevision() == fromIncluding.getNumber())) {
return;
}
if ((!includeOldest) && (logEntry.getRevision() == toIncluding.getNumber())) {
return;
}
result.add(new SvnChangeList(myVcs, myLocation, logEntry, myRepositoryRoot.toString()));
};
}
}
@@ -30,7 +30,6 @@ import org.jetbrains.annotations.Nullable;
import org.jetbrains.idea.svn.SvnBundle;
import org.jetbrains.idea.svn.SvnUtil;
import org.jetbrains.idea.svn.branchConfig.SelectBranchPopup;
import org.jetbrains.idea.svn.branchConfig.SvnBranchConfigurationNew;
import org.jetbrains.idea.svn.branchConfig.SvnBranchMapperManager;
import org.jetbrains.idea.svn.dialogs.WCInfoWithBranches;
import org.jetbrains.idea.svn.integrate.IntegratedSelectedOptionsDialog;
@@ -39,8 +38,6 @@ import org.tmatesoft.svn.core.SVNURL;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Map;
import java.util.Set;
@@ -80,39 +77,29 @@ public class SvnMergeInfoRootPanelManual {
}
private void initWithData() {
myInclude.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
myListener.run();
}
});
myInclude.addActionListener(e -> myListener.run());
myUrlText.setText(myInfo.getUrl().toString());
myFixedSelectLocal.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
if (mySelectedBranch != null) {
Pair<WorkingCopyInfo, SVNURL> info =
IntegratedSelectedOptionsDialog.selectWorkingCopy(myProject, myInfo.getUrl(), mySelectedBranch.getUrl(), false, null, null);
if (info != null) {
calculateBranchPathByBranch(mySelectedBranch.getUrl(), info.getFirst().getLocalPath());
}
myListener.run();
myFixedSelectLocal.addActionListener(e -> {
if (mySelectedBranch != null) {
Pair<WorkingCopyInfo, SVNURL> info =
IntegratedSelectedOptionsDialog.selectWorkingCopy(myProject, myInfo.getUrl(), mySelectedBranch.getUrl(), false, null, null);
if (info != null) {
calculateBranchPathByBranch(mySelectedBranch.getUrl(), info.getFirst().getLocalPath());
}
myListener.run();
}
});
myBranchField.getTextField().setEditable(false);
myBranchField.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
final VirtualFile vf = SvnUtil.getVirtualFile(myInfo.getPath());
if (vf != null) {
SelectBranchPopup.show(myProject, vf, new SelectBranchPopup.BranchSelectedCallback() {
public void branchSelected(final Project project, final SvnBranchConfigurationNew configuration, final String url, final long revision) {
refreshSelectedBranch(new WCInfoWithBranches.Branch(url));
calculateBranchPathByBranch(mySelectedBranch.getUrl(), null);
myListener.run();
}
}, SvnBundle.message("select.branch.popup.general.title"));
}
myBranchField.addActionListener(e -> {
final VirtualFile vf = SvnUtil.getVirtualFile(myInfo.getPath());
if (vf != null) {
SelectBranchPopup.show(myProject, vf, (project, configuration, url, revision) -> {
refreshSelectedBranch(new WCInfoWithBranches.Branch(url));
calculateBranchPathByBranch(mySelectedBranch.getUrl(), null);
myListener.run();
}, SvnBundle.message("select.branch.popup.general.title"));
}
});
@@ -41,7 +41,7 @@ public class SvnRevisionsNavigationMediator implements CommittedChangesNavigatio
private final InternallyCachedProvider myInternallyCached;
private final VisuallyCachedProvider myVisuallyCached;
private final List<List<Fragment>> myChunks;
private boolean myCanNotGoBack;
private int myCurrentIdx;
@@ -58,15 +58,12 @@ public class SvnRevisionsNavigationMediator implements CommittedChangesNavigatio
final VcsException[] exception = new VcsException[1];
final Ref<Info> infoRef = new Ref<>();
Runnable process = new Runnable() {
@Override
public void run() {
try {
infoRef.set(vcs.getInfo(location.toSvnUrl(), SVNRevision.HEAD));
}
catch (SvnBindException e) {
exception[0] = e;
}
Runnable process = () -> {
try {
infoRef.set(vcs.getInfo(location.toSvnUrl(), SVNRevision.HEAD));
}
catch (SvnBindException e) {
exception[0] = e;
}
};
underProgress(exception, process);
@@ -77,8 +74,10 @@ public class SvnRevisionsNavigationMediator implements CommittedChangesNavigatio
}
final Iterator<ChangesBunch> visualIterator = project.isDefault() ? null :
CommittedChangesCache.getInstance(project).getBackBunchedIterator(vcs, vcsRoot, location, CHUNK_SIZE);
final Iterator<ChangesBunch> internalIterator = project.isDefault() ? null : LoadedRevisionsCache.getInstance(project).iterator(location.getURL());
CommittedChangesCache.getInstance(project)
.getBackBunchedIterator(vcs, vcsRoot, location, CHUNK_SIZE);
final Iterator<ChangesBunch> internalIterator =
project.isDefault() ? null : LoadedRevisionsCache.getInstance(project).iterator(location.getURL());
myInternallyCached = (internalIterator == null) ? null : new InternallyCachedProvider(internalIterator, myProject);
myVisuallyCached = (visualIterator == null) ? null : new VisuallyCachedProvider(visualIterator, myProject, location);
@@ -90,16 +89,13 @@ public class SvnRevisionsNavigationMediator implements CommittedChangesNavigatio
myCurrentIdx = -1;
underProgress(exception, new Runnable() {
@Override
public void run() {
// init first screen
try {
goBack();
}
catch (VcsException e) {
exception[0] = e;
}
underProgress(exception, () -> {
// init first screen
try {
goBack();
}
catch (VcsException e) {
exception[0] = e;
}
});
}
@@ -111,13 +107,13 @@ public class SvnRevisionsNavigationMediator implements CommittedChangesNavigatio
if (exception[0] != null) {
throw exception[0];
}
if (! succeeded) {
if (!succeeded) {
throw new ProcessCanceledException();
}
}
public boolean canGoBack() {
return ((myCurrentIdx + 1) < myChunks.size()) || (! myCanNotGoBack);
return ((myCurrentIdx + 1) < myChunks.size()) || (!myCanNotGoBack);
}
public boolean canGoForward() {
@@ -126,7 +122,7 @@ public class SvnRevisionsNavigationMediator implements CommittedChangesNavigatio
public void goBack() throws VcsException {
if ((myCurrentIdx + 1) < myChunks.size()) {
++ myCurrentIdx;
++myCurrentIdx;
return;
}
@@ -134,29 +130,29 @@ public class SvnRevisionsNavigationMediator implements CommittedChangesNavigatio
final List<Fragment> fragments = myChunkFactory.goBack(CHUNK_SIZE, canNotGoBackRef);
myCanNotGoBack = canNotGoBackRef.get().booleanValue();
if (! fragments.isEmpty()) {
if (!fragments.isEmpty()) {
// load
++ myCurrentIdx;
++myCurrentIdx;
myChunks.add(fragments);
}
}
public void goForward() {
-- myCurrentIdx;
--myCurrentIdx;
}
public List<CommittedChangeList> getCurrent() {
debugPrinting();
return (List<CommittedChangeList>) ((myChunks.isEmpty()) ? Collections.<List<CommittedChangeList>>emptyList() :
fragmentsToLists(myChunks.get(myCurrentIdx)));
return (List<CommittedChangeList>)((myChunks.isEmpty()) ? Collections.<List<CommittedChangeList>>emptyList() :
fragmentsToLists(myChunks.get(myCurrentIdx)));
}
private void debugPrinting() {
LOG.debug("== showing screen (" + myCurrentIdx + "): ==");
if (! myChunks.isEmpty()) {
if (!myChunks.isEmpty()) {
for (Fragment fragment : myChunks.get(myCurrentIdx)) {
LOG.debug(fragment.getOrigin().toString() + " from: " + fragment.getList().get(0).getNumber() +
" to: " + fragment.getList().get(fragment.getList().size() - 1).getNumber());
" to: " + fragment.getList().get(fragment.getList().size() - 1).getNumber());
}
}
LOG.debug("== end of screen ==");
@@ -175,9 +171,11 @@ public class SvnRevisionsNavigationMediator implements CommittedChangesNavigatio
myVisuallyCached.doCacheUpdate(myChunks);
// keep also in internal cache
InternallyCachedProvider.initCache(myChunks, myProject);
} else if (myInternallyCached != null) {
}
else if (myInternallyCached != null) {
myInternallyCached.doCacheUpdate(myChunks);
} else {
}
else {
InternallyCachedProvider.initCache(myChunks, myProject);
}
}
@@ -209,13 +207,13 @@ public class SvnRevisionsNavigationMediator implements CommittedChangesNavigatio
@Override
protected void addToLoaded(final ChangesBunch loaded) {
myHolesDetected |= (! loaded.isConsistentWithPrevious());
myHolesDetected |= (!loaded.isConsistentWithPrevious());
super.addToLoaded(loaded);
}
public static void initCache(final List<List<Fragment>> fragmentListList, final Project project) {
final List<CommittedChangeList> lists = getAllBeforeVisuallyCached(fragmentListList);
if (! lists.isEmpty()) {
if (!lists.isEmpty()) {
LoadedRevisionsCache.getInstance(project).put(lists, false, null);
}
}
@@ -233,7 +231,7 @@ public class SvnRevisionsNavigationMediator implements CommittedChangesNavigatio
final Fragment fragment = fragmentList.get(j);
liveMet |= Origin.LIVE.equals(fragment.getOrigin());
if (Origin.INTERNAL.equals(fragment.getOrigin())) {
bindAddress = ((LoadedRevisionsCache.Bunch) fragment.getOriginBunch()).getNext();
bindAddress = ((LoadedRevisionsCache.Bunch)fragment.getOriginBunch()).getNext();
// latest element
if ((i == (fragmentsListList.size() - 1)) && (j == (fragmentList.size() - 1))) {
lists.addAll(fragment.getOriginBunch().getList());
@@ -244,15 +242,16 @@ public class SvnRevisionsNavigationMediator implements CommittedChangesNavigatio
lists.addAll(fragment.getList());
}
}
if (! liveMet) {
if (!liveMet) {
return;
}
} else {
}
else {
// until _first_internally
for (List<Fragment> fragmentList : fragmentsListList) {
for (Fragment fragment : fragmentList) {
if (Origin.INTERNAL.equals(fragment.getOrigin())) {
bindAddress = (LoadedRevisionsCache.Bunch) fragment.getOriginBunch();
bindAddress = (LoadedRevisionsCache.Bunch)fragment.getOriginBunch();
consistent = true;
break;
}
@@ -261,7 +260,7 @@ public class SvnRevisionsNavigationMediator implements CommittedChangesNavigatio
}
}
if (! lists.isEmpty()) {
if (!lists.isEmpty()) {
LoadedRevisionsCache.getInstance(myProject).put(lists, consistent, bindAddress);
}
}
@@ -33,7 +33,6 @@ import org.tmatesoft.svn.core.internal.util.SVNPathUtil;
import java.io.File;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
public class WcInfoLoader {
@@ -107,11 +106,7 @@ public class WcInfoLoader {
}
}
Collections.sort(branches, new Comparator<WCInfoWithBranches.Branch>() {
public int compare(final WCInfoWithBranches.Branch o1, final WCInfoWithBranches.Branch o2) {
return Comparing.compare(o1.getUrl(), o2.getUrl());
}
});
Collections.sort(branches, (o1, o2) -> Comparing.compare(o1.getUrl(), o2.getUrl()));
return new WCInfoWithBranches(info, branches, rootUrlInfo.getRoot(), workingCopyBranch.get());
}
@@ -21,7 +21,6 @@ import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.CharsetToolkit;
import com.intellij.util.Consumer;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -104,15 +103,12 @@ public class CmdInfoClient extends BaseSvnClient implements InfoClient {
return;
}
final SvnInfoHandler infoHandler = new SvnInfoHandler(base, new Consumer<Info>() {
@Override
public void consume(Info info) {
try {
handler.consume(info);
}
catch (SVNException e) {
throw new SvnExceptionWrapper(e);
}
final SvnInfoHandler infoHandler = new SvnInfoHandler(base, info -> {
try {
handler.consume(info);
}
catch (SVNException e) {
throw new SvnExceptionWrapper(e);
}
});
@@ -144,204 +144,39 @@ public class SvnInfoHandler extends DefaultHandler {
}
private void fillElements() {
myElementsMap.put("copy-from-url", new Getter<ElementHandlerBase>() {
@Override
public ElementHandlerBase get() {
return new CopyFromUrl();
}
});
myElementsMap.put("copy-from-rev", new Getter<ElementHandlerBase>() {
@Override
public ElementHandlerBase get() {
return new CopyFromRev();
}
});
myElementsMap.put("changelist", new Getter<ElementHandlerBase>() {
@Override
public ElementHandlerBase get() {
return new ChangeList();
}
});
myElementsMap.put("author", new Getter<ElementHandlerBase>() {
@Override
public ElementHandlerBase get() {
return new Author();
}
});
myElementsMap.put("checksum", new Getter<ElementHandlerBase>() {
@Override
public ElementHandlerBase get() {
return new Checksum();
}
});
myElementsMap.put("commit", new Getter<ElementHandlerBase>() {
@Override
public ElementHandlerBase get() {
return new Commit();
}
});
myElementsMap.put("conflict", new Getter<ElementHandlerBase>() {
@Override
public ElementHandlerBase get() {
return new Conflict();
}
});
myElementsMap.put("cur-base-file", new Getter<ElementHandlerBase>() {
@Override
public ElementHandlerBase get() {
return new CurBase();
}
});
myElementsMap.put("date", new Getter<ElementHandlerBase>() {
@Override
public ElementHandlerBase get() {
return new Date();
}
});
myElementsMap.put("depth", new Getter<ElementHandlerBase>() {
@Override
public ElementHandlerBase get() {
return new Depth();
}
});
myElementsMap.put("entry", new Getter<ElementHandlerBase>() {
@Override
public ElementHandlerBase get() {
return new Entry(myBase);
}
});
myElementsMap.put("info", new Getter<ElementHandlerBase>() {
@Override
public ElementHandlerBase get() {
return new Info();
}
});
myElementsMap.put("prev-base-file", new Getter<ElementHandlerBase>() {
@Override
public ElementHandlerBase get() {
return new PrevBase();
}
});
myElementsMap.put("prev-wc-file", new Getter<ElementHandlerBase>() {
@Override
public ElementHandlerBase get() {
return new PrevWc();
}
});
myElementsMap.put("prop-file", new Getter<ElementHandlerBase>() {
@Override
public ElementHandlerBase get() {
return new PropFile();
}
});
myElementsMap.put("repository", new Getter<ElementHandlerBase>() {
@Override
public ElementHandlerBase get() {
return new Repository();
}
});
myElementsMap.put("root", new Getter<ElementHandlerBase>() {
@Override
public ElementHandlerBase get() {
return new Root();
}
});
myElementsMap.put("schedule", new Getter<ElementHandlerBase>() {
@Override
public ElementHandlerBase get() {
return new Schedule();
}
});
myElementsMap.put("text-updated", new Getter<ElementHandlerBase>() {
@Override
public ElementHandlerBase get() {
return new TextUpdated();
}
});
myElementsMap.put("tree-conflict", new Getter<ElementHandlerBase>() {
@Override
public ElementHandlerBase get() {
return new TreeConflict();
}
});
myElementsMap.put("url", new Getter<ElementHandlerBase>() {
@Override
public ElementHandlerBase get() {
return new Url();
}
});
myElementsMap.put("relative-url", new Getter<ElementHandlerBase>() {
@Override
public ElementHandlerBase get() {
return new RelativeUrl();
}
});
myElementsMap.put("lock", new Getter<ElementHandlerBase>() {
@Override
public ElementHandlerBase get() {
return new LockElement();
}
});
myElementsMap.put("token", new Getter<ElementHandlerBase>() {
@Override
public ElementHandlerBase get() {
return new LockToken();
}
});
myElementsMap.put("owner", new Getter<ElementHandlerBase>() {
@Override
public ElementHandlerBase get() {
return new LockOwner();
}
});
myElementsMap.put("comment", new Getter<ElementHandlerBase>() {
@Override
public ElementHandlerBase get() {
return new LockComment();
}
});
myElementsMap.put("created", new Getter<ElementHandlerBase>() {
@Override
public ElementHandlerBase get() {
return new LockCreated();
}
});
myElementsMap.put("uuid", new Getter<ElementHandlerBase>() {
@Override
public ElementHandlerBase get() {
return new Uuid();
}
});
myElementsMap.put("version", new Getter<ElementHandlerBase>() {
@Override
public ElementHandlerBase get() {
return new Version();
}
});
myElementsMap.put("wc-info", new Getter<ElementHandlerBase>() {
@Override
public ElementHandlerBase get() {
return new WcInfo();
}
});
myElementsMap.put("moved-to", new Getter<ElementHandlerBase>() {
@Override
public ElementHandlerBase get() {
return new MovedPath();
}
});
myElementsMap.put("moved-from", new Getter<ElementHandlerBase>() {
@Override
public ElementHandlerBase get() {
return new MovedPath();
}
});
myElementsMap.put("wcroot-abspath", new Getter<ElementHandlerBase>() {
@Override
public ElementHandlerBase get() {
return new WcRoot();
}
});
myElementsMap.put("copy-from-url", () -> new CopyFromUrl());
myElementsMap.put("copy-from-rev", () -> new CopyFromRev());
myElementsMap.put("changelist", () -> new ChangeList());
myElementsMap.put("author", () -> new Author());
myElementsMap.put("checksum", () -> new Checksum());
myElementsMap.put("commit", () -> new Commit());
myElementsMap.put("conflict", () -> new Conflict());
myElementsMap.put("cur-base-file", () -> new CurBase());
myElementsMap.put("date", () -> new Date());
myElementsMap.put("depth", () -> new Depth());
myElementsMap.put("entry", () -> new Entry(myBase));
myElementsMap.put("info", () -> new Info());
myElementsMap.put("prev-base-file", () -> new PrevBase());
myElementsMap.put("prev-wc-file", () -> new PrevWc());
myElementsMap.put("prop-file", () -> new PropFile());
myElementsMap.put("repository", () -> new Repository());
myElementsMap.put("root", () -> new Root());
myElementsMap.put("schedule", () -> new Schedule());
myElementsMap.put("text-updated", () -> new TextUpdated());
myElementsMap.put("tree-conflict", () -> new TreeConflict());
myElementsMap.put("url", () -> new Url());
myElementsMap.put("relative-url", () -> new RelativeUrl());
myElementsMap.put("lock", () -> new LockElement());
myElementsMap.put("token", () -> new LockToken());
myElementsMap.put("owner", () -> new LockOwner());
myElementsMap.put("comment", () -> new LockComment());
myElementsMap.put("created", () -> new LockCreated());
myElementsMap.put("uuid", () -> new Uuid());
myElementsMap.put("version", () -> new Version());
myElementsMap.put("wc-info", () -> new WcInfo());
myElementsMap.put("moved-to", () -> new MovedPath());
myElementsMap.put("moved-from", () -> new MovedPath());
myElementsMap.put("wcroot-abspath", () -> new WcRoot());
}
public Map<File, org.jetbrains.idea.svn.info.Info> getResultsMap() {
@@ -40,8 +40,6 @@ import org.jetbrains.idea.svn.info.Info;
import org.tmatesoft.svn.core.SVNURL;
import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.io.File;
import java.util.*;
@@ -77,11 +75,8 @@ public class IntegratedSelectedOptionsDialog extends DialogWrapper {
init();
myWorkingCopiesList.setModel(new DefaultListModel());
myWorkingCopiesList.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(final ListSelectionEvent e) {
setOKActionEnabled((! myMustSelectBeforeOk) || (myWorkingCopiesList.getSelectedIndex() != -1));
}
});
myWorkingCopiesList
.addListSelectionListener(e -> setOKActionEnabled((!myMustSelectBeforeOk) || (myWorkingCopiesList.getSelectedIndex() != -1)));
setOKActionEnabled((! myMustSelectBeforeOk) || (myWorkingCopiesList.getSelectedIndex() != -1));
final List<WorkingCopyInfo> workingCopyInfoList = new ArrayList<>();
@@ -212,12 +207,9 @@ public class IntegratedSelectedOptionsDialog extends DialogWrapper {
}
private boolean underProject(final File file) {
return ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
@Override
public Boolean compute() {
final VirtualFile vf = SvnUtil.getVirtualFile(file.getAbsolutePath());
return (vf == null) || PeriodicalTasksCloser.getInstance().safeGetService(myProject, FileIndexFacade.class).isInContent(vf);
}
return ApplicationManager.getApplication().runReadAction((Computable<Boolean>)() -> {
final VirtualFile vf = SvnUtil.getVirtualFile(file.getAbsolutePath());
return (vf == null) || PeriodicalTasksCloser.getInstance().safeGetService(myProject, FileIndexFacade.class).isInContent(vf);
});
}
@@ -23,8 +23,6 @@ import com.intellij.util.ui.JBUI;
import com.intellij.util.ui.UIUtil;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* @author irengrig
@@ -47,12 +45,7 @@ public abstract class MoreAction extends AnAction implements CustomComponentAct
myPanel.setLayout(layout);
myLoadMoreBtn = new JButton(name);
myLoadMoreBtn.setMargin(JBUI.insets(2));
myLoadMoreBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
MoreAction.this.actionPerformed(null);
}
});
myLoadMoreBtn.addActionListener(e -> MoreAction.this.actionPerformed(null));
myPanel.add(myLoadMoreBtn);
myLabel = new JLabel("Loading...");
myLabel.setForeground(UIUtil.getInactiveTextColor());
@@ -21,7 +21,6 @@ import com.intellij.util.ui.JBUI;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
@@ -59,12 +58,9 @@ public class QuickMergeWayOptionsPanel {
}
private ActionListener setCodeAndClose(@NotNull QuickMergeContentsVariants variant) {
return new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
myVariant = variant;
close();
}
return e -> {
myVariant = variant;
close();
};
}
@@ -46,21 +46,18 @@ public class ResolveWorker {
}
private void refreshChangeListsFindConflicts(final UpdatedFiles updatedFiles) {
UpdateFilesHelper.iterateFileGroupFiles(updatedFiles,
new UpdateFilesHelper.Callback() {
public void onFile(final String filePath, final String groupId) {
final VirtualFile vf = SvnUtil.getVirtualFile(filePath);
if (vf != null) {
// refresh base directory so that conflict files should be detected
// file itself is already refreshed
vf.getParent().refresh(false, false);
myDirtyScopeManager.fileDirty(vf);
}
if (FileGroup.MERGED_WITH_CONFLICT_ID.equals(groupId)) {
myConflictedVirtualFiles.add(vf);
}
}
});
UpdateFilesHelper.iterateFileGroupFiles(updatedFiles, (filePath, groupId) -> {
final VirtualFile vf = SvnUtil.getVirtualFile(filePath);
if (vf != null) {
// refresh base directory so that conflict files should be detected
// file itself is already refreshed
vf.getParent().refresh(false, false);
myDirtyScopeManager.fileDirty(vf);
}
if (FileGroup.MERGED_WITH_CONFLICT_ID.equals(groupId)) {
myConflictedVirtualFiles.add(vf);
}
});
}
public boolean needsInteraction(final UpdatedFiles updatedFiles) {

Some files were not shown because too many files have changed in this diff Show More