Search in sources :

Example 1 with FilePath

use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.

the class HgUpdateEnvironment method updateDirectories.

@NotNull
public UpdateSession updateDirectories(@NotNull FilePath[] contentRoots, UpdatedFiles updatedFiles, ProgressIndicator indicator, @NotNull Ref<SequentialUpdatesContext> context) {
    List<VcsException> exceptions = new LinkedList<>();
    boolean result = true;
    for (FilePath contentRoot : contentRoots) {
        if (indicator != null) {
            indicator.checkCanceled();
            indicator.startNonCancelableSection();
        }
        VirtualFile repository = ProjectLevelVcsManager.getInstance(project).getVcsRootFor(contentRoot);
        if (repository == null) {
            continue;
        }
        try {
            HgUpdater updater = new HgRegularUpdater(project, repository, updateConfiguration);
            result &= updater.update(updatedFiles, indicator, exceptions);
        } catch (VcsException e) {
            //TODO include module name where exception occurred
            exceptions.add(e);
        }
        if (indicator != null) {
            indicator.finishNonCancelableSection();
        }
    }
    return new UpdateSessionAdapter(exceptions, !result);
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) VirtualFile(com.intellij.openapi.vfs.VirtualFile) VcsException(com.intellij.openapi.vcs.VcsException) LinkedList(java.util.LinkedList) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with FilePath

use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.

the class HgUtil method removeFilesFromVcs.

/**
   * Calls 'hg remove' to remove given files from the VCS.
   * @param project
   * @param files files to be removed from the VCS.
   */
public static void removeFilesFromVcs(Project project, List<FilePath> files) {
    final HgRemoveCommand command = new HgRemoveCommand(project);
    for (FilePath filePath : files) {
        final VirtualFile vcsRoot = VcsUtil.getVcsRootFor(project, filePath);
        if (vcsRoot == null) {
            continue;
        }
        command.executeInCurrentThread(new HgFile(vcsRoot, filePath));
    }
}
Also used : HgRemoveCommand(org.zmlx.hg4idea.command.HgRemoveCommand) FilePath(com.intellij.openapi.vcs.FilePath) VirtualFile(com.intellij.openapi.vfs.VirtualFile) VcsVirtualFile(com.intellij.openapi.vcs.vfs.VcsVirtualFile) AbstractVcsVirtualFile(com.intellij.openapi.vcs.vfs.AbstractVcsVirtualFile)

Example 3 with FilePath

use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.

the class HgHistoryTest method testUncommittedRenamedFileHistory.

public void testUncommittedRenamedFileHistory() throws HgCommandException {
    cd(myRepository);
    VirtualFile subDir = myRepository.findFileByRelativePath(subDirName);
    assert subDir != null;
    cd(subDir);
    int namesSize = names.length;
    String beforeName = names[namesSize - 1];
    VirtualFile before = VfsUtil.findFileByIoFile(new File(subDir.getPath(), beforeName), true);
    assert before != null;
    FilePath filePath = VcsUtil.getFilePath(VfsUtilCore.virtualToIoFile(before));
    final String renamed = "renamed";
    hg("mv " + beforeName + " " + renamed);
    myRepository.refresh(false, true);
    List<HgFileRevision> revisions = HgHistoryProvider.getHistory((filePath), myRepository, myProject);
    assertEquals(3, revisions.size());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FilePath(com.intellij.openapi.vcs.FilePath) HgFileRevision(org.zmlx.hg4idea.HgFileRevision) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) HgFile(org.zmlx.hg4idea.HgFile)

Example 4 with FilePath

use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.

the class SvnCheckinHandlerFactory method createVcsHandler.

