Search in sources :

Example 11 with Label

use of com.intellij.history.Label in project intellij-community by JetBrains.

the class HistoryReverterToLabelTest method testFileCreation.

public void testFileCreation() throws Exception {
    createChildData(myRoot, "first.txt");
    final Label testLabel = LocalHistory.getInstance().putSystemLabel(myProject, "testLabel");
    createChildData(myRoot, "foo.txt");
    revertToLabel(testLabel, myRoot);
    assertNull(myRoot.findChild("foo.txt"));
    assertNotNull(myRoot.findChild("first.txt"));
}
Also used : Label(com.intellij.history.Label)

Example 12 with Label

use of com.intellij.history.Label in project intellij-community by JetBrains.

the class GitMergeAction method perform.

protected void perform(@NotNull final Project project, @NotNull final List<VirtualFile> gitRoots, @NotNull final VirtualFile defaultRoot) {
    final DialogState dialogState = displayDialog(project, gitRoots, defaultRoot);
    if (dialogState == null) {
        return;
    }
    final VirtualFile selectedRoot = dialogState.selectedRoot;
    final Computable<GitLineHandler> handlerProvider = dialogState.handlerProvider;
    final Label beforeLabel = LocalHistory.getInstance().putSystemLabel(project, "Before update");
    new Task.Backgroundable(project, dialogState.progressTitle, true) {

        @Override
        public void run(@NotNull ProgressIndicator indicator) {
            final GitRepositoryManager repositoryManager = GitUtil.getRepositoryManager(project);
            final Git git = Git.getInstance();
            final GitLocalChangesWouldBeOverwrittenDetector localChangesDetector = new GitLocalChangesWouldBeOverwrittenDetector(selectedRoot, MERGE);
            final GitUntrackedFilesOverwrittenByOperationDetector untrackedFilesDetector = new GitUntrackedFilesOverwrittenByOperationDetector(selectedRoot);
            final GitSimpleEventDetector mergeConflict = new GitSimpleEventDetector(GitSimpleEventDetector.Event.MERGE_CONFLICT);
            AccessToken token = DvcsUtil.workingTreeChangeStarted(project);
            try {
                GitCommandResult result = git.runCommand(() -> {
                    GitLineHandler handler = handlerProvider.compute();
                    handler.addLineListener(localChangesDetector);
                    handler.addLineListener(untrackedFilesDetector);
                    handler.addLineListener(mergeConflict);
                    return handler;
                });
                GitRepository repository = repositoryManager.getRepositoryForRoot(selectedRoot);
                assert repository != null : "Repository can't be null for root " + selectedRoot;
                String revision = repository.getCurrentRevision();
                if (revision == null) {
                    return;
                }
                final GitRevisionNumber currentRev = new GitRevisionNumber(revision);
                handleResult(result, project, mergeConflict, localChangesDetector, untrackedFilesDetector, repository, currentRev, beforeLabel);
            } finally {
                token.finish();
            }
        }
    }.queue();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Task(com.intellij.openapi.progress.Task) Label(com.intellij.history.Label) GitRepositoryManager(git4idea.repo.GitRepositoryManager) GitRepository(git4idea.repo.GitRepository) GitRevisionNumber(git4idea.GitRevisionNumber) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) AccessToken(com.intellij.openapi.application.AccessToken)

Aggregations

Label (com.intellij.history.Label)12 VirtualFile (com.intellij.openapi.vfs.VirtualFile)8 Project (com.intellij.openapi.project.Project)2 GitRepository (git4idea.repo.GitRepository)2 LocalHistory (com.intellij.history.LocalHistory)1 AccessToken (com.intellij.openapi.application.AccessToken)1 ApplyPatchStatus (com.intellij.openapi.diff.impl.patch.ApplyPatchStatus)1 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 Task (com.intellij.openapi.progress.Task)1 Pair (com.intellij.openapi.util.Pair)1 Ref (com.intellij.openapi.util.Ref)1 GitRevisionNumber (git4idea.GitRevisionNumber)1 GitRepositoryManager (git4idea.repo.GitRepositoryManager)1 GitUpdateResult (git4idea.update.GitUpdateResult)1 CalledInAwt (org.jetbrains.annotations.CalledInAwt)1 NotNull (org.jetbrains.annotations.NotNull)1