use of org.jetbrains.idea.svn.SvnVcs in project intellij-community by JetBrains.
the class BasicAction method actionPerformed.
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
Project project = e.getData(CommonDataKeys.PROJECT);
VirtualFile[] files = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY);
if (isEmpty(files))
return;
SvnVcs vcs = SvnVcs.getInstance(project);
if (!ProjectLevelVcsManager.getInstance(project).checkAllFilesAreUnder(vcs, files))
return;
project.save();
String actionName = getActionName();
LocalHistoryAction action = LocalHistory.getInstance().startAction(actionName);
AbstractVcsHelper helper = AbstractVcsHelper.getInstance(project);
try {
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);
exceptionList.add(ex);
}
}, null);
helper.showErrors(exceptions, actionName);
} finally {
action.finish();
}
}
use of org.jetbrains.idea.svn.SvnVcs in project intellij-community by JetBrains.
the class CreateExternalAction method doInBackground.
private static void doInBackground(@NotNull Project project, @NotNull VirtualFile file, String url, boolean checkout, String target) {
SvnVcs vcs = SvnVcs.getInstance(project);
VcsDirtyScopeManager dirtyScopeManager = VcsDirtyScopeManager.getInstance(project);
File ioFile = virtualToIoFile(file);
try {
addToExternalProperty(vcs, ioFile, target, url);
dirtyScopeManager.fileDirty(file);
if (checkout) {
UpdateClient client = vcs.getFactory(ioFile).createUpdateClient();
client.setEventHandler(new SvnProgressCanceller());
client.doUpdate(ioFile, SVNRevision.HEAD, Depth.UNKNOWN, false, false);
file.refresh(true, true, () -> dirtyScopeManager.dirDirtyRecursively(file));
}
} catch (VcsException e) {
AbstractVcsHelper.getInstance(project).showError(e, "Create External");
}
}
use of org.jetbrains.idea.svn.SvnVcs in project intellij-community by JetBrains.
the class IgnoreActionGroup method update.
public void update(final AnActionEvent e) {
final FileGroupInfo fileGroupInfo = new FileGroupInfo();
myHelperAction.setFileIterationListener(fileGroupInfo);
myHelperAction.update(e);
myGetterStub.setDelegate(fileGroupInfo);
if ((e.getPresentation().isEnabled())) {
removeAll();
if (myHelperAction.allAreIgnored()) {
final DataContext dataContext = e.getDataContext();
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
SvnVcs vcs = SvnVcs.getInstance(project);
final Ref<Boolean> filesOk = new Ref<>(Boolean.FALSE);
final Ref<Boolean> extensionOk = new Ref<>(Boolean.FALSE);
// virtual files parameter is not used -> can pass null
SvnPropertyService.doCheckIgnoreProperty(vcs, null, fileGroupInfo, fileGroupInfo.getExtensionMask(), filesOk, extensionOk);
if (Boolean.TRUE.equals(filesOk.get())) {
myRemoveExactAction.setActionText(fileGroupInfo.oneFileSelected() ? fileGroupInfo.getFileName() : SvnBundle.message("action.Subversion.UndoIgnore.text"));
add(myRemoveExactAction);
}
if (Boolean.TRUE.equals(extensionOk.get())) {
myRemoveExtensionAction.setActionText(fileGroupInfo.getExtensionMask());
add(myRemoveExtensionAction);
}
e.getPresentation().setText(SvnBundle.message("group.RevertIgnoreChoicesGroup.text"));
} else if (myHelperAction.allCanBeIgnored()) {
final String ignoreExactlyName = (fileGroupInfo.oneFileSelected()) ? fileGroupInfo.getFileName() : SvnBundle.message("action.Subversion.Ignore.ExactMatch.text");
myAddExactAction.setActionText(ignoreExactlyName);
add(myAddExactAction);
if (fileGroupInfo.sameExtension()) {
myAddExtensionAction.setActionText(fileGroupInfo.getExtensionMask());
add(myAddExtensionAction);
}
e.getPresentation().setText(SvnBundle.message("group.IgnoreChoicesGroup.text"));
}
}
}
use of org.jetbrains.idea.svn.SvnVcs in project intellij-community by JetBrains.
the class BranchesLoader method loadBranches.
@NotNull
public List<SvnBranchItem> loadBranches() throws SVNException, VcsException {
SvnVcs vcs = SvnVcs.getInstance(myProject);
SVNURL branchesUrl = SVNURL.parseURIEncoded(myUrl);
List<SvnBranchItem> result = new LinkedList<>();
SvnTarget target = SvnTarget.fromURL(branchesUrl);
DirectoryEntryConsumer handler = createConsumer(result);
vcs.getFactory(target).create(BrowseClient.class, !myPassive).list(target, SVNRevision.HEAD, Depth.IMMEDIATES, handler);
Collections.sort(result);
return result;
}
use of org.jetbrains.idea.svn.SvnVcs in project intellij-community by JetBrains.
the class SvnCheckoutProvider method checkout.
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 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()) {
public void run(@NotNull final ProgressIndicator indicator) {
final WorkingCopyFormat format = selectedFormat == null ? UNKNOWN : selectedFormat;
SvnWorkingCopyFormatHolder.setPresetFormat(format);
SvnVcs vcs = SvnVcs.getInstance(project);
ProgressTracker handler = new CheckoutEventHandler(vcs, false, ProgressManager.getInstance().getProgressIndicator());
ProgressManager.progress(message("progress.text.checking.out", target.getAbsolutePath()));
try {
getFactory(vcs, format).createCheckoutClient().checkout(SvnTarget.fromURL(SVNURL.parseURIEncoded(url)), target, revision, depth, ignoreExternals, true, format, handler);
ProgressManager.checkCanceled();
checkoutSuccessful.set(Boolean.TRUE);
} catch (SVNCancelException ignore) {
} catch (SVNException | VcsException e) {
exception[0] = e;
} finally {
SvnWorkingCopyFormatHolder.setPresetFormat(null);
}
}
public void onCancel() {
onSuccess();
}
public void onSuccess() {
if (exception[0] != null) {
showErrorDialog(message("message.text.cannot.checkout", exception[0].getMessage()), message("message.title.check.out"));
}
VirtualFile vf = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(target);
if (vf != null) {
vf.refresh(true, true, () -> getApplication().invokeLater(() -> notifyListener()));
} else {
notifyListener();
}
}
private void notifyListener() {
notifyRootManagerIfUnderProject(project, target);
if (listener != null) {
if (!checkoutSuccessful.isNull()) {
listener.directoryCheckedOut(target, SvnVcs.getKey());
}
listener.checkoutCompleted();
}
}
};
ProgressManager.getInstance().run(checkoutBackgroundTask);
}
Aggregations