@NotNull
@Override
protected CheckinHandler createVcsHandler(final CheckinProjectPanel panel) {
    final Project project = panel.getProject();
    final Collection<VirtualFile> commitRoots = panel.getRoots();
    return new CheckinHandler() {

        private Collection<Change> myChanges = panel.getSelectedChanges();

        @Override
        public RefreshableOnComponent getBeforeCheckinConfigurationPanel() {
            return null;
        }

        @Override
        public ReturnResult beforeCheckin(@Nullable CommitExecutor executor, PairConsumer<Object, Object> additionalDataConsumer) {
            if (executor instanceof LocalCommitExecutor)
                return ReturnResult.COMMIT;
            final SvnVcs vcs = SvnVcs.getInstance(project);
            final MultiMap<String, WorkingCopyFormat> copiesInfo = splitIntoCopies(vcs, myChanges);
            final List<String> repoUrls = new ArrayList<>();
            for (Map.Entry<String, Collection<WorkingCopyFormat>> entry : copiesInfo.entrySet()) {
                if (entry.getValue().size() > 1) {
                    repoUrls.add(entry.getKey());
                }
            }
            if (!repoUrls.isEmpty()) {
                final String join = StringUtil.join(repoUrls, ",\n");
                final int isOk = Messages.showOkCancelDialog(project, SvnBundle.message("checkin.different.formats.involved", repoUrls.size() > 1 ? 1 : 0, join), "Subversion: Commit Will Split", Messages.getWarningIcon());
                return Messages.OK == isOk ? ReturnResult.COMMIT : ReturnResult.CANCEL;
            }
            return ReturnResult.COMMIT;
        }

        @Override
        public void includedChangesChanged() {
            myChanges = panel.getSelectedChanges();
        }

        @Override
        public void checkinSuccessful() {
            if (SvnConfiguration.getInstance(project).isAutoUpdateAfterCommit()) {
                final VirtualFile[] roots = ProjectLevelVcsManager.getInstance(project).getRootsUnderVcs(SvnVcs.getInstance(project));
                final List<FilePath> paths = new ArrayList<>();
                for (VirtualFile root : roots) {
                    boolean take = false;
                    for (VirtualFile commitRoot : commitRoots) {
                        if (VfsUtilCore.isAncestor(root, commitRoot, false)) {
                            take = true;
                            break;
                        }
                    }
                    if (take) {
                        paths.add(VcsUtil.getFilePath(root));
                    }
                }
                if (paths.isEmpty())
                    return;
                ApplicationManager.getApplication().invokeLater(() -> AutoSvnUpdater.run(new AutoSvnUpdater(project, paths.toArray(new FilePath[paths.size()])), ActionInfo.UPDATE.getActionName()), ModalityState.NON_MODAL);
            }
        }
    };
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FilePath(com.intellij.openapi.vcs.FilePath) LocalCommitExecutor(com.intellij.openapi.vcs.changes.LocalCommitExecutor) ArrayList(java.util.ArrayList) CheckinHandler(com.intellij.openapi.vcs.checkin.CheckinHandler) LocalCommitExecutor(com.intellij.openapi.vcs.changes.LocalCommitExecutor) CommitExecutor(com.intellij.openapi.vcs.changes.CommitExecutor) Project(com.intellij.openapi.project.Project) PairConsumer(com.intellij.util.PairConsumer) Collection(java.util.Collection) AutoSvnUpdater(org.jetbrains.idea.svn.update.AutoSvnUpdater) Map(java.util.Map) MultiMap(com.intellij.util.containers.MultiMap) Nullable(org.jetbrains.annotations.Nullable) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with FilePath

use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.

the class AutoSvnUpdater method actionPerformed.

@Override
protected void actionPerformed(@NotNull VcsContext context) {
    final SvnConfiguration configuration17 = SvnConfiguration.getInstance(myProject);
    configuration17.setForceUpdate(false);
    configuration17.setUpdateLockOnDemand(false);
    configuration17.setUpdateDepth(Depth.INFINITY);
    final SvnVcs vcs = SvnVcs.getInstance(myProject);
    for (FilePath root : myRoots) {
        configureUpdateRootInfo(root, configuration17.getUpdateRootInfo(root.getIOFile(), vcs));
    }
    super.actionPerformed(context);
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) SvnConfiguration(org.jetbrains.idea.svn.SvnConfiguration) SvnVcs(org.jetbrains.idea.svn.SvnVcs)

Aggregations

FilePath (com.intellij.openapi.vcs.FilePath)167 VirtualFile (com.intellij.openapi.vfs.VirtualFile)68 NotNull (org.jetbrains.annotations.NotNull)43 VcsException (com.intellij.openapi.vcs.VcsException)34 File (java.io.File)30 Change (com.intellij.openapi.vcs.changes.Change)26 Nullable (org.jetbrains.annotations.Nullable)22 Project (com.intellij.openapi.project.Project)20 ContentRevision (com.intellij.openapi.vcs.changes.ContentRevision)15 VcsFileRevision (com.intellij.openapi.vcs.history.VcsFileRevision)13 FileStatus (com.intellij.openapi.vcs.FileStatus)10 AbstractVcs (com.intellij.openapi.vcs.AbstractVcs)8 GitRepository (git4idea.repo.GitRepository)7 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)6 IOException (java.io.IOException)6 ArrayList (java.util.ArrayList)6 List (java.util.List)6 Test (org.junit.Test)6 StringUtil (com.intellij.openapi.util.text.StringUtil)5 Logger (com.intellij.openapi.diagnostic.Logger)4